All Questions

Filter by
Sorted by
Tagged with
2
votes
1answer
9k views

What value the rear and front counter of an Array implementation of Queue start with? -1 or 0 or 1?

Is there anything wrong with this implementation of Queue with array? I have started front = rear = -1. Some references tend to start front = 0 like this:enter link description here I think if ...
3
votes
2answers
1k views

Functions for scanning command line options

I know that getopts is available but I wanted to write my own as a way of improving my bash. Below I show two function definitions and an example of the use of them in a bash script. Finally I show ...
4
votes
3answers
9k views

There has to be a better way of parsing XML in C# than what I'm doing

This is the way I'm currently getting data from XML, but it seems to be really inefficient, checking every localname in every iteration. How should I be doing it? Here is a sample of the XML I am ...
3
votes
1answer
258 views

C in CRUD for Silverlight

The C in CRUD Silverlight: Create new Silverlight business application "CRUD" Add ADO.NET Entity Data Model to CRUD.web Select the db, the tables, build the project Add Domain Service Class to CRUD....
3
votes
1answer
186 views

Creating a matrix from a dyadic product

Ax, Ay, Az: [N-by-N] B=AA (dyadic product) means ...
1
vote
3answers
745 views

Is my multithreaded form code correct?

The basic idea is this: There are two buttons: a DoWork button and a Cancel button. The ...
3
votes
4answers
4k views

Iterator pattern/iterator class

I have implemented a simple iterator. Just want to check if I have missed anything. ...
2
votes
2answers
218 views

Sanitisation function: any holes?

I've come up with this small function to make user submitted strings safe for MySQL. I'd be grateful if someone could point out any security holes in this. I've tested it out, and it happily replaces ...
3
votes
1answer
1k views

Zend Bootstrap code review

I've been working on putting a new app up against Zend. In my admin section, I want the nav links to only show if the user has rights to see the page. So I set up some Acls. But this doesn't seem like ...
4
votes
3answers
266 views

I want a nice design pattern for “All”, “many” or “one”

In my particular usage here, I'm using two functions to deal with one thing. Lets say the user request comes in to select "ALL" the records, in which case I would pass on some code such as: ...
2
votes
1answer
871 views

Polling script to determine the continuous time a user has been connected

I've been asked to keep track of how long a user has been connected to a site without interruption. So far the solution I've come up with is to use ajax to poll the site every now and then to check ...
2
votes
2answers
2k views

Class for loading and resizing images on the fly performs slowly on large images

I made this PHP class that loads any image you specify and resizes it to any size you want. Features If the size you specify is greater than the original, it will not stretch the image but use ...
0
votes
1answer
2k views

How to re register dynamic scripts registered with ClientScriptManager in asp dot net using session was bad idea

Following the normal pattern of adding inline scripts to gridview row/s is a bad practice it used to work like below ...
4
votes
3answers
243 views

Setting bgcolor in Ruby. What's the proper way to do it?

<p style="background-color:#<%= debate.bg_color %>;" > be_color is a method of ...
3
votes
1answer
3k views

Python subclassing ConfigParser

I've never done anything like this before so I'd like someone else to look at this before I get too carried away :) Am I making this more complicated than it needs to be? I'm trying to make it EASY ...
4
votes
3answers
815 views

Converting a string to coordinates

I'm going through the CoffeeScript book by Trevor Burnham, and I was curious as to what the best style is for a function I was writing. In the book the author writes the function like so: ...
3
votes
2answers
979 views

Fair use or Abuse of the dynamic (System.Dynamic.DynamicObject)?

I have a T4 Templates project that generates methods to "convert" one Type (class, struct, enum) from a source Assembly its corresponding Type in another. The two types have the identical names and ...
4
votes
4answers
486 views

Email confirmation model

Email<input type="text" id="email" /><br /> Re-enter Email<input type="text" id="confirm-email" /> I'm thinking that I want a model so that I ...
1
vote
1answer
589 views

Adding or Replacing a Page item in a QueryString in C#.

Can this code be improved? I'm avoiding using the QueryString collection because the query string may contain eg: OrderBy=Column1&OrderBy=Column2 and it didn't ...
2
votes
1answer
901 views

WCF general response validation for multiple services

Background information I am building a web application that consumes 3 different WCF services that are hosted internally. Each response object from the service inherits from a base class ...
2
votes
4answers
396 views

Reduce the code in a WHERE clause without using dynamic SQL

How can I write the following T-SQL query part in a shorter way without using dynamic SQL? ...
4
votes
3answers
2k views

Need help with valid knight moves in Chess

Last weekend I was writing a short PHP function that accepts a starting move and returns valid knight squares for that move. ...
4
votes
1answer
309 views

Using Regex to parse a chat transcript

I need to classify each line as "announce, whisper or chat" once I have that sorted out I need to extract certain values to be processed. Right now my regex is as follow: ...
3
votes
1answer
1k views

Legendre's polynomials and functions

I would like to improve this function to reduce the run time and optimize it. ...
6
votes
3answers
5k views

fix ugly initialisation in while loop over queue

I have a loop structure, that I really don't like. It's the initialisation I find appalingly ugly. Is there a nicer way to do the following? ...
8
votes
4answers
3k views

