All Questions

Filter by
Sorted by
Tagged with
2
votes
2answers
13k views

Minimax Alpha-beta code for Java

Not so long ago I learned how to implement the minimax algorithm with alpha beta pruning, and even created a perfect Tic Tac Toe player. How can I improve this? ...
-1
votes
1answer
4k views

How to optimize response.redirect in ASP.net [closed]

We know when we call HttpContext.Current.Response.Redirect("http://tvrowdy.in"); It throw an exception. Can we do it this way(working fine). Need suggestions and ...
2
votes
1answer
399 views

Python flask web app, simplification [closed]

I am writing web application using flask framework + mongodb. I have an issue, should I use classes for my mongo entities or just use dictionaries for them. ...
1
vote
3answers
92 views

Image uploader and manager

I have recently started using Ruby and would like to hear your take on the following piece of code. ...
2
votes
2answers
2k views

Replacing tokens in a text file with replaced text

This code parses a text file, replacing special tokens marked as $(token) with some replaced text. The $ symbol can be escaped by entering a double $$. In the example a user enters a text file ...
2
votes
2answers
2k views

Reducing time limit for prime number program

I have to create a program in which t sets of m and n will be given by the user. For each ...
3
votes
1answer
495 views

Select first or last object from id<NSFastEnumeration>

I found this code in our project and it just feels like the wrong way to do what it seems to be doing ...
1
vote
2answers
223 views

JS arrays to simplify jQuery filtering

Okay, I'm under the impression that my current jQuery can be simplified (don't worry! It's short!) and I'm curious to know how this can be achieved. I think a solution to this will help produce a lot ...
2
votes
1answer
283 views

How can I tidy up this servlet parameter check code?

One of the servlet in my web app takes parameters in the form www.service.com/servletname/parameter1/parameter2. The first parameter is required and the second ...
2
votes
1answer
126 views

Handling library entity

Below you'll find a Symfony2 service I wrote to assist in handling the Library entity. Each user in my app has a personal library where one can upload items to and a purchased library, that contains ...
4
votes
2answers
207 views

Am I violating any sound coding principles with this approach?

I am creating a C# service that will be doing some specialized processing of data coming into our ODS (Operational Data Store) DB. To support this, I’m building a DAL that will be used to access our ...
1
vote
1answer
139 views

Square free Integer

I am an amateur programmer and I tried coding this problem using the TurboC++ IDE (though my code is in C), but the site's compiler throws a "TIME LIMIT EXCEEDED" error. How can I optimize my code ...
1
vote
2answers
3k views

Performance testing in PHP

I need to test performance of a function in PHP. This has to happen accurately, of course. In the end I need to know how long it takes for a function to perform. What I'm doing now: ...
6
votes
3answers
3k views

Comparing database values with values from a GridView

I have a block of C# code here that stores data to an ArrayList from the database and compares each with the values from the ...
1
vote
1answer
143 views

Is this a good way for Controller to interact with Model ? (MVC)

In my controller I had the idea to do something like the following: ...
4
votes
4answers
2k views

Reducing memory usage of nested vectors

I recently asked this question about performance of an unordered_map, but I realize my question is probably more about this piece of code here. I create a 8 x 10 x 30 x 30 x 24000 nested vectors of ...
2
votes
1answer
4k views

overloaded const and non-const class methods returning references in C++

I have a data-structure class in C++ with an accessor to some object (may be large) and I have const and non-const methods using this accessor so I need to overload it. I am looking for a critique of ...
0
votes
3answers
571 views

Tips to refactor code : very repetitive code [closed]

I have this very simple problem : my code is too repetitive. It works, but it could be much cleaner. I don't know exactly where to start. I'd like to learn to work better, and I'd really like ...
2
votes
1answer
174 views

Implement pattern match on FindUsersByName

I would like some feedback on the code below. And how would I Implement pattern match on find users in role so that exact match not required? ...
4
votes
1answer
827 views

Project Euler #14 (Longest Collatz Sequence) in Haskell

You can check the problem here: http://projecteuler.net/problem=14 My first approach in Haskell was this: ...
-1
votes
1answer
4k views

Counting failed login attempts to enforce temporary lockout

I'm reviewing my code and trying to figure out how I can do some simplifying to flatten my code. Whether it be making simpler function out of the segment of code or by removing parts of it and wanted ...
2
votes
2answers
557 views

Should I be using Regex to uppercase uncommon characters?

I've written a function for converting strings to upper case. It currently works by replacing each character using a Regex pattern with a hash: ...
1
vote
1answer
80 views

Is this a safe way of using HTTP query parameters to build a SQL query?

Is it? And maybe theres a better way to do this? ...
2
votes
3answers
141 views

What's the most optimal way to see if a string is included in a list of strings?

Something that has bugged me for a while, is what way is best to perform a conditional where a string is compared to other strings. Here is some sample code. This code is just for illustration ...
2
votes
1answer
1k views

Java Pong Game Collision between bat and ball

