language-agnostic

What does it mean when `Ex` is added to a function/method name?

I don't work with the Windows API much, but I've seen it used there as well as occasionally in a codebase here at work. ...

how to represent a n-byte array in less than 2*n characters

given that a n-byte array can be represented as a 2*n character string using hex, is there a way to represent the n-byte array in less than 2*n characters? for example, typically, an integer(int32) can be considered as a 4-byte array of data ...

When designing a data structure, should helper methods be accessible to other users?

I had a talk with my professor today about the layout of the Chunklist data structure that we've been working on. Basically, it is a hybrid of a ordered circular linked list with each node containing an arraylist. Since this is an ordered list, the add() method is pretty complicated, so I wrote a nested class to hold the helper methods...

I need advice for a desktop app

I'm creating some uml diagrams to clear my mind about a desktop app I'm about to create. I've never done desktop app development, I'm a bit confused on how to proceed. I need to capture the Stamp keypress and then after that access the clipboard (both write and read). I would like to provide the user with a package that he can install ...

How unique is PHP's __autoload()?

PHP's __autoload() (documentation) is pretty interesting to me. Here's how it works: You try to use a class, like new Toast_Mitten()(footnote1) The class hasn't been loaded into memory. PHP pulls back its fist to sock you with an error. It pauses. "Wait," it says. "There's an __autoload() function defined." It runs it. In that function...

How to have procedural code wait for user input from a GUI before continuing?

In my program there is a complex calculation that requires the user to evaluate intermediate results. This works well in a command line application (which is what my code looks like now) because the interactive prompt halts the program execution until the user hits enter. The command line code looks something like this: def calculate(...

Should I assume that ^[a-z]{2} will match any locale?

I'm implementing the routing and i18n part of my framework. I'm wondering if I should assume that ^[a-z]{2} Will be a locale, and if so use it. Or should I make the user populate a list with languages? Eg: supported = [ 'en', 'es', 'it', 'ru', ] So the developer has to manually define languages. And for the record, 90% of the sit...

Sending money from [SomePaymentProcesingCompany] to bank account

The Imaginary Scenario: The Affiliates earn money on my website by selling items/services/widgets to their clients. You can think of it as a simple affiliate program. This money is stored in a single account until the Affiliate requests their money. The Affiliates don't want to wait for a check to come in the mail; they want to log-on ...

Online syncing between iPhone, iPad, Mac, etc.

I have plans to set up a website where people can create an account and create their own content. This content consists of text, images and likely audio. Users should also be able to download an iPhone, iPad, Mac or even a Windows app that syncs with their online content, so they can view their content offline, possibly make changes to ...

Throwing cats out of windows

Imagine you're in a tall building with a cat. The cat can survive a fall out of a low story window, but will die if thrown from a high floor. How can you figure out the longest drop that the cat can survive, using the least number of attempts? Obviously, if you only have one cat, then you can only search linearly. First throw the cat fr...

Wich type of disclaimer i need to use for my app?

I am currently working on an application that generates code dynamically depending on the options wich select the final user. I'm looking for a disclaimer-warning text, that i can include in the header of the code generated by my application, ideally should also indicate that there is no liability for any damage or loss of data . someth...

Variable Declaration Versus Error Checking: Which Comes First?

When writing a function I always have this confusion whether to check for errors first and declare the variables later (or) assign the parameters to local variables and then check for errors. Which of the following way is preferred and why? I usually stick to the first type. void DoSomething1(Object x, Object y){ // All sort of error...

Tips to understand huge monolithic code

I am looking for some good tips to track and understand huge codebase. I usually start at the top and end up getting lost in some nitty-gritty details of a function after a while. Since I would have already been many levels deep, the process of backing up and getting on track is tiresome and exhausting. How do you keep track of the trail...

Learning about scalability

I've decided I need to learn more about building scalable solutions. Given almost any programming problem, I can build something to take care of it. Unless that problem is "this needs to handle a billion hits a day". Where do I start? Websites, books, articles, etc are all appreciated. My primary languages of choice are currently Ja...

access os x IME capabilities from code

Hi, How can I access the IME configuration of an OS X system? I would like to get the key to enable/disable IME input for instance, get the composition window position, selected candidate etc. Any language is fine, I just want to know how such a thing is possible, thanks! ...

Difference of sums

I take no credit for this challenge at all. It's Project Euler problem 6: The sum of the squares of the first ten natural numbers is, 1^(2) + 2^(2) + ... + 10^(2) = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^(2) = 55^(2) = 3025 Hence the difference between the sum of the squares of the first ten ...

Best practise for adding a bidirectional relation in OO model

I'm struggling to come up with a good way of adding a bidirectional relation in OO model. Let's say there is a Customer who can place many Orders, that is to say there is a one-to-many association between Customer and Order classes that need to be traversable in both directions: for a particular customer it should be possible to tell all...

Find tunnel 'center line'?

Hi All, I have some map files consisting of 'polylines' (each line is just a list of vertices) representing tunnels, and I want to try and find the tunnel 'center line' (shown, roughly, in red below). I've had some success in the past using Delaunay triangulation but I'd like to avoid that method as it does not (in general) allow fo...

How do you decide to learn a new language? And how do you begin with it?

This is a poll. How did you decide to learn a new language? I have always been in a situation which required me to use a particular language and that's how I got introduced to the language I now code in. Secondly, whenever I start with a new language I get stuck with a slow introduction to if, while, for et al. in the beginning. It is ...

Efficient random sampling of constrained n-dimensional space

I'm about to optimize a problem that is defined by n (n>=1, typically n=4) non-negative variables. This is not a n-dimensional problem since the sum of all the variables needs to be 1. The most straightforward approach would be for each x_i to scan the entire range 0<=x_i<1, and then normalizing all the values to the sum of all the x's...