All Questions

Filter by
Sorted by
Tagged with
15
votes
1answer
7k views

What is better for Lazy-Loading Navigation Properties of detached Self-Tracking Entities through a WCF service?

I have a WCF client which passes Self-Tracking Entities to a WPF application built with MVVM. The application itself has a dynamic interface. Users can select which objects they want visible in their ...
5
votes
1answer
1k views

Haskell - Different log methods

I'm pretty new to Haskell and was playing around with some number manipulation in different bases when I had to write an integer logarithm function for my task. I don't mean discrete/modular logs, ...
3
votes
2answers
286 views

Best syntax for executing an action between each loop iteration.

The question of the cleanest way to write a loop that executes some action between each iteration has always interested me. In a sense, what is the best way in c/c++ to implement this fictional ...
3
votes
2answers
1k views

jQuery Delay slideDown using Queue

I have the task to create a function that adds some messages to the page and another to show them in last to first order with a jQuery slideDown() effect. jsFiddle ...
22
votes
5answers
1k views

Reading a collection of strings from the user

I was trying to write a program that will read a collection of strings from the user, and then end the moment it encounters a ".". So then I write a ...
5
votes
1answer
5k views

Is this a decent way of writing a start-stop-daemon script?

This is the first time I've written a start-stop-daemon script, so I would love some feedback. :) The goal is to have it start late, when the network and everything is ready. I also have 2 other start-...
8
votes
3answers
2k views

Generating very large prime numbers and their generator modulo N in php

I recently came up with the idea to attempt generating ungodly large prime numbers and their generators modulo N in php. I don't know much about number theory and just wanted to get some comments to ...
5
votes
2answers
314 views

shorthand methods

Is it good or bad practice (or, when is it appropriate) to use shorthand methods? Lets pretend we're using jQuery here, because it has a lot of them.: ...
6
votes
4answers
12k views

Polish notation interpreter/calculator

Just for the heck of it, I wrote a simple little interpreter that takes in inputs in the form of Polish Notation. The user will input something like + 5 6 And ...
7
votes
1answer
4k views

Becoming root from Python

In order to avoid the user having to explicitly prefix a script with sudo or su --command, I wrote the following: ...
7
votes
1answer
711 views

Merge sort and selection sort comparison taking too long

I have this python code that compares merge sort and selection sort, but it is taking "forever." ...
4
votes
2answers
5k views

Is this a reasonable Trie implementation?

http://en.wikipedia.org/wiki/Trie The basic idea is to support fast searches via prefix matching. In my implementation, I allow each node to store all of the words that match its given prefix, and ...
4
votes
5answers
2k views

single array or many single argument to call a constructor with params?

I am seeing it more and more. Which do you think works best and why? This: $config = array( 'param1'=>'abc' 'param2'=>'dfg' ); new Class($config); Or: <...
4
votes
1answer
232 views

Wrapper for dynamic behavior

I am writing a wrapper for dynamic behavior in C#. If I use GetMethod(), then an exception is thrown when there is more than one method (overloads). I figure it ...
11
votes
3answers
2k views

My own C++ Format function

I've never been satisfied with any of the possible sprintf()-like functions in C++: sprintf() is a C function and it's very ...
14
votes
0answers
1k views

PowerShell module for formatting objects using Razor

