All Questions
0
votes
0answers
5 views
Calculate work progress in percentage of batches that contain tasks and task contain sub tasks
I was being referred to here from stackoverflow.
I am trying to calculate work progress in percentage. I have multiple batches, and each batch contains a set of tasks and each task also contains a ...
0
votes
0answers
6 views
Collision System in Pong-like game - How good is this code? (Blitzmax)
I am writing a game like Pong. Therefor I am using an entity system approach, so I use component based design.
The hardest part until now was to write the collision system. As I just began with the ...
1
vote
1answer
11 views
More Elegant Solution to Logging Class
I got this class in C# which works fine. But I was wondering if there was a more elegant solution to what I am trying to do. It looks rather clumsy and inefficient for a Logging functionality.
The ...
1
vote
1answer
6 views
Sleepsort in Go
I implemented sleepsort in Go. I am new to channels, and I'd like to get some advice on them, especially on how to close channels after N messages have been sent on them. Currently I use a counter and ...
1
vote
1answer
13 views
Asp.net MVC4, Lamba Sorting
I have the List method that takes sorting parameter to sort result. and the sorting parameter value is same to column name. And this is my code,
public ActionResult List(string sorting = "Name", ...
0
votes
0answers
11 views
MySQL vs PDO execution time
I'm having some issues understanding why PDO is 6X slower executing a query than the depreciated MySQL query function. Here's my code:
$conn = new PDO('mysql:host=localhost;dbname=work', 'root', ...
2
votes
0answers
29 views
Looking for a better solution to my OO code
I would like if this could be kept to a post providing concrete examples of how I could solve my problem better, and not about which one would be "best" as such :) I would simply love some insight to ...
0
votes
1answer
12 views
Need to clean up my code and add the ability to resize the image
I have the following code:
<?php
include '../../inc/config.php';
$size = isset($_REQUEST['size']) ? $_REQUEST['size'] : 'full';
$image = isset($_REQUEST['image']) ? $_REQUEST['image'] : FALSE;
...
0
votes
0answers
9 views
Type conversion from FORTRAN to C#
I have in F2008
module mod_Blood
use mod_liquid
implicit none
type, public :: typ_BloodComponents
character(len=5) :: name
real(DP):: salt
real(DP):: RBC
end type typ_BloodComponents
...
1
vote
1answer
28 views
Ruby multiples of 3 and 5 code challenge
I have implemented the first coding challenge on http://projecteuler.net/. I would love to get it reviewed by some expert rubyists! Thanks in advance :)
# Multiples of 3 and 5
#
# If we list all of ...
2
votes
2answers
37 views
Extension methods for class Type
While working on one of my projects I actively used Reflection. While working with class Type I expected methods: TryGetMember, TryGetProperty, TryGetField, TryGetMethod. I've implemented them as ...
3
votes
1answer
39 views
Is the following code well written?
The following program is supposed to return the length of a 'hidden' string within each of the sentences of another string, using pointers and avoiding as much as possible the use of [] as a means to ...
0
votes
1answer
34 views
Class design question
i have Winform application and i want to separate the button click event from the main form.
my application has Add button who add files into my Listbox and until now all my code was inside this ...
2
votes
1answer
19 views
tree heap Haskell code
I'd like a review of Haskell tree heap code in Turning a tree into a heap in Haskell.
module Heapify where
data Tree a = Leaf a | Node (Tree a) a (Tree a)
deriving Show
ourTree = Node (Node ...
0
votes
1answer
14 views
Showing jQuery UI tooltip on focus of text box
Firstly, here's a link to the fiddle.
Basically my situation is that there is a requirement to show tooltips on textboxes on some forms being created for a website to allow employees to update their ...
2
votes
1answer
44 views
C++ Linked List: Would This Code be Considered Clean If written in an Hour Long Interview
If you were interviewing me, and saw this code written in a little under an hour would you consider me as a candidate for a position at your company if you knew I had 2 years of C++ experience.
...
2
votes
1answer
23 views
Better code for converting a char to its UTF-8 percent encoding representation?
This is working code for a URI template (RFC 6570) implementation; when the character to render is not within a specific character set, it is needed to grab the UTF-8 representation of that character ...
1
vote
1answer
32 views
SQL Query efficiency within class
I'm trying to figure out whether I should do the following:
This class (over-simplified version) retrieves information about an order by having 1 main query function that select a specific column ...
2
votes
1answer
23 views
PID Controller library
I'm trying to implement a PID without floating point operations on a micro controller. I appreciate all feedback I can get.
Header file:
#ifndef BRUSHPID_H
#define BRUSHPID_H
#if defined(ARDUINO) ...
0
votes
0answers
18 views
Read BER-encoded data in C#?
I've asked this in StackOverflow and got a nice advice by Chris Latta on asking here because, well, someone called Lex Li closed my question: ...
-1
votes
0answers
21 views
How is it called when what goes first in &&-condition(java) matters a lot? [closed]
I have discovered that if accessing some index from array/string happens first in IF clause, it can crash (out of bounds exception)
However, if i check index first and then try to access it, if index ...
1
vote
0answers
18 views
Is this a correct recursive Scala iterator creation?
I am diving into scala (using 2.10) headfirst and am trying out a simple task of taking bulk data and then doing something with that stream. The first part is generating that stream. I have seem to be ...
1
vote
1answer
33 views
Anyone have some ideas about my code?
I have this class that pulls people out of a database. I want it to be a little prettier and function better. Anone got ideas? Feel free to ask questions :)
<?php
class comps extends db_config {
...
1
vote
0answers
43 views
What is this structure called?
So I've been writing this data structure for a few days, and now I'm really curious about what it actually is, and to get some critique on my logic.
A branch, based on this usage, exists when a HEAD ...
2
votes
1answer
70 views
Trying to get better at Ruby and programming in general- here's a simple TopCoder question in Ruby
I want to get general feedback and feedback about if I can make this more Ruby-like, if there are any obvious inefficiencies, and if I need to organize my class differently. The topcoder question is ...
-1
votes
0answers
6 views
my colour change through keyboard and mouse is not working properly.how to retain the colour even after i release the pressed key? [closed]
#include <stdio.h>
#include <stdlib.h>
#include <glut.h>
float _angle = 30.0f,xt=1.0f;
float zt = 1.0f;
float _cameraAngle = 0.0f, _angle1=30.0f;
//char key;
//int flag=2;
//float ...
0
votes
1answer
36 views
How to make this function reusable instead of repeating it? [closed]
I'm using JavaScript and JQuery 1.8.3 to rebuild a form built by Django-filter. My purpose is to only present options that will yield a result to the user. The Django stuff all works fine and this is ...
0
votes
0answers
8 views
Multi threaded API calls problem
I have this API to control some hardware. The API is not very well documented, but I've been able to make do with what I have. It is a API for a RFID device, but also has LED's on it that are ...
-2
votes
0answers
19 views
Jquery File Upload (blueimp/jQuery-File-Upload) - ASP.NET MVC - How to Cancel Upload Async [closed]
created this in my github repository where I have the code of JqueryFileUploadblueimp implemented with ASP.NET MVC. Need some help about it, because I would like to know how can I cancel an UPLOAD ...
0
votes
0answers
17 views
Why does my third column line-break?
How do I make the three columns I have on different lines parallel to each other?
jsFiddle:
http://jsfiddle.net/JordanSimps/n79LY/2/
HTML:
<div id="middle_container">
<div ...
0
votes
0answers
22 views
Is there a better way to count seconds in python
def stopWatchSeconds(secondCnt) :
""" counts second for secondCnt seconds """
# is there a better way to do this?
startTime = time.clock()
ellapsed = 0
for x in range(0, ...
2
votes
1answer
27 views
Two dimensional unit testing
Consider a process composed of three algorithms: makeRuns, meld and traverse (each taking the output of the previous one as input): it is interesting to test each separately. Now consider three (or ...
1
vote
1answer
19 views
Clean up Rails Routes
Is there any way I can DRY up this Rails 4 routes.rb code?
match '/oauth/apps/' => 'oauth/applications#index', :as => :oauth_applications, :via => :get
match '/oauth/apps/new/' => ...
0
votes
0answers
14 views
Extract equally from X queues to one queue with Y elements
I need to implement a system of queueing that extracts elements equally from x queues to one single queue with y positions.
Let's say I have 5 queues, each with a number of elements and I need to ...
0
votes
1answer
30 views
Concatenating wide character strings
I just wrote this code to concatenate two wide characters
strings. Could someone please comment if it looks OK? (seems
to work at least).
1. SomeStringClass amount = Window->get_text();
2. wchar_t ...
1
vote
1answer
42 views
Better way to hide, change and show DIVs in Javascript
I made this Javascript to hide, show and change some DIVs but I believe it's not really good code. Can you help me to make it better?
function colorM(n) {
switch(n){
case 1:
...
1
vote
2answers
26 views
jQuery sum outerHeight of multiple divs? Can I do this more efficiently?
I am summing the total .outerHeight() of multiple divs like this:
// How can I do this more efficiently?
var h = $('#div1').outerHeight() + $('#div2').outerHeight() + $('#div3').outerHeight() + ...
-1
votes
0answers
18 views
html form not working in google chrome [closed]
I have a login page which accepts username and password and when you press enter then it is taking to home page. This is working perfectly in mozilla firefox and opera but its working at all in ...
0
votes
1answer
25 views
OpenMP parallelization of a for loop with function calls
using OpenMP, is it correct to parallelize a for loop inside a function "func" as follows?
void func(REAL coeff, DATAMPOT *dmp, int a, int la, int b, int lb, REAL L)
{
int i,j,k;
REAL ...
2
votes
1answer
34 views
Need suggestions to improve the code for an open source web based drafting application
My application. The repository and the file that needs review.
Here is the source code
$(function () {
var draft = function (parsed, title) {
var self = this;
var wordCount = ...
2
votes
1answer
29 views
What changes, if any, are required to make the following Perl eval bullet proof?
eval {
# here is put some code that may throw exception
1; # Why is the "1;" here ?
} or do {
my $error = $@;
# Handle error.
};
Does the following style protect against $@ not being ...
2
votes
1answer
37 views
Best way to call future.get()
The following is a small part of some code I am working on
Which is better/faster/nicer?
1.
for (Future<Subscription> future : futures) {
try {
executorService.submit(new ...
2
votes
1answer
35 views
Generic method for database calls
Background
Breaking from MVC, I've implemented the following architecture:
POST/GET ➤ PHP ➤ Database Calls ➤ XML ➤ XSLT ➤ HTML
All database interactions are relegated to the call method in the ...
0
votes
0answers
12 views
Backbone Marionette code improvement 2
What's a better way to implement the code below? As much as possible, lessen the repeated lines:
vent.on("createAccountLayout:rendered", function() {
...
5
votes
0answers
49 views
I've written an aimbot for an open source FPS game. Any suggestions?
The game is Assault Cube. Here is the source code:
/*
Control + 0 = enable aimbot
*/
#include "stdafx.h"
#include <math.h>
const float pi = 3.14159265358979f;
/*
* I am using int* as ...
3
votes
1answer
30 views
Improvement on code
Okay, I'm just a little newbie in programming just doing it for a past time hobby. I am just recently making a web editor for fun and the way I was doing it (Using PHP) I was told would be a bad way. ...
0
votes
0answers
6 views
Correctness Of OpenGL Model View Matrix Algorithms
I am more worried about correctness of formulas than I am about style.
For my view matrix I am basing my formulas from:
http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml
camera_matrix()
For my ...
3
votes
1answer
30 views
Optional argument for which None is a valid value
I have the following function:
def item_by_index(iterable, index, default=Ellipsis):
"""Return the item of <iterable> with the given index.
Can be used even if <iterable> is not ...
0
votes
0answers
50 views
Generic Task Blocking Queue [closed]
A generic blocking queue has the following properties:
It is thread-safe.
It allows queuing and de-queuing of items of a certain type (T).
If a de-queue operation is performed and the ...
2
votes
1answer
28 views
JSON AsyncTask refactoring to improve quality?
I'm new to Android. I was wondering if anyone had any suggestions. It's basically an AsyncTask to get a remote JSON array and put it into a native array.
Would be very grateful for suggestions.
...
