0
votes
0answers
10 views

Google Spreadsheet Script - Looping through selected cells to indent text [on hold]

I have written the following Google Spreadsheet script that attempts to loop through all selected cells and then update the value so that it adds an indent, by adding =CONCAT(REPT( CHAR( 160 ), 5),"' ...
2
votes
0answers
10 views

Lots of repeating code, trouble refactoring

I'm looking for a design pattern or suggestions that can help refactor my code into something a bit less repetitive. I have a method that has several sequential steps (10-15) that if any of them fail ...
1
vote
1answer
14 views

All permutations of the pairs that add to squares

Given a number, this program would find "all permutations of the pairs that add to squares" from 1 to number. Eg: Given input a number 16, one of the possible answers would be: ...
1
vote
0answers
7 views

ListView-row Controller?

In most examples ListView routine is pretty simple: Adapter keeps a list of models In getView() method, it binds model's property to row's subviews There's no controller-object which is binding ...
1
vote
0answers
10 views

Writing a JTable to a tab delimited file

I have wrote this class that will write JTable to a tab delimited file so that it can be opened in Excel. It works great but is there any way to make it better or is there a way to have it directly ...
0
votes
0answers
16 views

Sorting comments into a multidimensional array using recursion PHP [on hold]

I fetch my commments using MYSQL, with the format comment_id, parent_id, group_id, message Where the parent_id can be empty if the comment is a 1st level comment. I store my nested comments, i.e ...
0
votes
0answers
10 views

Nasty CBuilder autogenerated code [on hold]

I'm using C++ builder XE2. If I create a new VCL Forms application. It creates the following function for main. WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { try { ...
1
vote
1answer
29 views

Partial sums of two dimensional array

I recieve a number n and then recieve n*n integers, representing a matrix, or an array of [n][n]. I want to create an array [n][n], where every cell contains the sum of all cells "left and above" from ...
5
votes
1answer
36 views

Orchard Partitioning in to close-to-equal sectors

The task (from this site) is to create a program that will solve a problem where a matrix (size n * n), which contains integers, is to be divided into four parts, the sums of which are as close to ...
1
vote
1answer
27 views

Performance issue of LFU-like web caching replacement algorithm

I have implemented a simulation program that runs LRU and another web caching algorithm called Sliding Window LFU. I want to compare them both in terms of the hit rate and their run time. SW-LFU works ...
2
votes
1answer
29 views

Async Queue Processing

I have a Queue that needs to try to process when anything updates in it (add, remove or update). However, I don't want any of the callers to wait while the processing is happening (either for the ...
4
votes
0answers
45 views

Calculate min, max, average, and variance on a large dataset

I got a piece of Java code using Hadoop to calculate min, max, average and variance on a large dataset made of (index value) couples separated by a newline: 0 11839923.64831265 1 5710431.90800272 ...
7
votes
1answer
71 views

Requesting Resources Until Exhaustion

When an API has a 'next' feature, I use the following pattern to obtain all the results: /** Obtains a list of channels followed by a user */ function get_follows(username, callback) { var ...
4
votes
1answer
29 views

Improve performance of Gaussian kernel function evaluation

I need to improve the performance of a function that calculates the integral of a two-dimensional kernel density estimate (obtained using the function stats.gaussian_kde) where the domain of ...
6
votes
1answer
41 views

Highlight countries based on category

In the below code I should highlight countries on the map based on the category of the country in which there are 2 different type of countries (issuing office and selected countries). Based on the ...
2
votes
1answer
38 views

How to generate balls and box combinations depending on rule set I have?

I am working on a project in which I have three box (as of now) and each box will have some color of balls So I am storing the input in a Map of String and List of String as shown below. ...
8
votes
2answers
196 views

Customised Java UTF-8

I have implemented a customized UTF-8 encoding mechanism. The code works fine, but I have a lot of concerns regarding the code. public class Utf8Encoding { public static void main(String[] args) ...
1
vote
2answers
32 views

Reusing objects using a Generic Object Pool

After reading a lot of documents, I wrote this object pooling code. Can anyone help me to improve this code.? I am lagging in validating the object, confirming whether I can reuse it or not? If ...
0
votes
0answers
20 views

Timer Manager for socket programming [on hold]

I am trying to write a class as Timermanager for managing tasks based on time intervals under socket communication, for eg: when a client request for a service from the server and if the client doesnt ...
3
votes
1answer
54 views

How do I extract interfaces from existing similar classes?

I have about 11 singleton-esque classes divided over a dozen files: the first file is one that gathers all singleton definitions and makes them callable on a request scope: public sealed partial ...
0
votes
2answers
30 views

Build a local cache of all streams from Twitch.TV API

I am trying to cache the entirety of streams from Twitch.TV public API with the following code. It is successful but takes almost a full minute to execute so I am wondering if it's my code or just the ...
2
votes
2answers
40 views

Dependency on overridden method

In my code I have a base type which is OnlinePaymentTransaction: public abstract class OnlinePaymentTransaction { public abstract void Complete( PaymentGatewayCallbackArgs args ); } The ...
2
votes
0answers
12 views

Product grid for a online catalog

I have this portion of code and I would like to know if I did it right, what changes could be done to optimize and make it better, and if I used the all the tags the right way. For the moment, the ...
0
votes
0answers
13 views

level traverse a binary tree [on hold]

Level traverse binary tree question The problem is pretty common level order traverse a binary tree but break each level into single array. I implemented mine: I've designed a few test cases, but ...
2
votes
1answer
56 views

Speedup cython dictionary counter

I wrote a simple cython script to optimize the collections.Counter of a dictionary counter and the python zip implementation (the main input is a list of tuples). Is there a way to speed it up? ...
2
votes
2answers
29 views

Elegant way of making a List of an attribute from a list of objects containing that attribute

If this is my class: class Something { UUID id; // Other members } Given a List<Something> things and I want to get a List<UUID> ids, this is what I usually do: ...
0
votes
0answers
5 views

Suggest a best practice to create Constants class [migrated]

There is a debate in between my team members about declaration of Constants class. We are moving the constant variables into separate class as like below public class Contants { public const ...
2
votes
0answers
31 views

Listen to multiple RabbitMQ queue by task and process the message

Single app which listen to multiple RabbitMQ queue and process the message. This is working fine but not sure this implementation is right one or I am missing something. Implementation is inspired ...
7
votes
2answers
169 views

Int stack implementation

#include <stdio.h> #include <stdlib.h> struct Stack { int value; int is_empty; struct Stack *next; }; int pop(struct Stack **stack) { if ((*stack)->is_empty == 1) { ...
3
votes
1answer
26 views

Using jquery Callbacks.fire method as a event handler

So I've got a jquery project where I'm using an external class that has callback style events. Meaning, it has an "onSave" property that takes one function. However, I need to more than one other ...
6
votes
2answers
263 views

Pong game written in C++ and using SDL 2.0

I've just finished writing my first game. It's a clone of the classic pong game for Linux and Mac only. You will need SDL 2.0, SDL_ttf 2.0 and SDL_Mixer 2.0 to compile it. The complete project can be ...
9
votes
5answers
333 views

Direction enum class

As request of Simon's comment: Direction.java package net.woopa.dungeon.datatypes; import java.util.Random; public enum Direction { NORTH, EAST, SOUTH, WEST; private static Random rnd = ...
1
vote
1answer
71 views

How to turn 201 queries into 1? [on hold]

I have a PHP web app that manages contacts. It has four main functions that display: contacts with upcoming birthdays; the 20 most viewed contacts; all contacts (200 limit) plus their phone number ...
5
votes
1answer
52 views

A non-blocking lock decorator in Python

I needed to impose on a Python method the following locking semantics: the method can only be run by one thread at a time. If thread B tries to run the method while it is already being run by thread ...
2
votes
0answers
23 views

Code to write data to Excel

I have a need to read properties from soapUI using groovy and writing them to Excel. I initially had a problem with writing to Excel, but I was able to solve that. Now I want to know if my solution is ...
11
votes
5answers
3k views

Why is my C# program slower than my Python program?

I made a program on python, and wanted it to be faster, so I wrote it on C#, because it's compiled. To my surprise, the python program is much faster. I guess there is something wrong with my C# code, ...
9
votes
2answers
184 views

Factorizing integers

I'm working on this method in Java, which is giving me the factors of a number. I'll be using this method a lot, and I was wondering if there isn't a better way of doing it. Like, with just one loop. ...
0
votes
0answers
23 views

RESTful client with Java using Apache HttpClient [on hold]

I would like to implement an independent class to communicate with a RESTful resource, using Java. The parsing of the InputStream into JSON will occur outside of this class by a different entity. ...
5
votes
3answers
295 views

WHERE NOT IN SQL Performance

SELECT TOP 1 l.ID FROM Leads l WHERE l.ID NOT IN (SELECT LeadID FROM LeadFollowups) AND l.ID NOT IN (SELECT LeadID FROM LeadsWorking) AND l.ID NOT IN (SELECT LeadID FROM LeadsDead) ...
5
votes
2answers
56 views

Cash Register Kata

The Setup This kata is a spin on the old backpack problem. Please give feedback on both the kata itself as well as my solution. I'm not sure if the kata needs to lead the student more or if this is a ...
2
votes
2answers
211 views

Singleton design pattern

I am a beginner in PHP-OOP and design patterns. I have got this basic piece of code in Singleton Pattern and I changed it in order to understand its behavior. I can see that it works as expected. ...
2
votes
2answers
26 views

Improving and shortening code for select validation

Is there any way to make that code shorter? I still want to use jQuery. I don't want to use any validation script. $("#form").submit(function (e) { var tmp = $('#select-1').val(); var tmp1 = ...
4
votes
2answers
53 views

How to chain exceptions?

I have some function like: void foo() { ... } int main() { ... try { ... foo(); ... } catch (const std::exception &e) { std::cout << "Fatal error: e.what() << ...
3
votes
1answer
35 views

Check for similar value with SQL

I've two table (t1 and t2) with 3 identical integer columns : c1, c2 and c3. I want to count how many value in t1 are in t2 So I start to write : SELECT count(t1.value) FROM t1 INNER JOIN t2 ON ( ...
3
votes
1answer
23 views

“Histogram of Oriented Gradients” (HOG) feature detector for Computer Vision: trying to optimize for speed

Below is a function that I've only slightly modified from it's original context, found here. Before mentioning anything else, it should be noted that I'm desperately trying to optimize this code for ...
0
votes
0answers
16 views

UVa 102 - Ecology Bin Packing -> Wrong Answer [on hold]

This is C++11 code. Trivial answer and a comedian "wrong answer" from UVA. #include <iostream> #include <string> #include <vector> const short block = 3; const short BGC = 3; ...
5
votes
2answers
198 views

QuickSort of Comparable[]

Here is the code for the QuickSort class that I created. public class QuickSort { public static void sort(Comparable[] a) { quicksort(a, 0, a.length-1); } ...
5
votes
1answer
52 views

Variadic templates and pointers to member functions to achieve a named-parameters interface in C++

I studied a bit and packed all the suggestions that I received here: Fluent interface and polymorphism and I came up with this: #include <iostream> #include <cmath> #include ...
4
votes
2answers
94 views

API for Dungeon Generator

I am writing a ASCII dungeon creator inspired from games such as Angband, Moria etc. The main goal of the project is to allow a user to come along and implement their own "DungeonLevelGenerator" so ...
3
votes
2answers
62 views

Project Euler “Largest product in a grid” (#11) in Java 8

I have come up with a Java 8 solution for the following problem: In the 20×20 grid below, four numbers along a diagonal line have been marked in red (bold here). 08 02 22 97 38 15 00 40 00 75 ...

15 30 50 per page