All Questions

Filter by
Sorted by
Tagged with
25
votes
1answer
20k views

Efficient smart pointer implementation in C++

The idea behind this is mainly educational but I might even consider using it in reality if turns out to be good. Here's my first try at implementing smart pointers: ...
4
votes
2answers
1k views

Lowest Common Multiple of 1 to n in Ruby

Project Euler problem 5 asks: What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? I'm learning Ruby by going through Project Euler problems, and ...
3
votes
1answer
3k views

PHP MVC - Custom Routing Mechanism

Note #2: This was a post from a while back. Although the top rated answer is useful (generally), I'm looking for something more specific to this issue including routing / architecture. I've even tried ...
5
votes
1answer
36k views

Writing/reading data structure to a file using C++

I wrote some piece of code which reads and write multiple data structures on a file using C++. I would be grateful to get your feedback on what you think about the code (it works at least when I ...
1
vote
1answer
264 views

WordPress plugin for obfuscating a file URL

I'm making a WordPress plugin that obfuscates the real file URL and forces the download of one of this 3 types of URL: Local: ...
0
votes
2answers
155 views

Does my classes contain right destructors [closed]

Every Account has its owner who is Person The bank has list of owners. I am not sure if my destructors are right and ...
2
votes
1answer
750 views

Designing function prototypes for a singly-linked list API in C

I am in the process of rewriting in C all the data structures that I learned about a few years ago to increase my understanding of data structures and the C language. The first one I'm doing is singly-...
7
votes
1answer
1k views

Find almost-shortest path more efficiently

I'm trying to solve a SPOJ problem, which is code SAMER08A at this link. The problem is that when I ran my code in my IDE with all the examples given in the problem, the code works perfectly. But ...
5
votes
2answers
385 views

Autoloader class

Depending on your directory structure you may have name spaced class files in different directories (that isn't really part of the structure, i.e. lib/ or core/). Symfony ClassLoader is awesome, but ...
4
votes
0answers
299 views

Quick Insert Merge Sort

I have written this code to sort a list of numbers, in increasing order. It is a combination of quick sort, insertion sort, and merge sort. I make the first element of the list a pivot, then I go ...
10
votes
1answer
2k views

A C++ PEG parser generator

I wrote a C++ PEG packrat parser generator and would love to get some feedback on the code and/or syntax. I currently use the << operator for defining grammar ...
2
votes
1answer
155 views

Bash script to manage multiple Java Development Kits installations

I'm writing a bash script to manage multiple JDKs, the script is very simple, you have to choose a directory when you store all the jdk's, and the script maintain ...
2
votes
2answers
81 views

Trying to improve a working regex

I am extracting data from a text file. Some of the lines from which I want to extract the data consist of a text description with single spaces, followed by a multiple-space gap preceding four fields ...
1
vote
1answer
126 views

How can I improve my code which dynamically populates a section of a page?

My site consists of a lot of asynchronous calls, and because of this a lot of content is dynamically added to the page. For this section of code I've dynamically added tabs to a page and need to ...
2
votes
3answers
5k views

Is this PHP Email Form Secure from injections or other abuses?

I am new to PHP and put this contact page together using the w3Schools.com example as a guide along with a couple other sources. As far as I can tell, it works fine, but before I put it up on my page ...
2
votes
0answers
76 views

String matching

I recently came across a lecture on DFA. I tried to use it to determine whether a given 'search string' is found in the 'input string'. Please tell me if there is a better way. ...
6
votes
1answer
1k views

How do I optimize the solving of ODEs?

I have been trying to figure out a way to optimize the solving of ODEs in Python but haven't been able to achieve this goal. I tried getting help via a bounty on SO using Cython but nothing came of ...
2
votes
1answer
45 views

Creating an expanding CCSprite cluster

I am creating an "explosion" of circle sprites from the character with this code, and I was wondering if there is a more effective way to do such things, because this just seems too stupid. (This is ...
2
votes
1answer
297 views

Cataloging digital media to a MySQL database

I understand .NET very well until Principles of OOP come into view, so I guess we can say very little. So to work on this, I am making a console app that will catalog my digital media to a MySQL ...
2
votes
1answer
305 views

Chrome extension that lets you push changes from Chrome Developer Tools directly to GitHub

2 months ago, I wrote a chrome extension called hotfix. I recently went back to look over the code and it made me cringe a bit. I refactored it a little, but before I get knee deep in it, I would like ...
8
votes
1answer
1k views

Dynamic Controller Creation in Rails

I have overrode Rails' ActionDispatch::Routing::RouteSet::Dispatcher.controller_reference method to check if a controller exists by checking for the required ...
2
votes
1answer
145 views

2-player board game app

This question is about the best way to declare functions in Javascript. The app is a small 2 player board game I'm working on as part of a bigger web page. Basically I have a socket which receives and ...
6
votes
1answer
197 views

C++: Generating similar methods with macros

I am currently working on a project that involves Lua. For convenience, I created a wrapper class for the Lua state structure. However, I also added some methods for getting globals and table fields. ...
4
votes
1answer
513 views

jQuery code repetition and MVC

A while ago I started working on a project, which does things mostly with jQuery and PHP. I had some problems with my structure and started using CodeIgniter which uses an MVC pattern. So the PHP part ...
8
votes
5answers
561 views

Saving a contact and dealing with exceptions

...
2
votes
1answer
112 views

Drawing game objects using their Z-order property

I am creating a game, with Ruby scripting. Sprite and Label objects can be drawn on the screen. Depending on the order you draw ...
7
votes
1answer
471 views

Prime Numbers Store

Let's say we need to create a store for selling prime numbers. Users enter the store and ask to buy a number. If the number asked is a prime number, 1.1. then it's either available for sale 1.2. ...
12
votes
3answers
14k views

Import “izip” for different versions of Python

A common idiom that I use for Python2-Python3 compatibility is: try: from itertools import izip except ImportError: #python3.x izip = zip However, a ...
4
votes
3answers
979 views

Minimizing CSS media queries for the page title?

I am working on page titles to be responsive. The code I have works and gets the job done, but I know that this is verbose. I decided upon the widths by trial and error based on how the words were ...
3
votes
2answers
261 views

Potential Problems with this templating technique

I like the way Zend Framework works it's views and I make extensive use of partials but every partial include results in it's own file system hit. As I'm building my own framework I thought I could do ...
3
votes
1answer
2k views

Proper way to cancel WebClient in BackgroundWorker

I have a WPF application that needs to get a XML document using a web request. The request is based on an id that the user enters. If the user enters a second id, before the first returns, I would ...
3
votes
2answers
6k views

Singleton interface in Java

I've created a singleton by means of an interface. I don't want to make a thing with getInstance() etc because I don't care about inheritance, and it's redundant ...
3
votes
1answer
128 views

Dynamic homepage with PHP - making things too complicated?

I am trying to show the 6 most popular products on my homepage from left to right, in two rows. My code actually works... but I have the feeling I am making things way too complicated. Is there a ...
2
votes
2answers
11k views

Populating an unordered list from values in a JSON file

I have this view that populates an unordered list from values in a JSON file, which I am doing in Node. Is there a better way to do this, or a more 'node-like' way? Can I load the JSON file without ...
1
vote
1answer
1k views

Better Design Pattern For Terminal-Like GUI

I am working on a java swing project that looks like a Terminal (but with less functionality). The GUI contains a jTextArea to ...
5
votes
1answer
892 views

Feedback on college project [closed]

I would appreciate some feedback regarding best practices on the following code for a college project. What should go in the controller and what in the views? How to attach and remove the views to ...
3
votes
2answers
514 views

Ruby Branch and Bound Algorithm implementation?

I am relatively new to Ruby and am trying to get a handle on making my code more Ruby-esque. At the same time I am experimenting with the branch and bound algorithm to solve a problem that I outline ...
1
vote
1answer
195 views

Callback for job applicant

This is on a job listing site and it has a Linkedin apply button plugin - this provides for a callback the someone has applied for a job. I've written the callback function which extracts the Job ID (...
1
vote
1answer
313 views

InstaSlider slider/carousel plugin

InstaSlider is a lightweight jQuery image slider / carousel plugin that populates content from an Instagram hashtag. After searching for a similar solution for one of my own projects with no luck I ...
1
vote
1answer
2k views

XmlNodeList to ListItemCollection

At this moment I'm reading an XmlNodeList into a ListItemCollection one node at a time using a ...
3
votes
1answer
2k views

Basic Java database

I just wrote my first Java database program for the purpose of getting feedback on the implementation and coding. It has 1 table and 2 buttons and prompts the user to select a folder, lists the ...
25
votes
9answers
41k views

Set of jQuery .onclick functions

I am hiding and fading in different content on the same page using jQuery to hide() and fadeIn() the content depending on which ...
2
votes
2answers
965 views

Time limit of a c program while calculating factorial of numbers in c

I am solving a problem on calculation of factorial and the challenge is as follows! ...
1
vote
1answer
98 views

Defining book models in GAE

I'm learning to work in GAE. I'm so used to SQL, but transform my way of think the last 20 years to NoSQL is a little hard for me. I have the next simple structure: ...
11
votes
1answer
5k views

Simple “nullable” template class. Are there weaknesses in the implementation?

The goal is to have fields in a class which are optional and can be determined if they are set in order to be able to leave them out of serialization. ...
11
votes
1answer
919 views

Random Generation From Sequences

With the inclusion of <random> into C++11, we can finally chuck out std::rand and start using generator with much better ...
3
votes
1answer
1k views

JavaScript geocoder

I'm pretty excited to have coded my first JavaScript file which now works, and I've spent my evening trying to improve it. It takes a location in the #loc input ...
8
votes
4answers
10k views

C++ vectors sort ascending/descending

How can I eliminate repetition from this code? ...
2
votes
1answer
2k views

Router Class In a Lightweight MVC Boilerplate

I'm trying to come up with a simple router class. I considered using a Request class, but I think that will turn something simple into something overly complex. ...
-2
votes
3answers
131 views

Optimizing this seemingly slow Query

...

15 30 50 per page