language-agnostic

How is "Is offline for maintenance" page implemented?

Occasionally when I try to open a site I will see a page saying smth like "This site is offline for maintenance" and then some comments follow on how long it would presumably take. Stack Overflow does that too. How does it work? I mean if the site is shut down who replies to my HTTP request and serves this page? ...

What is eager loading?

What is eager loading? I code in PHP/JS but a more generalised answer will be just fine. I saw a lot of questions regarding Java & Ruby, but i don't know any of these languages, and I find it hard to read code. I don't know whats supposed to do in the first place ...

How to calculate distance from a point to a line segment, on a sphere?

I have a line segment (great circle part) on earth. The line segment is defined by the coordinates of its ends. Obviously, two points define two line segments, so assume I am interested in the shorter one. I am given a third point, and I am looking for the (shortest) distance between the line and the point. All the coordinates are gi...

What are the Top 5 Languages to localize an app for?

I'm wondering, based on experience (and raw population data) which are the 5 "best" localizations for an application (iPhone app in this case). Note by localization I don't only mean language, but other customs such as date and currency formats, etc. My guess list would be as follows English French Spanish German Japanese How does y...

Guessing an unbounded integer

If I say to you: "I am thinking of a number between 0 and n, and I will tell you if your guess is high or low", then you will immediately reach for binary search. What if I remove the upper bound? i.e. I am thinking of a positive integer, and you need to guess it. One possible method would be for you to guess 2, 4, 8, ..., until you g...

What kind of sorting is this?

Say I have a list of integers, where each element is a number from 1 to 20. (That's not what I'm trying to sort.) Now, I have an array of "operations", where each operation: Removes certain (known) numbers from the list and Adds certain other (known) numbers to the list and Is unable to handle the list if it contains certain (known) n...

Extensible/Customizable Web Crawling engines / frameworks / libraries?

I have a relatively simple case. I basically want to store data about links between various websites, and don't want to limit the domains. I know I could write my own crawler using some http client library, but I feel that I would be doing some unnecessary work -- making sure pages are not checked more than once, working out how to read ...

Which datastructure is appropriate for this situation?

I'm trying to decide which datastructure to use to store key-value pairs when only features needed are insertion lookup Specifically, I don't need to be able to delete pairs, or iterate through keys/values/pairs. The keys are integer tuples, the values are pointers (references, whatever). I'm only storing a couple million pairs spr...

How to improve your reading and understanding of code?

For the past 5 or so years, I've been working with vastly different projects and systems. Code for those projects differed significantly in terms of quality, style, size. I saw examples of both: clean as well as disgusting 1000 lines functions and if conditions code. I still don't feel quite competent at reading other people's code,...

What is the single most effective thing you did to improve your QA skills?

Looking back at my career and life as a QA engineer, there were plenty of different ways I improved my QA skills and testplans- reading other people's testplans, readings specs, reading books, listening to podcasts, watching screencasts. My question is: What is the most effective thing you have done that improved your QA skills? What w...

Sharing objects

Imagine that I have a nice Deck class, in the best OO fashion. It has Cards, which have a Suit and a Rank, it has a Shuffle method, and so on. Now, I'm going to have a lot of concurrent instances of Deck (say this is a casino). The question is: Should there be a different instance of every card across all the decks? ...

Why isn't every type of object serializable?

Why isn't every type of object implicitly serializable? In my limited understanding, are objects not simply stored on the heap and pointers to them on the stack? Shouldn't you be able to traverse them programatically, store them in a universal format and also be able to reconstruct them from there? ...

Is it possible to calculate median of a list of numbers better than O(n log n)?

I know that it is possible to calculate the mean of a list of numbers in O(n). But what about the median? Is there any better algorithm than sort (O(n log n)) and lookup middle element (or mean of two middle elements if an even number of items in list)? ...

How are nested capturing groups numbered in regular expressions?

Is there a defined behavior for how regular expressions should handle the capturing behavior of nested parentheses? More specifically, can you reasonably expect that different engines will capture the outer parentheses in the first position, and nested parentheses in subsequent positions? Consider the following PHP code (using PCRE reg...

What is name mangling, and how does it work ?

Please explain what is name mangling, how it works, what problem it solves, and in which contexts and languages is used. Name mangling strategies (e.g. what name is chosen by the compiler and why) a plus. ...

Generating random 6-character strings

How many possible words of length 6 can I generate from the English lower case alphabet, if each word starts with a random consonant, and after that vowels and consonants alternate? What if I add digits to my alphabet? See also this question. ...

which data model storage strategy ?

I am trying to come out with a good design for the storage of a data model. The language is python, but I guess this is fairly agnostic. At the moment I envision three possible strategies: Object database The datamodel is a network of objects. When I create them, I specify them as descendant from a persistence object. Example: class ...

Using Rabin-Karp to search for multiple patterns in a string

According to the wikipedia entry on Rabin-Karp string matching algorithm, it can be used to look for several different patterns in a string at the same time while still maintaining linear complexity. It is clear that this is easily done when all the patterns are of the same length, but I still don't get how we can preserve O(n) complexit...

Learning garbage collection theory

I want to learn the theory behind garbage collection. How do i go about it? The obvious answer is - a compiler textbook... The question is, is it necessary to learn lexical analysis, parsing and other stuff that usually precedes garbage collection in a text? In short, what are the prerequisites to learning about Garbage collection theo...

Other ways of protecting cookies

I've been thinking a lot about this recently, and I wanted to know if anyone has thought of/implemented any intuitive ways of securing cookies from manipulation. I've always used the "sign it with a hash and check against the hash later" approach, but it doesn't strike me as a particularly brilliant way of going about it, and just like a...