1
vote
0answers
5 views

Which pattern could help to refactor this controller code?

I know I should use services and patterns to refactor this controller action, but I can't imagine one that could fit/be appropriate for this problem. It seems a strategy or template, but a strategy ...
1
vote
0answers
4 views

SMS relay --> MySQL database

The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps: ...
2
votes
0answers
12 views

Creating chat commands properly with Socket.IO

I am developing a chat(mountreus-chat and GitHub) in Node.js using Socket.io however my code looks awful. I'm starting to use commands and now it's even worser. Here's a code snippet (you can find ...
-3
votes
0answers
14 views

How do I remove this bug [on hold]

This program is supposed to perform the sum, difference,multiplication or division of two numbers and return "Invalid operator" if the operator isn't one of these. Here's my code: ...
3
votes
1answer
7 views

Cleaner code for iterables

I am new to Python and am trying to see if there is a cleaner way to write my code. The following code take iterables as parameter it produces the first value from the first parameter, then the first ...
-4
votes
0answers
10 views

Can't spot the error [on hold]

I'm writing a program that displays the lyrics of a nursery rhyme called "This old man". I've been trying to identify the error for a few hours. The error is: 4: [Error] expected initializer before ...
2
votes
0answers
17 views

Efficient use of branch prediction

I am trying to learn how branch optimization works. For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary ...
-1
votes
0answers
7 views

Code for finding longest substring in a given string [on hold]

I know this code is probably too erroneous, but I can't debug it. Can anybody help? ...
1
vote
0answers
12 views

Check secure image upload

I want to upload images to server from browser window. I'm using this function for image upload. Images is uploaded by GD library. What is your opinion of this code? Is there still a way to upload a ...
-1
votes
0answers
12 views

PHP Class over writing OOP [on hold]

I am fetching data from database and then looping it. The problem is that the first class overwrites on my second class, and it disturbs my coding. You can have a look at this code. If you want any ...
1
vote
0answers
17 views

inefficient hash map operation provoke OutOfMemory: Java heap space error

I know I can increase the size of the heap but that seems like a poor solution. This program runs correctly on small files but when run on large data sets it crashes with the OutOfMemory: Java heap ...
2
votes
0answers
14 views

Web service for Android clients to store images

I wrote this code for Android server interaction. The way I built the client was an onSharePreference of strings includes photo encoded to a base64 ...
1
vote
1answer
11 views

Schema.org combining different categories

This is the follow up version of a previous question on combining different categories and their properties. The home page contains the overarching company information. The product page contains ...
2
votes
1answer
37 views

First OOP TicTacToe game

This is my first program using classes. How could this be improved? ...
2
votes
1answer
38 views

Converting array of bytes to the hex string representation

Is it possible to make the hexStr function faster? ...
7
votes
2answers
186 views

Quadratic Calculator

I am about a month into learning Java and I'm just looking for some comments on my code. Specifically, I would like to know if I'm being as efficient as I can be. This is the most complex thing I've ...
0
votes
0answers
18 views

Why does this implementation of Dijkstra's algorithm work in O(n^2)?

Here is the code I use for implementing Dijkstra's algorithm. Consider a graph with n vertices and m edges. Shouldn't it run in O(n^2 m) ? Someone may say that there are n vertices and each edge gets ...
3
votes
2answers
141 views

Efficient way of finding perfect squares

I was trying to solve a problem which needed you to count the number of perfect square in the given range: ...
4
votes
0answers
15 views

Data-checking class supporting letters

I'm starting to learn OOP with PHP, and all I've learned so far is just by searching and reading. So I have this need to check input data for certain things like min of chars, max of chars, spaced or ...
1
vote
0answers
24 views

Finding the number with the greatest number of divisors and lowest value

The program is finding the number with the greatest number of divisors and lowest value. I have been working on it for about 7 hour and it keep saying "Time Limit Exceed", so I'd like to show me how ...
5
votes
1answer
46 views

Popping from a list in state while a condition is true

I'm dealing with data that stores its state as a String, treating the string like a stack. I also have to combine that with error handling. To that end, I'm using ...
5
votes
1answer
32 views

OO Blackjack game design

I have set up card, deck, hand, player, ...
2
votes
1answer
22 views

All-in-one number base converter

I coded this program as a challenge for /r/dailyprogrammer. Basically this program can convert any number from any base to another base including negative bases as long as the input is coherent. Did I ...
2
votes
1answer
40 views

TicTacToe in OOP

I'm trying to learn some OOP programming using Java, so I've created TicTacToe. Could you give me some advice on how I can improve this code? Player.java: ...
3
votes
2answers
159 views

C++ smart pointers and classes

I've started learning C++ recently and want from what I've gathered smart pointers are the way to go when storing stuff on the free store. I want to make sure I've got the basic hang of C++(11) ...
5
votes
2answers
102 views

Slide-Game in Swing

