All Questions
77,574
questions
17
votes
2
answers
6k
views
ISBN missing number solver
This is a programming contest question. Question as follows
Problem Definition
An ISBN (International Standard Book Number) is a ten digit code that
uniquely identifies a book. The first 9 ...
9
votes
3
answers
19k
views
Very Basic Java Piano
I've been reading "Head First Java" and some of the early projects surround basic swing and basic MIDI.
So I've put the two together and written a basic "Synthesiser"/"Piano" using what I have ...
-1
votes
1
answer
324
views
LPTHW Ex51 with image upload [closed]
Here's what I ended up with for Learning Python the Hard Way Ex 51 with image upload (save and display).
The form:
...
1
vote
1
answer
2k
views
Convert a doubly linked list into balanced binary search tree in-place
Given a doubly linked list which has data members sorted in ascending
order, construct a balanced binary search tree which has same data
members as the given doubly linked list. The tree must be ...
2
votes
1
answer
91
views
Client-side API design
I'm working on a client-side API for my ASP.net MVC application and I'm not quite sure I've got the code right. This API allows me to call server-side action methods via Ajax and I've designed it to ...
1
vote
1
answer
123
views
jQuery Dialog Settings
The goal of the code is to
initialize a Dialog with settings
make sure the object is reusable
Setup the options to reuse the code
I'm not quite sure if this is overkill, or I am going about this ...
5
votes
3
answers
12k
views
Counting the most frequently appearing character in a string (i.e. the statistical mode)
This is my sample code to find maximum occurrence of characters in string in C#.
How can I make it better?
...
3
votes
2
answers
1k
views
Efficiency of Project Euler 28 - number spiral diagonals
I have written a solution for Problem 28.
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
$$\begin{array}{rrrrr}
\color{red}{...
6
votes
1
answer
64
views
Trying to avoid a double full scan with aggregates in query
I have a statistics query I'm trying to run against the below table:
...
14
votes
2
answers
4k
views
Detecting two intersecting circles with editable x, y, and radius in JavaFX
I was actually pretty proud of this programming project that I came across in this book I'm working through. I only really had problems figuring out the formula for detecting whether or not the two ...
5
votes
1
answer
64
views
I think I should use JOIN but I did this instead
Let me start by saying that I am brand new to PHP and MySQL.
I have two tables. One table is called domains and it contains the "rep" column which is an integer. It is related to the column "id" in ...
6
votes
4
answers
2k
views
Temperature conversion table
This is another solution for this challenge.
Problem statement:
In this challenge, write a program that takes in three arguments, a
start temperature (in Celsius), an end temperature (in Celsius)...
8
votes
1
answer
4k
views
"Function Buffer" to avoid triggering an event handler too frequently
If some big event handler is triggered too frequently, it will cause computer lagging.
In my example $(window).resize(), I want the function to be called after the ...
30
votes
9
answers
58k
views
Check a string to see if it is a palindrome
I have written two code pieces to check if a given string is a palindrome:
...
5
votes
1
answer
309
views
Shopping cart logic for authenticated users and guests
I am tasked with cleaning up someone else's Objective-C code, and will admit it is not my language of choice. I am not sure if this is a valid question but was hoping someone could double check my ...
1
vote
1
answer
2k
views
5
votes
1
answer
108
views
Selecting template from database using organization ids
This is my first SQL post over here, and in fact, I have more or less the experience of a regular SQL programmer, except that the task at hand this time was way harder than normal.
I am expecting, ...
1
vote
2
answers
214
views
Speeding up prime factorization
I have written the following code for returning the list of prime factors. Any speed-enhancing suggestions?
...
1
vote
2
answers
54
views
Filtering data stored using classes via user-called function the proper way?
I'm currently working on an API package. Basically what it does is scrapes team data and stores them in list of Team objects. The team object contains data such as Team.name,rank, country etc.
If a ...
4
votes
2
answers
43k
views
SQL percentage calculation
I have created a query in which there is a column that calculates a percentage:
...
1
vote
1
answer
3k
views
6
votes
2
answers
233
views
Database layer class
I'm trying to get familiar with database handling. Can you point out my errors and what I should change?
I want to learn new methods, but just don't want to learn it the wrong way.
I do realize ...
4
votes
1
answer
9k
views
Batch of SQL statements in a single query
I'm using the following query for multiple transactions. This is the scenario.
Generate Salary (this is not in the scope of the query)
I have employee attendance in ...
3
votes
3
answers
183
views
A simple prompt-and-print program
I have accomplished what I wanted to do but I think this can be done better. I want my code to look professional.
What my code does is ask for your name and gives output in below form.
Input: Jack
...
8
votes
1
answer
197
views
Honey I shrunk the view
Going down the rabbit hole, I wanted to be able to change the size of a form, and not have to worry about the layout of the controls.
vba doesn't support user-resizeable forms, but forms still have a ...
19
votes
2
answers
4k
views
Down the rabbit hole with MVP
Following-up on this post where I implemented a Repository Pattern in vba to abstract ADODB and enable testing my Excel app without hitting a database backend; curious about how far vba would let me ...
1
vote
1
answer
192
views
Java service layer code cleanup
I have the block of code from my project service layer and I'm not happy with it. It seems overly complex and I would hate to have to calculate the cyclomatic complexity. This block is called in ...
0
votes
4
answers
5k
views
Selection sorting an int array
I'd like to improve this selection sort code
...
2
votes
1
answer
2k
views
Refactoring Android fragments
I have an Android app that shows some fragments, but I'm repeating lots of code.
MainActivity.java
...
3
votes
1
answer
4k
views
Using dapper.net and repository pattern in Azure websites
I'm currently on Azure Websites & Azure SQL, some documentation recommends using Async as much as possible as cloud services higher latency and have chances of dropping traffic, but it's also ...
3
votes
1
answer
126
views
Web page based on a sample from a book
I've created a web page based on a sample from a book. It works fine, but seems to have become too complicated.
...
6
votes
1
answer
3k
views
C++ Wrapper for SAFEARRAY
Here is a C++ wrapper for SAFEARRAY, including the ability to expose it as a VARIANT, and to create one out of VARIANT.
I am aware of CComSafeArray, however i don't use VC++ so I do not have ...
11
votes
3
answers
2k
views
Algorithm to calculate semi perfect integers, lack of efficiency
I'm working on an algorithm to calculate weird numbers, and to do so there are several properties that needs to be calculated, one of them being, if it is NOT a semi-perfect/pseudoperfect number.
My ...
2
votes
2
answers
717
views
Select item of IEnumerable<T> in UI (MVVM)
Please, help improve following code. I have list of users, item of the list has buttons remove (remove user from list) and profile (navigate to user profile). I use ...
6
votes
2
answers
97
views
Discount curve from instant rate
This my first foray in F#, and I cannot think (yet) functional. I have implemented an interface for a discount curve and the implementation for a piecewise constant instant rate implementation.
I ...
15
votes
3
answers
2k
views
Testing a lock-free job queue
I've created a lock-free job queue and with the tests I've written, which is also very fast.
That makes me doubt my benchmark procedure, so I'm hoping the collective knowledge will shed some light on ...
12
votes
1
answer
966
views
Implementing a generic and covariant Set in Scala
I'm struggling with manually implementing a simple purely functional Set that's also generic and covariant on its type parameter:
...
3
votes
1
answer
2k
views
Implementation of MVC pattern with paintComponent method
Could someone review my code, with respect to OOP, clean code and MVC pattern?
Main app:
...
12
votes
4
answers
1k
views
Decision Table for the Movement AI in a Game
I posted a question on Stack Overflow about how to implement Decision Tables in Objective-C after reading about them for the first time in chapter 18 of Code Complete. Nobody provided an answer, so ...
2
votes
2
answers
97
views
Multiple isset block going from more specific to more generic
I have a data structure that allows for inheritance of properties, in such a way that if a property is not defined within a context, the second most specific context is checked until said property is ...
2
votes
1
answer
162
views
Benchmark/timer library - follow-up
I created a timer library called PHPBenchTime a few years ago, and decided to rewrite it last week.
This new version is meant to add in missing functionality (pause/unpause) as well as expand on the ...
11
votes
2
answers
190
views
Random weighted 'tick' function
This is a very simple function, but it gets run on a roughly 10ms interval, so I'm looking for ways to improve it. The first obvious thing is that it has to run the comparisons nearly every time as it ...
10
votes
4
answers
1k
views
Inserting 1 line into my SQL database
This is for adding code into my table really easily, however it will be called 2000+ times per second, so I need to know if this is the most efficient code to add a row to the database.
...
4
votes
1
answer
1k
views
A Quadtree implementation with Colliders
I have created a QuadTree in Java and would like a general code review or suggestions.
...
2
votes
1
answer
262
views
Can this method be changed to remove all objects in one call?
I am converting a VB.NET app over to C#. I won't subject you to the old code but the following is done in a little over 100 lines using nested loops. I am using Entity Framework 6 as my ORM. I have ...
6
votes
2
answers
15k
views
Multiple SQL statements in a single transaction
Using the following query I'm doing transactions with two tables
...
9
votes
1
answer
3k
views
Getting all likes from a specific user on a news wall with fewer graph API calls
Right now, my solution counting likes of a specific user is
Starting a recursive call on the "/{user-id}/posts" edge
Iterate through all posts
On each post iterate through each like on the likes ...
12
votes
1
answer
28k
views
Generating random email addresses [closed]
The code below generates only 10 email domains. To me, this is bruteforce programming. Is there another random integer library? Could I use something like ...
10
votes
1
answer
215
views
Refactor VB.NET to C#.Net using Linq
I am rewriting a VB.NET application in C#. I will not subject you to the original code because it's pretty messy. Below is the converted C# code:
...
4
votes
1
answer
84
views
Is this approach correct when testing an Angular controller?
I'd like someone to review these tests to make sure I'm along the right lines in Angular testing.
Note - They do all pass (great) but I feel like I'm struggling to understand the finer points of ...