“Pretty” date generator

I have this "pretty" date string generator in C# - pass it a date and it returns a string with "5 minutes ago" or "2 weeks, 3 days ago", etc. It's a little verbose and hogs 61 lines, and I'm ...
3
votes
2answers
453 views

Code Concision - String Capitalization

I'm working on a few JavaScript functions for myself that I hope come in handy sometime. The first I wrote was a Capitalization function (yeah i know, real original. whatever) I was just wondering ...
5
votes
1answer
2k views

Coding adjacency list representing graph

I want to write some basic code on graph like DFS, BFS but before that I am coding graph representation in adjacency list, and some basic functions like ...
87
votes
6answers
56k views

File Browser GUI

FileBro is a basic GUI based File Browser. FileBro Functionality Directory tree - shows the file system roots at start-up, but is otherwise built lazily as the user browses around the file system. ...
5
votes
1answer
648 views

How would you rate this python code? (Django AJAX)

This code comes straight out from the example code in a Django book. I find it quite bad, mainly because the use of flags (if ajax then again ...
33
votes
6answers
4k views

DisposableObject base class for C#

I commonly run into the need to implement IDisposable in my code. To correctly dispose of both managed and unmanaged resources requires a reasonable amount of boilerplate code. Based on the ...
8
votes
1answer
3k views

What can I improve on my iOS PDF class?

This is the first PDF class I have made for the iOS using code from Apple's samples. There could easily be stuff here wrong that I am missing. I intend this to get images out of for a layer, for ...
6
votes
1answer
409 views

jQuery to display ANSI graphics

This is my first attempt at a jQuery plugin. Any tips or comments in regards the the plugin setup would be appreciated. I'm also looking for a general review over the code itself. I'm wondering if ...
4
votes
1answer
394 views

Social share widget for guubo.com

This is a social share widget for guubo.com. The live widget can be seen here (though you need to be signed in guubo.com, otherwise you will see a logged-out user interface). JS is not my first ...
6
votes
5answers
452 views

Search for products based on criteria

The method must search Products found by criteria and store them in @products. The criteria are as follows: If the user enters ...
7
votes
1answer
942 views

Critique request: PHP cookie library

I've written a fairly small library that abstracts cookie functionality in a way that mimics working with a database model. The repository is on bitbucket and the code is small enough to embed here: ...
10
votes
3answers
3k views

Linked list loop detection in Java

A schoolmate is going through the interview process, and was given the question of detecting if a linked list data structure has an infinite loop in it. I wrote this example, and wanted to see what ...
11
votes
15answers
1k views

Java practise exam question

Doing practise questions for a Java exam which have no answers (useful) I have been asked to do the following: Write a class called Person with the following ...
6
votes
1answer
392 views

Inserting into a linked list

I know that this is very very basic, but now I am starting from group up after getting frustrated with my coding practices and knowledge of standard idioms out there and elegant way of coding corner ...
8
votes
2answers
1k views

Using bucket sort to rank students based on their marks

Problem: n students have marks and names. Rank students based on their marks and print their names. ...
4
votes
2answers
157 views

jInternalFrames code

I'm new to this page I want to ask you to critique my code on jInternalFrame. Basically the problem is that there is no complete example on using this, so I wrote this "template" but I don't know if ...
6
votes
3answers
4k views

TDD workflow best-practices for .NET using NUnit

I'm starting to dive into TDD with NUnit and despite I've enjoyed checking some resources I've found here at stackoverflow, I often find myself not gaining good traction. So what I'm really trying to ...
5
votes
2answers
3k views

Given two Binary trees, find whether the second is a sub tree of the first

Given two binary trees, you have to find whether the second is a sub tree of the first. First attempt (brute force): ...
2
votes
1answer
335 views

Second largest element of a large array

Given an array which contains integers (may contain thousands of elements), you have to write a program to find the second largest element of the group. ...
7
votes
2answers
900 views

Merge sort 2 sorted linked list

My coding skill is pretty rusty and moreover, I have never paid much attention to writing elegant code. I want to start on this. Problem is to merge 2 sorted linked list. Algorithmically this is ...
7
votes
1answer
1k views

Replacing files with symlinks to other files

I wrote a little Python script to replace some files in usr/bin with symlinks to files in a different location. I wouldn't mind anyone telling me where I could do ...
3
votes
2answers
1k views

How skinny should controllers be, how fat should models be in CakePHP?

I know it's a good idea to put all data-related logic in your models in CakePHP, but what would you say about keeping every Model::find() and its particular params in the model? Is this good practice, ...
5
votes
3answers
389 views

Improving the design of this program.

I am trying to design a program that will read a XML file and based on the tag name will perform certain requirements checks. I feel that there is probably a better way of doing this and any comments ...
3
votes
1answer
2k views

Review Request: Python code that searches query words in a given text

I have this code which looks for query words in a given text. I preprocess the give text and store it in an inverted-index (dictionary with word as key and position in text as value). Searching for a ...
5
votes
1answer
1k views

Count to target with JavaScript

I'm looking for (and be as brutal as you like) ways to improve the code or the algorithm (I'm aware there should be comments) - I'm a recreational programmer and would like to be improving my skills. ...

15 30 50 per page