# All Questions

67,348 questions
Filter by
Sorted by
Tagged with
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? ...
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 ...
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. ...
92 views

I have recently started using Ruby and would like to hear your take on the following piece of code. ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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: ...
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 ...
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: ...
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 ...
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 ...
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 ...
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? ...
827 views

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 ...
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: ...
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? ...
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 ...
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 ...
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? ...
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 ...
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. ...
10k views

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 ...
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: ...
36k views

### Very simple events implementation

I've been thinking about implementing events and wrote some abstract code: ...
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 ...
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. ...
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 ...
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 ...
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: ...
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? ...
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 ...
6k views

### Nested layouts - BoxLayout inside BorderLayout

I have this code: ...
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 ...
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 ...
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 ...
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 ...
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 ...
272 views

### Counting which numbers fall in a certain bracket

I'm taking a text file that looks like this: ...
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 ...
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: ...
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 ...