language-agnostic

Any reason to use SecureZeroMemory() instead of memset() or ZeroMemory() when security is not an issue?

This MSND article says SecureZeroMemory() is good for cases when sensitive data stored in memory for a while should be for sure overwritten as soon as possible when no longer needed. Answers to this SO question explain why this can make a difference. Now is there any sence in using SecureZeroMemory() for initializing just every memory b...

Why do programming languages round down until .6?

If you put a decimal in a format where has to be rounded to the nearest 10th, and it is: 1.55, it'll round to 1.5. 1.56 will then round to 1.6. In school I recall learning that you round up when you reach five, and down if it's 4 or below. Why is it different in Python, et al. Here's a code example for Python 2.6x (whatever the latest v...

What is the correct term for referring to a path and filename?

I want to use the correct term to make my API as intuitive as possible, so when a parameter is expected to be a full path and filename (ex "C:\Users\Max\Documents\MyDocument.txt") what is the correct term? filename - that would just be MyDocument.txt, right? path - that would just be C:\Users\Max\Documents, right? What should I use ...

How to Check Authenticity of an AJAX Request

I am designing a web site in which users solve puzzles as quickly as they can. JavaScript is used to time each puzzle, and the number of milliseconds is sent to the server via AJAX when the puzzle is completed. How can I ensure that the time received by the server was not forged by the user? I don't think a session-based authenticity to...

Compiling nested mutually recursive function

I'm creating a toy dynamic language (aching towards javascript) and while my implementation is on top of the DLR, I figured the solution to this problem would be pretty language/platform agnostic. I have no problem with compiling recursive functions, or mutually recursive functions that exist next to each other. But compiling nested mut...

What's a good introductory book on Data Structures

Possible Duplicate: What is a good book to study data structures in C? Please recommend a good beginner-intermediate book on data structures. Preferably a printed book, with code in C (or language-agnostic). ...

Drawing abstract canvas

I'm planning to write a diagram editor-style application, where you organize objects on a canvas. This application will need to support setting viewport, zooming, cropping and a lot of other standard features of such a graph style application. I'm looking for toolkits or frameworks which could supports drawing in a standard mathematical ...

Construct an Iterator

Let's say you want to construct an Iterator that spits out File objects. What type of data do you usually provide to the constructor of such an Iterator? an array of pre-constructed File objects, or simply raw data (multidimensional array for instance), and let the Iterator create File objects on the fly when Iterated through? Edit: ...

What are most common programming scenarios encountered during programming Web Applications ?

What are most commonly faced programming scenarios while developing Web/Enterprise Applications ? Note: Include common programming scenarios which would occur more frequently across all layers of Web/Enterprise Applications : Frontend/Middle/Backend. ...

Idiom vs. pattern

In the context of programming, how do idioms differ from patterns? I use the terms interchangeably and normally follow the most popular way I've heard something called, or the way it was called most recently in the current conversation, e.g. "the copy-swap idiom" and "singleton pattern". The best difference I can come up with is code w...

Highlight block scope under point ?

I remember seeing this functionnality while editing elisp code, using a config cloned from someone on github. However, I can't find it anymore, and would especially like to know if this feature is possible using other major modes (especially javascript, ruby, and maybe nXhtml). ...

worth to learn groovy?

the question im asking, is it worth to learn a new language like groovy? cause if i learn groovy, it feels like i code in groovy and not java. and how smart is that when i have to be good in java to code desktop applications too in the future. so if i use groovy a lot for web applications, i will just be worse and have to start over to b...

Get adjacent elements in a two-dimensional array?

I have a two-dimensional array, say 0 0 0 0 0 0 2 3 4 0 0 9 1 5 0 0 8 7 6 0 0 0 0 0 0 And i need to get all the numbers adjacent to 1(2, 3, 4, 5, 6, 7, 8, 9) Is there a less ugly solution than: topLeft = array[x-1][y-1] top = array[x][y-1] topRight = array[x+1][y-1] # etc Thanks! ...

What should I put in header comments at the top of source files?

I've got lots of source code files written in various languages, but none of them have a standard comment at the top (sometimes even across the same project). Some of them don't have any header comment at all :-) I've been thinking about creating a standard template that I can use at the top of my source files, and was wondering what fi...

Are there any patterns or is there any standard terminology for inheriting data/objects?

I have a class A that has a collection of objects of Class B. Class A can also 'inherit' (for lack of a better term) the collection of objects of Class B from other instances of Class A. To model this, instances of Class A point to other instances of Class A (I control for circular references). A simplified concrete example might be th...

How do disk pointers work?

Suppose I want to store a complicated data structure (a tree, say) to disk. The internal pointers which connect nodes in my data structures are pointers, but I can't just write these pointers to disk, because when I read the data structure back the memory locations will have changed. So what is the right way to store the pointers on di...

How can you efficiently remove duplicate characters from a string?

Is it possible to remove duplicate characters from a string without saving each character you've seen in an array and checking to see if new characters are already in that array? That seems highly inefficient. Surely there must be a quicker method? ...

Expression to calculate a field within a loop

I basically have a few variables 0 < na < 250 0 < max <= 16 nb = (na + max - 1) / max n has the following characterstics 0 <= i < nb - 1 => n = max i = nb - 1 => n = na - i * max Is there an easy way to do this without the ternary operator? for (i = 0; i<nb;i++) { n = ((i + 1) * max > na ? na - (i * max) : max); } Examples...

Standard Pattern for Iterating Over Loop and Printing Start and End Tags

Hello all, This is a problem I have run into before and I have yet to find an elegant solution, so I thought I would ask for SO's help. I am iterating through an array and printing off some information from that array and having trouble figuring out how to print my start and end <div> tags. Below is an example table and the desired out...

Can a variable like 'int' be considered a primitive/fundamental data structure?

A rough definition of a data structure is that it allows you to store data and apply a set of operations on that data while preserving consistency of data before and after the operation. However some people insist that a primitive variable like 'int' can also be considered as a data structure. I get that part where it allows you to store...