instruction stringlengths 71 71.9k |
|---|
I wrote this code many years ago to analyze Excel data coming in from the clipboard.
Please review for performance and maintainability concerns.
One minor note, from an OO perspective, a class level property is pretty much global level as every method has access, so these are prefixed with G_
class ZCL_RM_EXCEL_DATA de... |
I'm working on the ui for an application which uses a custom ui control that is loosly related to a treeview.
This treeview has two levels:
Top level which has a number of different geographical regions as well as a 'select all' item
Second level which has a number of countries in those geographical regions
The user... |
Attempting to jump into the Windows Server ServiceBus 1.1 code-base along with adopting the new TPL async methods. But I could not find an easy way to just spin up N number of handlers for message sessions (might have 100 or so concurrent sessions). So it would be great to get some feedback on the following code, any s... |
I am programming with Java (server side) and JavaScript a card game and I do not know how to give properties (on server side) to every card that I create. For a match I need 20 different cards from a complete set of cards (52). Now I want that these 20 cards get a value (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, Ki... |
New to Ruby here. I just made a script that print some metrics from a Windows machine about its disk. The script works fine and as I wanted it to. Now, since I'm new to the ruby and programming world, I'd like to ask you if anyone could help me to make to code look better or if there's other more efficient way I could ... |
Adapt the ideas of printd to write recursive version of itoa; that is, convert integer into a string by calling a recursive routine
Here is the implementation of printd:
void printd(int n) {
if(n < 0)
putchar('-');
if(n / 10)
printd(n / 10);
putchar(n % 10 + '0')l
}
And here is my solutio... |
I've made a small class whose purpose is to generate dynamic HTML. However, it seems that my implementation turned into a state machine algorithm. And so here am I seeking help on a possible design pattern that I may apply, so my code can be more readable, objected oriented and more maintainable.
public interface IView... |
I would really like something to replace all of these REPLACE Statements.
SELECT DISTINCT
CAH.CaseNbr
, REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
(SELECT table1.Degree
FROM SDUJS.dbo.fnWorstDegreeCharge(CB.CaseID) AS table1), 'F1', 'F')
,'F2','F'),... |
I've seen a similar question to this but mine's a little more specific. I have the below
File f = new File("./data.txt");
if(f.isFile())
{
try
{
FileChannel fc = new RandomAccessFile(f,"r").getChannel();
//Get information and return it
}
catch(FileNotFoundException e)
{
Syste... |
This functionality is for a Monopoly board game. In particular, when the player lands on Chance or Community Chest, a random card is drawn with a particular set of instruction, a bonus could be paid out, or perhaps the player is fined. The two cards are different in that one is a set of 16 cards and the other a set of... |
I am writing a function to filter a "dictionary" by the "subject" of its definitions.
The dictionary data structure is a hash-map of this kind:
{ "word1" {:foo :bar
:definitions [{:definition "def1" :subject ["Subject1" "Subject2"]}
{:definition "def2" :subject ["Subject3" "Subject1"... |
I am just now learning Scala a bit on my own time. I wrote some code that works, but was wondering if you could eyeball it to see if its structure can be improved. It is a partial octree implementation.
class octree(min_x:Double,
min_y:Double,
min_z:Double,
max_x:Double,
... |
I want you to give me some tips on what I could have done better and is considered "bad practice". The code works, but I think there are better ways to do stuff, so please let me know.
var Artikel = Backbone.Model.extend({
urlRoot: 'api/items.json',
defaults: {
titel: 'Titel niet opgegeven',
url... |
The following class was designed to help create a more detailed error message than what's provided by the repository when a user tries to insert text into a column that is > the column max length. The users would like to be able to track down exactly which column(s) were the issue. Therefore, I created the following, a... |
I'm writing a list of inputs and outputs for to be compared in unit tests.
var equals = [
//input //output
["name:(John Smith)", "name:(John~ Smith~)" ],
["name:Jon~0.1", "name:Jon~0.1" ],
["Jon",... |
I don't want any feedback on the regexes as I know what needs to be updated here. Also, don't need any feedback on naming conventions.
I'm looking for feedback on the structure and correctness of the class.
/***************************************************************************************************
**SForm - v... |
Looking for feedback on correctness and code structure.
Follow up to:
SStorage (remember) - v0
Note that b.c. the user can only change the storage type when logging in, there is no need to copy back and forth between storage types.
/***************************************************************************************... |
This class creates dynamic input labels. You give it a pair of elements and it sets up the event listeners and CSS toggles to accomplish this.
Looking for feedback on code structure and correctness.
Toggle classes do what they say, they toggle one class on and another class off.
/**************************************... |
I am fairly new to web development, and would like some feedback. It is HTML/CSS, with some JS (button hovers, anchor scrolling and image sliders) from elsewhere. Comments on best practices and any other suggestions would be great as I feel I'm probably doing a lot wrong, but specifically:
I used different-colored con... |
I was doing a simple exercise to calculate the amount based on an expression.
For example:
(((2*2)+(3*5/5)+(2*5))) outputs 17
((2*2)(3*5/5)(2*5)) output 120 etc
I have written the code, but I am not satisfied with what I've done. Could you please help me to review the code and suggest the best approach for that?
import... |
As suggested here, I'm using Boost multi-index to implement orderbook. So far my code looks like this:
"CommonsNative.h" contains typedef int64_t myDecimal; and enum Side { Buy, Sell };
#pragma once
#include "CommonsNative.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <... |
I have a little js I call a "jqGrid Factory" to encapsulate common settings and functionality across my web app.
I just want to see what improvements I can make.
var jqGridReportFactory = (function () {
var config = {
datatype: 'json',
mtype: 'GET',
height: 'auto',
... |
I'm using these 2 functions to handle file input/output and would like to know if there's anything that should be changed.
For content retrieval, enough space is allocated and the file content is copied. To make sure saving a file either saves all or nothing, I'm writing to a buffer then renaming it after all content i... |
I needed to build a one-way web service for a mobile app I developed. Its only goal is to receive incoming JSON data and insert it into the correct tables. It works, but it looks very "kludgy" and cobbled together (happens a lot with solo development).
I'd like another pair of eyes to see where it could be improved as... |
I have a BLAST output file and want to calculate query coverage, appending the query lengths as an additional column to the output. Let's say I have
2 7 15
f=open('file.txt', 'r')
lines=f.readlines()
import re
for line in lines:
new_list=re.split(r'\t+',line.strip())
q_start=new_list[0]
q_end=new_list[1... |
I've written a function that can be used at runtime to suggest how the provided incomplete Lua expression can be completed so that it would make sense (that is, it would evaluate to a non-nil value). For example, this can be used with an application console that can evaluate Lua expressions at runtime, so that it would... |
For a website with four pages (blog, portfolio, profil and impressum) I have four different color schemes (for links, headings, code, etc.). This results in bloated CSS which I want to reduce.
Here is a demo. You see the navigation items use the color scheme of the page it links to. In the demo we're on the blog page ... |
Write a recursive version of the function reverse(s), which reverses the string s in place.
Here is my solution:
void reverse(char a[], int i, int j) {
char tmp;
if(i >= j) {
return;
}
reverse(a, i + 1, j - 1);
tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
This exercise is right after ... |
I'm trying to find maximum the Collatz sequence between 1 and 1000000. I wrote the following code below. I guess it is correct but it is extremely slow. Can you give me a few hints to make it faster?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool myfn(int i, int j) { return i<j; }
... |
I want to implement the cleanest amount of CSS through proper use of inheritance. All links need to be a shade of white, so lets say #fff
HTML
<div class="header">
<div class="headerLogo">
<a href="/">BruxZir</a>
</div>
<div class="headerMenu">
<a href="#">≡</a> <!-- other HTML and JS left out -->
... |
I have the following grid shape:
__ __ __
|__|__|__|
|__|__|__|
I have the following 3 types of shapes to fill it (they cannot rotate):
__
|__| __
|__| |__| (6x6 one above, or full size)
I have also 3 "shape lists" that need to fill it in priority, as in:
ShapeList1 = all types
ShapeList2 = all types
ShapeL... |
This class provides animation messages to the user. Looking for general feedback.
I've posted the library I use as well if you have time to look that over.
/***************************************************************************************************
SMessenger - messaging system to provide feedback to the user
... |
Concerned with the length of this and the organization. Looking to organize it better if possible. If anyone knows the jQuery equivalent of these methods I would like to put them in the comments.
I'm not interested in changing the style, i.e. - identifier names, whitespace, etc.
/*************************************... |
Addressed both issues in this codereview post.
Fixed the indexing issue and the call mechanism of the function expression.
Looking for perfect code. Hope this is the last rev.
/***************************************************************************************************
**ALGORITHMS
*****************... |
After finishing Project Euler 24, I decided to make a scrabble type of application using /usr/lib/dict as my dictionary what I cat that into a word file. It does take a few seconds, and the dictionary selection isn't that great.
Is there any way I could make it faster, more effective, and with a better dictionary sourc... |
I've been iterating on my repository pattern implementation over the course of the past 4-5 months. In my new projects I choose to use this pattern and I try to improve upon what I learned in previous projects. I'm pretty pleased with the state of my current implementation. I feel like I could improve upon my validatio... |
class MyObject
{
public static enum Type {A, B, C, D;}
public static final int ID_MAIN = 1;
public static final int ID_MAIN_UK = 2;
public static final int ID_MAIN_US = 3;
public static final int ID_SUB = 4;
// lots more constants here
public static final String DESCRIPTION_1 = "Desc Full ... |
Given a list, find the longest non-repeating (in other words I mean unique) string in the input list. Looking for code review, pointers on best practices, optimizations etc.
public final class LongestUniqueWord {
/*
* do not initialize this class
*/
private LongestUniqueWord( ) {}
/**
* Re... |
I am reading Cracking the Code Interview and I am getting a bit confused at the bit using 'previous'. In this problem, the method deletes duplicate nodes in a Linked List.
My assumption is that head is used to scan through the linked list while previous is used to update the linked list head because previous points to... |
I've created a simple game, in which the user needs to guess 4 digits number between 0-9, generated randomly using Random() Each of the 4 digits are different from each other, with no repeated digits. The user has 5 attempts to guess, and each failed (almost correct) guess will tell the user in which part they got it ... |
I have a textarea and iframe whose sizes should change dynamically and in reverse directions. I'd like to achive this effect without using a frameset or jQuery plugin. Here's the result of my attempt:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Resize</title>
<style>
textarea,
... |
Project Euler Problem 23 asks:
A perfect number is a number for which the sum of its proper divisors
is exactly equal to the number. For example, the sum of the proper
divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28
is a perfect number.
A number n is called deficient if the sum of its proper... |
I am wondering what a better solution would be for this bit of code:
public static void main( String[] args )
{
String name = "hello, ddd";
boolean[] success = new boolean[ name.length() ];
for( char character: VALID_CHARS ) {
for( int index = 0; index < name.length(); index ++ ) {
if( ... |
Given this kind of code:
public static final int DEFAULT_MASK = Mask.BASE
| Mask.SECTOR
| Mask.GROUP
| Mask.INDUSTRY
| Mask.NAME
| Mask.COUNTRY;
Sonar raises a warning:
Boolean expression complexity is 5 (max allowed is 3).
What would be a good way to deal with this?
I suppose the warning might g... |
When creating objects to be added to a list in Python, we can avoid the if statement by changing our create_object function to return a list.
Is this a good idea or not? Why?
(assume create_object is called in multiple places and is always added to a list)
def _create_object(self, data):
if data:
return Object(da... |
A couple of hours ago I asked a question on Stackoverflow to find out if there is a good way to delete files in a folder only if all files are indeed deletable and I got some good answers that led me (I think) in the right direction
Based on the two currently most upvoted answers I scrambled together the following code... |
See Wikipedia - Multiton Pattern for details on the intent.
Here's the class:
/**
* Holds a thread-safe map of unique create-once items.
*
* Contract:
*
* Only one object will be made for each key presented.
*
* Thread safe.
*
* @param <K>
* @param <V>
*/
public class Multiton<K, V> {
// Map from the ke... |
The first piece of code should cover the standard expected data. But as you can easily see, the data not always conveys to this standard. The code works great but I wonder if this is thought be a miss-use of the try/except clause. Better to go with if/else?
try:
short_name = short_name.upper()
m = (k for k,v ... |
I recently came across code that looked something like this (generates 4 random numbers in an array, this is not the actual code, I just wrote this up now, so it's untested):
var uniqueNumbers = new Array();
var count = 4;
var max = 10;
function main() {
for (var i = 0; i < count; i++) {
do {
... |
I'm looking for suggestions on how to select properties on the child level or deeper dynamically.
For example, here is the method that I am currently using. The method parameters is the object and either a string or array for the property name. If a string is passed used, it will just will get the property. The arra... |
This is my program code for comparing if 2 images are the same. It basically uses the open dialog and opens 1 image at a time and puts it in 1 picture box.
I heard that GetPixel() method may be slow. Is there a more efficient and faster way to compare 2 if 2 images are the same?
Bitmap image1 = null;
Bitmap image2 = n... |
I am creating an API for consumption by other developers to interface with an internal framework. My goal is to be able to have the developers type something like:
profile.setPreference(new GroupPreference(id));
or
UserPreference preference = new UserPreference();
preference.setDefaultInbox("nameOfInbox");
// set any... |
I'm writing a PHP tutorial and I would like to display some forms where the users could enter values that are displayed in the same webpage, just as a demonstration.
The forms do nothing special, they only use print instructions to display the input.
I would like to know if these apparently innofensive forms could be... |
I'm showing and hiding 4 svg paths based on the value of a slider, all is working as expected, but it still feels a little cumbersome. Does anyone know a way to "DRY" it out a little more?
jsFiddle
$('.volumeSlider').slider({
value: 1,
orientation: "vertical",
range: "min",
max: 1,
step: 0.05,
a... |
I am trying to learn to create controllers for my own HTML5 audio tags, which I often have several of on the same page. The js.jQuery code below is a simple beginning to this; it works to apply a play/pause button to each corresponding audio tag with a class of my_audio.
I'm a new coder though, so I imagine there are ... |
I need to write a bit of code that will get a list of the RGB colours in an image and then translate them into a NumPy array of lab colours. I have managed to do this, but I would like to learn how I can do it more efficiently.
from skimage.color import rgb2lab
from skimage.io import imread
import numpy as np
from PIL... |
Class To Test
Some methods hidden for clarity
namespace RiPS.Infrastructure.UA
{
public class UAWorkflowManager
{
private readonly IContextIOAPI _api;
private readonly IUAjoinedRepo _dbJoinedRepo;
private readonly IRemindersSystem _remindersSystem;
public UAWorkflowManager(ICon... |
This is how I handle this situation right now:
For example, I have service that returns UserDto by user ID: GetUserById.
Service never returns null or throws exceptions.
Service always returns DTO objects derived from the base class (DtoBase).
Each DTO object relates to some Entity type. Each entity has an assigned I... |
I wanted to try out writing an minimalistic connection pool implementation (out of curiosity and for learning). Could you all please review the code and provide feedback?
There are two classes (class names are hyperlinked to code):
com.amitcodes.dbcp.ConnectionPool: The connection pool implementation
com.amitcodes.d... |
I've been working on a version of Conway's Game of Life for about a week now. It has loads of features like drawing onto the screen and saving/loading images. The problem is that ever since I added mouse support, it seems to start running pretty slowly. I don't know if it is due to the mouse or if it's something else... |
For some reporting, I need to print a human readable date string for the week covered by the report, using just the standard python module library. So the strings should look like:
Dec 29, 2013 - Jan 4, 2014
Jan 26 - Feb 1, 2014
Jan 19 - 25, 2014
Below is a script I threw together to achieve this. But is there a si... |
Here is my functional approach to split a list into sub lists, each having non-decreasing numbers, so the input
\$[1; 2; 3; 2; 4; 1; 5;]\$
computes to
\$[[1; 2; 3]; [2; 4]; [1; 5]]\$
The code works, but I need a while to understand it. I would prefer a solution that is more clear. Is there a way to make this more el... |
EDIT: Here's my totally-revised PHP...
$text = preg_replace("~[^ a-z0-9'-]~"," ",strtolower($INPUT));
for($i=1;$i<strlen($text)-1;$i++) {
if(preg_match("~['-]~",$text[$i]) && ( !preg_match("~[a-z0-9]~",$text[$i-1]) || !preg_match("~[a-z0-9]~",$text[$i+1])) ){
$text[$i] = " ";
}
}
while( preg_match ("~ ... |
Is this an OK way to handle access to database connection both inside and outside of classes?
I used to include a PHP file -- database.detl.php -- at the very top of my index.php file containing the following code:
try{
$dbh_options = array(/*...*/);
$dbh = new PDO('mysql:host=localhost;dbname='.db_name.';chars... |
The problem: I want to find the word in a string that has the most repeats of a single letter, each letter is independent. Does not need to be consecutive.
Currently I am jumping each character and checking, which doesn't seem very efficient. Do you have any ideas that might improve the number of processes that are req... |
Please review the code quality of this JavaScript Quiz App.
Code improvement tips and simplify are welcome.
Demo - http://jsbin.com/eRiSUhIB/1/
var quiz = [{
"question": "What is the full form of IP?",
"choices": ["Internet Provider", "Internet Port", "Internet Protocol"],
"correct": "Internet Protocol"
}, {
"... |
The form updates a spreadsheet with agents (employees) hours worked for a specific date. The form has 4 pages, a first page where the date and office is picked. After which the form continues to one of 3 pages which has the agent names for their particular office, and a field to enter hours.
The form submission columns... |
I have a question about the Repository pattern:
public abstract class RepositoryBase<T> : IDisposable, IRepository<T> where T : class, IEntity
{
/// <summary>
/// For iterations using LINQ extension methods on the IQueryable and IEnumerable interfaces
/// it is required that the context whic... |
I have another issue: I'm trying to handle connections made by local socket along with data from serial port. Here is my concept:
Serial port is opened and monitored by select
Local socket is opened and put in Listen state
inside loop I call my function accept_connection periodically
When new connection arrives I all... |
I have some VB code that connects to a MySQL database to update every control on every page of a form in our database.
I am told this is taking longer than it should to run. The 'Setup MySql connection' comment is where it starts. I am wondering if there are any obvious optimisation tricks I am missing here, or whether... |
I have some Node/Express.js controllers which implement the exports.method Node module convention. This particular controller also has a few helper methods. The code works fine!
However, I'm a stickler for conventions, best practices etc. and recently I've been going back over one of my project with jshint (Sublime... |
Below is code that will compile when INT_MAX is equal to 232. It will generate a compiler error when INT_MAX is not equal to 232.
#include <iostream>
#include <climits>
namespace NBitCheck
{
template<bool> struct CTAssert;
template<> struct CTAssert<true> {};
constexpr bool intbitwidthcheck=INT_MAX-(2^32)... |
I've started learning F# and functional programming in general, but the code I wrote doesn't seems to be really functional. Could you take a look and say how to make it more as it should be in functional programming?
type internal CsvReader(source : Stream) =
// input stream
let stream = source
// reader... |
This is a chat using Node.js, socket.io and MongoDB for storage.
I'd appreciate any feedback on what can be improved. I understand that this allows for non-unique usernames to be used, and it's currently a JavaScript prompt, however this is simply a demonstration for entering a username to test the functionality.
index... |
I have this function:
int sort(book *data, int books, char mode, char sortBy) {
int i, j;
book aux;
aux.cat = malloc(sizeof *(aux.cat));
if(sortBy == 'n') {
for(i = 0; i < books; i++) {
for(j = i; j < books; j++) {
if(mode == 'a') {
if(strcmp((data + i)->fname, (data + j)->fname) >... |
I'm wondering if anyone would like to give me some solid advice on how to better organize my main.js file. I have a hunch that I should probably break the file into multiple files and decrease the amount of global variables. Maybe my naming is not so great either? I'm using codekit so I can prepend if that won't screw ... |
I'm basically redoing a piece of reactive C# code posted in SO code in F#, please, see below. The translation is fairly literal, I've just written the infinite loop as a recursive function and rearranged the conditions for breaking the recursion. Any notes regarding style and so forth, even the most subjective ones, ar... |
I want to learn how to write clean code from the start. This is my first project, a 'Minimum Viable Product' implementation of Conway's Game of Life in C#. Mostly I want to know if my code is readable, clean, understandable, etc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Syste... |
As part of a fun project to help build my knowledge of PHP. I've written a Data Access Class here to bridge the site to the database. I know there are a lot of posts and articles out there explaining this type of thing, but I needed some individual feedback from people.
It does work, but I'm open to all sorts of respon... |
I'm trying to come up with an alternative to the gmean implementation in scipy, because it is awkwardly slow. To that end I've been looking into alternate calculation methods and implementing them in numpy. My only issue is that a method that in the two methods I'm implementing, the one that I feel ought to be faster i... |
I have a local database in Windows Phone 8 app. The app includes a lot of queries to the database and I don't want bad effect on the responsiveness of UI.
For example I have a table of users and method to get a user from database by id.
Current variant
public class CacheDataContext : DataContext
{
public static st... |
Having so many loops running concurrently obviously can't be good, and the code seems overly complicated. There has to be a simpler, more efficient way to
Turn the designMode of all iFrames on
Find the three "buttons" ('a' link elements) - that when clicked affect its corresponding iFrame - depending on its className
... |
Can someone look over this? This is the entire authentication file. It's referenced at the beginning of all my catalog editing files to make sure only the specified user is logged in. I want to make sure it's secure.
<?php
// pageauth.php
// Asks for a username and a password and checks it.
if($_SESSION['... |
I am working on a project in which I need to have synchronous and asynchronous methods of my Java client. Some customer will call synchronously and some customer will call asynchronously, depending on their requirement.
Here is my Java client which has synchronous and asynchronous methods:
public class TestingClient im... |
I am working on a project in which I am making a call to one of my servers using RestTemplate which is running a RESTful service and getting the response back from them.
The response that I will be getting from my server can be either of these error responses (that's all I have for error response) if something has gon... |
I'm trying to get started with network and parallel programming in C#. I'm almost a complete novice in programming, so I'm looking for feedback on a small script I'm writing.
The goal of the programming is to:
Accept incoming connections and store them as users which are sent into Rooms. Users are expected to provide... |
Problem: Concat all sub-arrays of a given array.
Example input: [[0, 1], [2, 3], [4, 5]]
Example output: [0, 1, 2, 3, 4, 5]
Solution A: Use a loop
var flattened=[];
for (var i=0; i<input.length; ++i) {
var current = input[i];
for (var j=0; j<current.length; ++j)
flattened.push(current[j]);
}
Solution ... |
This is my first attempt a for git command I can use to push the latest commit and email the diff. Story behind how it came up: http://goo.gl/3NEHvn
Revision 1 (Scroll down for 2nd Revision)
import argparse
import subprocess
import os
import re
import send
import sys
class INVALIDEMAIL(Exception):
pass
def main(... |
I am writing a method to synchronize the local Core Data entities with a remote web service (in this case, Parse.com).
To update changed or created objects, I fetch all where the updatedAt date property is larger than the last local sync date. So far, so good.
But I am struggling with the deletion of local objects that... |
I have a (control engineering) controller. These controllers usually need several parameters to do their thing, and in my application it is desirable that these parameters can be changed while the controller is running - in a thread safe and well defined manner.
I came up with this design (extremely simplified):
// Thi... |
What's the best way to format a number?
If decimal is less than 2 digits, add zero to make it 2 decimals
If more than 4, truncate to 4 decimals
If 3 decimals, keep it to 3 decimals
14 => 14.00
14.1 => 14.10
14.123 => 14.123
14.12347 => 14.1234
I don't want rounding to happen
if (number !== 0) {
nParts = number.t... |
I keep running into the same pattern with code using promises in javascript.
When writing a function which takes a promise and returns a promise, obviously I want to reject the promise I'm returning when the promise I received is rejected (and usually I want to pass the error down the chain verbatim). This results in ... |
In his Clean Code book, Robert C. Martin states that functions should do only one thing and one should not mix different levels of abstraction. So I started wondering whether the code below meets these requirements (I assume the answer is negative). Which one of the following code snippets is better?
Snippet 1
public v... |
I have a repository class that impliments a repository Interface.
In my Controllers I want a way to access the repository without creating constructors each time in the controller. So now all my Controllers have to do is inherit from Base. Any pitfalls to this, or how I can write it differently.
public class BaseContro... |
I've made an attempt at writing class wrappers around basic OpenGL objects to make managing them easier and more intuitive. Writing a generic one for program uniforms proved to require a little bit more effort than the other objects, due to there being different OpenGL functions for manipulating uniforms of different t... |
I'm looking for bugs, ways to make it more portable or standardized, improvements of any kind. Seems to do what it is supposed to on my Ubuntu 12.04 PC.
/* VLC-Watchdog v2
*
* A fix for stopped VLC Media Player inhibiting the power management
* daemon and preventing screen saver and/or monitor power off.
*
* Take... |
I am currently working on a small website for my scuba diving club, and it needs a "simple" login system to allow members-only features etc.
I've been using the php-login-minimal as the base for the PHP login: https://github.com/panique/php-login-minimal
It works by creating a session cookie if a user is logged in. Thi... |
This algorithm is supposed to organize and visually duplicate images. I compare 2 images at a time; 1 is the first index image of the directory and another for comparing every other image in the directory. If there are duplicates of the first index image, all of the duplicates will be moved to a new folder that is name... |
This function is intended to remove leading and trailing whitespace from a string. How can it be made more efficient? For example, can the two for loops be combined into one?
string trim(string str)
{
int i = 0;
for (char c : str)
{
if (!isspace(c))
break;
i++;
}
string... |
I'm working on an algorithm to determine if a std::string has all of the same character. Here is what I have:
bool string_has_all_of_the_same_chars(const std::string& s) {
return std::all_of(s.begin(), s.end(), [&s](char ch) { return ch == s[0]; });
}
Are there any improvements that can be made to this? I am guara... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.