All Questions

Filter by
Sorted by
Tagged with
1
vote
1answer
636 views

Knockout first-timer

Looking at knockout for the first time, would like to know if I'm approaching it correctly. Here's a live example: http://jsfiddle.net/fergal_doyle/xhAe8/1/ I have a "car" select, and an "other" ...
3
votes
1answer
207 views

Contact information validation

The scripts below, I've obtained through tutorials and edited the best I know how. It all works - but I'd like to place them in one, external script. If at all possible, I'd appreciate some help in ...
2
votes
1answer
97 views

How do I structure my entities for easier persistence?

I am learning ORM using Hibernate by creating a movie rental application. Currently, I have the following three entities for persistence: User Movie Rental (composite element for many-to-many mapping ...
2
votes
1answer
563 views

Am I using C++11 features like STL and move semantics correctly?

I've implemented selection sort, heap sort, insertion sort, and iterative quicksort using C++11. Am I using the correct STL data structures/algorithms? Am I using move semantics correctly in my code? ...
3
votes
3answers
4k views

Finding the closest node

I have a function that I need to optimize: ...
4
votes
1answer
4k views

Handling of open database connection and calling shared function from WebAPI

I'm working on an ASP.NET project using VB.NET that uses Dapper and the code as implemented so far runs fine with just me testing. In the example below, Dapper calls a stored proc. But I am ...
8
votes
2answers
201 views

Switching some text labels when the first image of a carousel is active

Is there any way I can simplify this inefficient piece of JavaScript? ...
1
vote
3answers
98 views

update list based on other values

Basically I have a 2d list containing movies. Movies are specified by name, version and description. For example ['Jaws', 1, 'Movie about sharks'] - where ...
3
votes
3answers
603 views

An attempt at a simple type safe python enum

There have been many posts here about enums in python, but none seem to be both type safe and simple. Here is my attempt at it. Please let me know if you see anything obviously wrong with it. ...
4
votes
1answer
2k views

Alternated Caesar Cipher

I've recently picked up PHP, for the first assignment in my IT-security class I decided to code it in PHP. The algorithm is an alternation of the Caesar cipher, instead of using a fixed number to ...
2
votes
2answers
807 views

Is it ok to use PHP's strpos and substr altogether in one statement?

I am using PHP to build a REST API. I want to receive requests from the URL in the following format: http://mydomain.com/api/format/method?app_id=value&call=encrypted_request So, I have modified ...
3
votes
1answer
166 views

The eternal dilemma: bar.foo() or foo(bar)?

I was using foo(bar) as it's adopted for functional programming. ...
4
votes
1answer
142 views

Refactor a sequence of functions

I have an http library in Ruby with a Response class, I have broken it down into smaller methods to avoid having a big intialize method, but then I end up with this: ...
1
vote
1answer
247 views

Referring to nested arrays and array_merge (php)

In such an array: ...
-3
votes
2answers
187 views

Any way to change optimize this or/and change to recursion?

Number can be very big.Script is taking number as a "number" list and crossing from 10-decimal based system to n-based system until list equals "5".I don't use letters like in 16-base system(hex)....
5
votes
1answer
6k views

Finding missing items in an int list

Here is a problem I am trying to solve: trying to find missing photographs from a sequence of filenames. The problem boils down to: given an unsorted list of integers, return a sorted list of missing ...
1
vote
3answers
13k views

Updating list of Dictionaries from other such list

Basically I have created a function which takes two lists of dicts, for example: oldList = [{'a':2}, {'v':2}] newList = [{'a':4},{'c':4},{'e':5}] My aim is to ...
3
votes
1answer
482 views

Lightweight Cookiemanager

I've been working on a lightweight cookiemanager and version 1 has been completed and works perfectly as intended. I would love to get a review to see where we can improve it. Where should I throw ...
2
votes
1answer
617 views

PHP ORM like system

I'm using PDO, but I want to create my own class for more convenient work with the database. My main idea in example with comments: ...
3
votes
1answer
132 views

Communication with GARMIN through WEB

I am developing a WEB based GPS system and one of its functionalities is to be able to send messages and routes to GARMIN devices. I have never been using sockets before, and for some (obvious) ...
5
votes
5answers
2k views

Guessing words from scrambled letters

How could I possibly shorten / clean this up? I suppose mainly clean up the loop at the start asking whether they would like to scramble the code. ...
3
votes
0answers
97 views

Fitness function

I have a fitness function, where inputs x1 to x14 have values between 1:4. Is there a way to make this more efficient? Any ...
3
votes
3answers
642 views

jQuery animation and rotation effects for a WordPress site

What is the best way to tidy up JavaScript code I have written? It seems very long winded, any suggestions to shorten it? Note: I'm running it on Wordpress which runs jQuery in nonconflict mode, ...
0
votes
2answers
547 views

iOS/Objective-C “if” best practice [closed]

I've got this code that I found in a project and I'm wondering how can it be done better: ...
3
votes
1answer
401 views

Displaying unique objects generated by Raphael.js in FancyBox

I'm using Raphael.js to generate objects which are unique but do basically the same thing. I'm also using Fancybox to display a unique image after a click on a generated object. Is there a way to ...
5
votes
1answer
173 views

Avoid redundant code in this simple method

I am wondering what would be an efficient way to simplify this very simple PHP method and I really lack inspiration: ...
0
votes
1answer
683 views

Optimizing Jquery Twitch TV Application

I'm trying to get in the habit of writing better looking code and more efficient code blocks. I wrote this Twitch TV Application which allows you to add and edit channels and it lets you know when a ...
3
votes
1answer
641 views

pull things from lazy source till timeout is reached

I need to pull things from lazy source till timeout is reached in this fashion: ...
2
votes
1answer
200 views

Optimization expression evaluation challenge

I'm trying to calculate a total value with an array of six numbers and all the basic operators (+-*/). Suppose you have: 1, 2, 3, 4, 5, 6 and you want to have a total of 10. Here is my function call ...
7
votes
1answer
3k views

Static variable in method vs private class property

I have a class with a method that will be called multiple times over an object's lifetime to perform some processing steps. This method operates on a mixture of immutable (does not change over the ...
1
vote
1answer
89 views

Learning MV* based javascript, would appreciate a review of my current app

I am trying to crank up my javascript knowledge by diving into the MVC/MV* design patterns in order to create more reusable and extendable apps. I am currently sketching out a webapp that involves ...
1
vote
3answers
78 views

Implementation of an UniqueIdentifier class

I have a requirement to implement a generic UniqueIdentifier which can cover identifiers like OrderId, TrackingID, scannableId and other Ids. The ids, as they are now, are either ...
8
votes
3answers
563 views

Statistical calculations with sets of genes

The following piece of code executes 20 million times each time the program is called, so I need a way to make this code as optimized as possible. ...
8
votes
1answer
1k views

Basic (Logical Only) Sudoku Solver

I'm (very) new to Scala, and decided I'd try to get a handle on some of the syntax and general language constructs. This currently doesn't implement any backtracking and will only solve things if ...
5
votes
3answers
17k views

Find and process duplicates in list of lists

I'm trying to merge counts for items (URLs) in the list: [['foo',1], ['bar',3],['foo',4]] I came up with a function, but it's slow when I run it with 50k entries....
1
vote
1answer
72 views

autoloader class fine tune to be usable in every project

I'm open to any advice to help improve this code for general use. ...
4
votes
1answer
139 views

Return most common items in list

I was wondering about the best way to return the most common items in a list. So far the best way I could do it was: ...
7
votes
1answer
352 views

Alien battle code

I've recently written a program for Python 3 that I'm using to practice my newly-acquired object-oriented knowledge. It's a simple text game that is really easy to play and can be run straight out of ...
4
votes
1answer
2k views

Implementing cache for server

I've just implemented a cache for my server, and I'd like your thoughts about performance improvements and maybe some possible bug fixes: ...
-1
votes
2answers
120 views

Unpacking sequences for functions [closed]

After watching Raymond Hettinger, I decided to go through my code and make it faster and more beautiful. The example given on the slides is, unfortunately, not good enough to get me going (ref. https:/...
2
votes
2answers
3k views

Date formatter for javascript

I just coded this formatter to format timestamps in javascript (I tied it to underscore for convenience), any remark? ...
4
votes
2answers
304 views

Given a random section of text delimited by line breaks, get the first paragraph

Requirements: Given a long section of text, where the only indication that a paragraph has ended is a shorter line, make a guess about the first paragraph. The lines are hardwrapped, and the ...
1
vote
4answers
115 views

Best design pattern for Javascript

I have a meta-search engine system, i implemented mainly using static classes. The query pre processing module consists of the following static methods ...
3
votes
3answers
864 views

Logic for an init function in email parser [closed]

I am writing an email parser and cannot decide how much logic should be included in the __init__ function. I know that a constructor should make the object ready ...
2
votes
2answers
330 views

exercise #40 in A Tour of Go

My quick searching did not reveal anyone sharing their solution to this exercise, so am not sure if there are other (and better) approaches to mine: ...
1
vote
1answer
431 views

Opinions on my Command pattern design - is it extensible?

I am implementing a program that takes commands from a user and based on those commands, drives a Robot on a grid. To implement this program I have used the Command pattern. I have used this pattern ...
3
votes
2answers
348 views

Raising an assertation error if string is not an email

I created a class EmailParser and check if a supplied string is an email or not with the help of the standard librarie's email module. If the supplied string is not an email I raise an exception. ...
7
votes
2answers
331 views

Efficent way of synchronizing between data

I'm currently working on a project where I have a punch of raw data and multiple components that use that data for various tasks. I would like to separate the raw data from the components as much as ...
1
vote
1answer
1k views

PHP DateTime increments, a neater / more efficient way?

I'm trying to get to grips with the DateTime class in PHP. Previously I've used date() and mktime() when playing with dates. Here's the head of a calendar table, and I'm pretty sure I'm doing this in ...
4
votes
1answer
6k views

AngularJS directive that manually transcludes content and has isolated scope

I would like to hear the opinion of more experienced AngularJS developers on whether the following directive is best practice... I was trying to make to make a directive that will include HTML that: ...

15 30 50 per page