I managed to get something up and running, but I've no idea whether there are better ways to do this. I've spent all morning trying to figure out the best way to use parameters (allowing objects from ...
6
votes
3answers
1k views

PHP Table generation

I have been using the following function (in the kohana html class in a table) to generate tables. ...
10
votes
4answers
2k views

Change upper or lowercase vowels to [0,1,2,3,4] respectively and leave the rest the same

The objective was the following to be solved in Python: Given a string, def a function that returns another string with the vowels (upper or lowercase) replaced by 0,1,2,3,4 respectively. ...
7
votes
1answer
504 views

Find the Hardy–Ramanujan number using R5RS scheme

I remember once going to see [Srinivasa Ramanujan] when he was ill at Putney. I had ridden in taxi cab number 1729 and remarked that the number seemed to me rather a dull one, and that I hoped it was ...
3
votes
4answers
1k views

Days of life calculator for first-year mathematics students

I'm giving a lecture on basic programming to first-year mathematics students. The programming language is Java (defined by curriculum). Last week I gave the following task: Write a program, that ...
14
votes
10answers
12k views

Looping through a collection

In the situation where I am looping through a collection looking for an item, is it better practice to break before I return or ...
4
votes
1answer
580 views

User php class. Should I connect to DB in this class?

I have small Class which handles user's information. (name, surname, login, hash of password). Also this class can activate, register and login the user. This means I should connect to DB. Is it ...
7
votes
4answers
659 views

Managing part types and counts

Both functions look fairly similar to each other, but they are different in the type of string. I have 6 functions like this and all differ only in the "string cmd". Any ideas on how I can put it all ...
6
votes
3answers
1k views

Performance optimization for Linq To SQL

I have been working with C# for quite some time but relatively new to the concepts of lambdas and Linq. I was working with a Linq To SQL example and trying to write a generic solution for executing a ...
5
votes
1answer
909 views

CSV module in Ruby

I finished the Ruby chapter in Seven Languages in Seven Weeks. It tries to make you familiar with the core concepts of several languages rather quickly. Dutifully I did all exercises, but most likely ...
8
votes
1answer
1k views

Custom grep in Ruby

I finished the Ruby chapter in Seven Languages in Seven Weeks. It tries to make you familiar with the core concepts of several languages rather quickly. Dutifully I did all exercises, but most likely ...
8
votes
1answer
1k views

Idiomatic haskell database connectivity

In this post I asked about what would be idiomatic haskell database abstraction. I had been thinking for it a while, and the first answer was similar to what I had in mind, and I wrote a proof-of-...
2
votes
1answer
542 views

Simple octal reader macro in Common Lisp

As an exercise, I've implemented a simple reader macro in Common Lisp (using SBCL). It converts Octal (unsigned integers only) into numbers. Usage: * #z1234 668 ...
7
votes
2answers
1k views

Higher lower game in Ruby

I finished the Ruby chapter in Seven Languages in Seven Weeks. It tries to make you familiar with the core concepts of several languages rather quickly. Dutifully I did all exercises, but most likely ...
4
votes
3answers
813 views

Making a job completed, rolling back on error

I have the following construction in the program: ...
2
votes
2answers
1k views

PHP Output Block Defining and Best Practices

I've been rolling around several ideas or approaches in my head, and none seem any more useful or "right" than another. I'm sure this is extremely objective but I'm looking for a close-to-definitive ...
2
votes
0answers
402 views

Coercion with multiple arguments

From SICP: Exercise 2.82 Show how to generalize apply-generic to handle coercion in the general case of multiple arguments. One strategy is to attempt to coerce all the arguments to ...
4
votes
1answer
684 views

Parsing random phrases from a file

This essentially reads a specially-structured file from the scanner and then parses random phrases and prints them: ...
11
votes
7answers
4k views

Rock Papers Scissors in Python

I am a newbie to Python and have started object-oriented programming recently. I have implemented a "Rock Paper Scissors" application in OOP. I would like for you to evaluate my code, and tell me ...
10
votes
3answers
1k views

FTP Download Helper Method

I'm currently using an Open Source FTP library in all my projects as I've never managed to code a decent FTP Helper Library based on the C# 4.0 API. What do you think about this approach? I'm not ...
1
vote
1answer
225 views

Have I gone too far in factoring out repeated code in this example?

In a controller (PHP, CodeIgniter) I'm adding scripts & css to variables to be used in the view output. My initial coding looked like this: ...
7
votes
2answers
32k views

Is there a better way to search directories for a file or files?

Edit: The purpose of this method is to search a specific directory for a given file type, ex. (*.txt, *.pdb, *.exe") then move the file(s) to a given destination directory and delete the original ...
3
votes
2answers
623 views

PHP and Custom Functions

I am new to the world of coding as well as XHTML and PHP. As a way to gain more experience as well as to put theory into practice including a way to challenge myself, I put together the following code ...
3
votes
1answer
961 views

jQuery Plugin Review - wrapper for jQuery UI's tabs

This is a jQuery plug-in I've created that relies on jQuery UI's tabs plug-in. It adds some framework specific logic when setting up tabs: Fixes a bug in jQuery that appears when an id/class contains ...
4
votes
1answer
368 views

Display catalog product quantity

I have a simple quantity display function that runs for every product displayed in our catalog. The MaxQtyDisplay value is set in our web.config file. Part of me ...
8
votes
5answers
5k views

Aborting a program for invalid floating-point input

My friend does a bunch of Java work (commandline, still toying around) and I notice a bunch of try/catch blocks like this: ...
5
votes
1answer
4k views

Transactions and locking in Rails 3

I am new to Rails and have a system that needs to process transactions. A user can enter a transaction to which one or more users are tied. These users owe some amount of money to the person making ...
3
votes
2answers
177 views

Can I jump like this?

In my nested for loops below, it is sometimes necessary to exit the outer loop and then continue program execution. Since loop labels and other goto-like ...
5
votes
2answers
1k views

VB6: String Searching Performance

5 years ago, when i was in love with VB, I created this simple program to detect if a file is virus or not. What I'd like is to see if you can help me optimize it, ...
13
votes
2answers
7k views

Handling many networking exceptions in Ruby

What would be a prettier/faster way to do handling of multiple errors in Ruby? Here is the code I am working with: ...
3
votes
1answer
939 views

Huffman encoding successive-merge function

From SICP: Exercise 2.69. The following procedure takes as its argument a list of symbol-frequency pairs (where no symbol appears in more than one pair) and generates a Huffman encoding ...
3
votes
2answers
2k views

Encode-symbol for Huffman tree

From the text: Exercise 2.68. The encode procedure takes as arguments a message and a tree and produces the list of bits that gives the encoded message. ...
6
votes
1answer
4k views

Why is this code to paste into a DataGridView so slow?

...
7
votes
5answers
14k views

Comparing Color objects with == [closed]

This example comes from a code snippet posted on Stack Overflow: ...
6
votes
1answer
410 views

How and where to define a partial helper module

I want to split my helpers in different modules (and files), but I found some problems which I got around with the following solution: ...

15 30 50 per page