I have a very simple Pong game that I've built in Java. The code is quite long so I've decided to focus this question on the collision that occurs with the ball and the bat and also the effects in the ...
3
votes
2answers
4k views

Generating .xml files based on .csv files

This reads in data from a .csv file and generates an .xml file with respect to the .csv data. Can you spot any parts where re-factoring can make this code more efficient? ...
2
votes
1answer
3k views

Generating Pandigital Numbers

A Base10 Pandigital Number is a number which uses all the digits 0-9 once: 1234567890 2468013579 etc... My naive solution was just to use a bunch of nested loops to do this but it's quite slow. And ...
3
votes
1answer
5k views

Search and replace on command line [closed]

Is there a tighter (less characters) way to use perl on the command line to search and replace text from STDIN than I've got here? The code below works. ...
5
votes
2answers
10k views

Tasks: exceptions and cancelation

I need to do a long running task. I've done this by executing a Task while there's a loading box on the UI. When an exception is thrown, I want to stop the task and show a msgbox to the user. If ...
7
votes
1answer
22k views

Accessing an unordered_map

How can I improve the access time to this unordered map? If I instead allocate a 8 x 10 x 30 x 30 x 24000: ...
4
votes
3answers
36k views

Very simple events implementation

I've been thinking about implementing events and wrote some abstract code: ...
5
votes
1answer
316 views

Should I encapsulate my fields differently?

I wanted an excuse to do some OO JavaScript and I decided to do a JSON editor. It will basically allow you to input JSON and either collapse objects to see other objects better, delete objects (can ...
3
votes
3answers
818 views

Learning C, basic string reversal function

I am starting to write some functions while studying how to program in C. In this small function I take a string as an argument and print it out in reverse order. ...
3
votes
3answers
307 views

UNIX semaphores

I wrote an example program about UNIX semaphores, where a process and its child lock/unlock the same semaphore. I would appreciate your feedback about what I could improve in my C style. Generally I ...
4
votes
5answers
1k views

Print the largest odd number entered

I wrote this code to solve a problem from a John Vuttag book: Ask the user to input 10 integers, and then print the largest odd number that was entered. If no odd number was entered, it should ...
3
votes
3answers
192 views

re-write javascript array [closed]

I am using a long array of over 300 var & 7,000 lines of code written like this: ...
1
vote
2answers
122 views

Making a preselected drop-down selection box in HTML

I'm a PHP newbie and I have a question. Is there a better way to do this? A nice solution? ...
3
votes
1answer
3k views

More efficient jQuery scripting when manipulating multiple elements with multiple CSS attributes

I'm relatively new to JavaScript and jQuery so go easy on me. I'm creating a website where upon jQuery document.ready a set of basic animations are performed on ...
1
vote
2answers
6k views

Nested layouts - BoxLayout inside BorderLayout

I have this code: ...
1
vote
1answer
2k views

Creating a PDO abstract parent class

I think many people for some reason use a singleton class to handle the PDO connection (?) but I was thinking it would be nice to have a parent abstract class initializing the connection and the child ...
3
votes
1answer
656 views

What is the best practice for working with a project as nested modules? [closed]

I come from the world of Python, so I'm used to every file representing their own enclosed module, never polluting the global environment. Up until now (I've worked with Ruby for a week) I've created ...
2
votes
2answers
260 views

Speed up MySQL query with IN clause

I've tried to improve the speed of my query in MySQL, but when condition IN clause happens too often, the query runs very slowly. Can anyone help me optimize the ...
0
votes
2answers
138 views

Comparing two arrrays

I have two arrays: first one is ip addresses from billing for blocking second is ip addresses from firewall - already blocked My task is, compare it, and if ip address new in billing list - block it ...
2
votes
1answer
631 views

Control consisting of a mute button and an expanding range slider

I'm learning BackboneJS and I just made an attempt at converting a pre-existing module to a Backbone.View. I was hoping to get some feedback on my attempt and learn. I've been using the annotated ToDo ...
6
votes
3answers
272 views

Counting which numbers fall in a certain bracket

I'm taking a text file that looks like this: ...
6
votes
1answer
12k views

Catching all exceptions and errors in PHP

I've tried to catch all exceptions and errors in PHP in a way so that I can deal with them consistently. This is the code with the exception of the very last bit where I instead pass ...
0
votes
1answer
145 views

refactoring and optimization the class [closed]

There is repetition here and would appreciate help in improving this code. Suggestions? Here's the framework for it: ...
4
votes
1answer
411 views

Creating my own flow control statements in C++. Is that acceptable?

I always considered switch statement as somehow defective: works only on integral types and enumerations. isn't an readability improvement over traditional if/else ...
5
votes
2answers
335 views

OOP approach to using DOMDocument

I've tried to write an "OOP" approach to printing a website using the DOMDocument class. I'm kind of stuck here because I feel like I am blundering in how I am passing and using the DOMDocument. I ...
3
votes
1answer
592 views

Why is this divide and conquer algorithm inefficient?

I was solving one of the problem in USACO 2007 Open Silver: Description Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the ...

15 30 50 per page