This was done as an assignment in school. As I am still learning some of the basic parts of Java be merciless when it comes to my code. As it is an assignment, some things are unchangeable. The ...
-2
votes
0answers
11 views

Fixing route problems in ruby on rails app [on hold]

I'm a ROR newbie and I've somehow broken the create and edit functionalities within my app. I have individual pages for each artwork I've uploaded, a _form that enables editing of those artworks (and ...
-1
votes
0answers
16 views

How to refactor code that violates the Law of Demeter without too much hassle? [on hold]

I'm facing a little problem regarding a piece of legacy code I'm working with and trying to make it Unit testable. Here's the chunk of it: ...
4
votes
0answers
23 views

Lookup GINI by year and country

This takes a dataframe as an argument, looks at all pairs of two columns in that data frame (country and year) and returns a column value of that pair in another data frame (the gini number). ...
4
votes
1answer
34 views

Get table header name in excel

I'm trying to get table header name in excel. I tried it using index, IF and MATCH. It works ...
8
votes
1answer
75 views

Multiplying corresponding integers using streams

While reviewing Multiplying Lists, I got the impression that the problem was naturally suited to Java 8 streams. Unfortunately, since there is no convenient way to zip two streams, the solution ended ...
3
votes
2answers
65 views

Hacker Rank - Lonely Integer

This is the problem statement for Lonely Integer. There are N integers in an array A. All but one integer occur in pairs. Your task is to find out the number that occurs only once. Input Format ...
-2
votes
0answers
12 views

Merge sort not working [on hold]

Here is my code for merge sort. The merge operation works fine but there is some glitch in the sorting part. ...
3
votes
0answers
25 views

Simulate Random Risk Battle

For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle. ...
4
votes
1answer
34 views

Prepared Statements / MySQLi / PHP Registration/Login Form

I'm just looking for some feedback here. I'm fairly new to MySQLi & PHP, but I've been working at it for a bit now, and reading up on how to make secure login forms, avoid SQL injection etc. I'm a ...
4
votes
1answer
34 views

Multiplying Lists

Challenge: Given 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists Specifications: Your program should accept as its first argument a ...
2
votes
1answer
41 views

Seeking proper system for pairing types

My code below ensures that only land animals can be a "representatives" for Land while only ocean animals can be representatives for ...
4
votes
1answer
38 views

Remove element slice of struct pointers

I have an application with a recent addition that requires the removal of a struct pointer from a slice that is itself an element of another struct. A summary of the usage. I am wondering if this is ...
2
votes
1answer
19 views

geoInput jQuery Plugin

I made my first jQuery plugin, and was hoping to get a review. I'm especially interested in comments on whether I went about building up my html and applying the css in a reasonable manner (I chose to ...
-1
votes
0answers
15 views

How to simplify my conditional statement

I am trying to see if I can simplified some of my codes. It looks messy now. I have something like ...
5
votes
3answers
361 views

Does this Tic-Tac-Toe game follow abstraction and encapsulation?

This below program will be further enhanced for TicTacToe game with Human and Computer as players. Currently this program is written for choosing best move for a ...
2
votes
0answers
14 views

Unit testing a click event with asynchronous content

I'm writing unit tests for a web application that has quite a lot of UI interactions. I would like some feedback regarding on how to handle click events with asynchronous code. My goal here is to ...
-5
votes
0answers
22 views

Why does quot need to be repeatedly subtracted by 1? [on hold]

This question is based off this thread http://stackoverflow.com/questions/763691/programming-riddle-how-might-you-translate-an-excel-column-name-to-a-number Here is code from that question to ...
4
votes
0answers
23 views

Average interval between dates with random blanks

I have a spreadsheet with order date data: I need to find the average interval in days between each order date. I have to both find a way to get past the blank cells in the row, and also take into ...
0
votes
1answer
18 views

Redirecting all pages under a certain directory to a single file

I want to redirect all pages under a certain directory to a single file, like so: /dir/a/dir/new ...
5
votes
0answers
39 views

Reading, writing, and copying files

Originally, I created a program that echoes files or strings to output. This is a modification of that same program and goes a step further. It does work (in both Linux and Windows), but I can NOT ...
3
votes
2answers
161 views

Determining if a pair exists in a large sorted array

I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a ...
1
vote
1answer
40 views

C++ Readable serial constant range counter [on hold]

What I am asking here is about code readablity. Consider the following code: ...
-3
votes
0answers
21 views

Style: python if else in one line [on hold]

I tend to use something like this: result = -1 if some_condition else result I use it very often in a return statement like ...
1
vote
1answer
71 views

Finding Lottery odds - Topcoder #268

I have implemented the question #268 from Topcoder. The question is that there are 4 conditions for a lottery ticket: CHOICES - numbers available (10 ≤ CHOICES ≤ 100) BLANKS - number of numbers that ...

15 30 50 per page