language-agnostic

Drag anything onto the desktop

Hi All Is there a way that we can drag text or images onto the desktop itself from within another application? Say for example there is some text in my app, and the user wants to drag it right onto the desktop, and be able to move it around and edit it right on the desktop... Would this be possible at all? Thank you :) I mainly use C...

What compilers can inline indirect function calls?

The LDC D compiler for LLVM can inline indirect function calls under some circumstances if it can prove that the target is statically known. Here's a toy example (in D) of where this might happen: void main() { uint num; void incNum() { num++; } auto myDelegate = &incNum; myDelegate(); } In this case, ev...

Simple 1-D particle swarm optimization algorithm for a noisy environment

I'm experimenting with particle swarm optimisation and am trying to determine the best approach for the following simple scenario: Optimizing a 1-dimensional function (i.e. particles are moving along a single line) The function to be optimised can be sampled at any point on the line The "value" sampled for each position is very noisy T...

creating a library in a single language with interfaces to everything else

Our business currently revolves around the development of a library, which can be used in a wide spectrum of industries (desktop, mobile, web and embedded). At the moment we only have customers within the desktop and web world and we already see that we are basically having to duplicate our code across multiple languages (c#, java and c+...

What features should a new SQL-based Rapid Development tool have?

I am interested in developing a new SQL-based RDS which can generate prototype CRUD-oriented 4GL code which can then be easily customized. So I am looking for opinions, suggestions, etc. in what features should a new RDS have? I have looked at several products. FileMaker is more or less the type of product I'm looking for, but it's no...

Code Golf: Happy Primes!

It's Sunday, time for a round of code golf! Challenge Write the shortest source code by character count to determine if an input number is a "happy prime", "sad prime", "happy non-prime", or "sad non-prime." Input The input should be a integer that comes from a command line argument or stdin. Don't worry about handling big numbers, ...

Where to find what O(n^2) and O(n) etc means?

I've been noticing answers on stack overflow that use terms like these, but I don't know what they mean. What are they called and is there a good resource that can explain them in simple terms? ...

Is there a publicly available API that does time zone conversion?

Does anyone provide an 3rd party API that does time zone conversions? I'm thinking of doing it for a site, just to make it easier to handle all the intricacies. It is a multi-zone scheduling kind of applicaiton and time zones need to be handled perfectly. I dont think timeanddate.com does it, but does anyone else? Reliabily? ...

Converting a number to a string and back

I have always used streams, printf, string(x) or whatever the language in question offered to convert numeric types to a string or back. However I have never really considered how this is actually done. I searched around on Google, but all the results are just to use those varies methods, and not how the conversion is really done behind ...

What's the best programming design for localizing an application?

i.e. Multi-language messages, screen captions, currency/date formats, etc. ...

Given grid coordinates, how can I determine the center point of a cell which they fall within?

I'm working on a simple board game using Appcelerator Titanium for iPhone (javascript - not that it matters for this question really). My problem isn't really language-specific, it's more of a general programming and math question. I have a grid of "cells" that is 10 columns by 10 rows (100 cells). It's a board game, like checkers/drau...

Rotate a circle around another circle

Short question: Given a point P and a line segment L, how do I find the point (or points) on L that are exactly X distance from P, if it guaranteed that there is such a point? The longer way to ask this question is with an image. Given two circles, one static and one dynamic, if you move the dynamic one towards the static one in a str...

good approach in tracking data for unregistered users

This is how the system works: I have a catalog of items. An guest user can choose to add an item from the catalog to what we call the inquiry bin. The system keeps track of the items added to the inquiry bin for that particular session. The user can delete items from the bin. I was wondering what may be the most optimal way of storing ...

Solution to programmatically generate an export script from a directory hierarchy

I often have the following scenario: in order to reproduce a bug for reporting, I create a small sample project, sometimes a maven multi module project. So there may be a hierarchy of directories and it will usually contain a few small text files. Standard procedure would of course be to create a zip file and send that. But on some maili...

Presentation patterns to use with Ext JS

Which presentation patterns do you think Ext JS favors or have you successfully used to achieve high testability and also maintainability? Since Ext JS component instances usually come tightly coupled with state and some sort of presentation logic (e.g. format validation for text fields), Passive View is not a natural fit. Supervising P...

How to terminate a program when it crashes? (which should just fail a unit test instead of getting stuck forever)

Our unit tests fire off child processes, and sometimes these child processes crash. When this happens, a Windows Error Reporting dialog pops up, and the process stays alive until this is manually dismissed. This of course prevents the unit tests from ever terminating. How can this be avoided? Here's an example dialog in Win7 with the...

What factors do I need to consider to determine whether I should "trust the defaults" with respect to encryption

Background With respect to cryptography in general, the following advice is so common that it may even be platform and language-agnostic. Cryptography is an incredibly complex subject which developers should leave to security experts` I understand and agree with the reasoning behind this statement, and therefore follow the advice when...

What is the difference between message-passing and method-invocation?

Is there a difference between message-passing and method-invocation, or can they be considered equivalent? This is probably specific to the language; many languages don't support message-passing (though all the ones I can think of support methods) and the ones that do can have entirely different implementations. Also, there are big diffe...

Web code re-use, How do you organize your scripts snippets?

In every web project most of the time the code is just being re-use. From the drop-down navigation, Rotating Header to CSS Grids. This process makes your workflow more faster and more efficient. I'm wondering how do people organized those scripts? Where do you store it? How do you break it down into category (javascript,css,php etc.)? so...

Any examples of very shocking undefined behavior?

People often comment that a program can legitimately respond to undefined behavior by deciding to reformat your hard drive. However, in practice undefined behaviors in most languages do something rather unsurprising, for example: Fail (e.g. crash, throw an exception, or otherwise interrupt execution). Refuse to compile. Yeah, that ...