Cartesian products in bash?
Given a directory with 2 sub-directories, A and B, this snippet will output: quartz ~/>; ls A B quartz ~/> ls -d1 */../*/ | sed ‘s;/../;->;g;s;/;;g’ A->A A->B B->A B->B
Weighted sampling of items in Python
Let’s say you need to produce realistically distributed random selections from a list. For example, let’s say you’re writing a US meteor simulation game, and want to select the state the meteor will land in. Assuming that the impact site will be completely geographically random, then the following example will select a state, with a [...]
Less.css and Controlling Element Size
Those of you (implicitly or explicitly) familiar with the css Box model will know that managing the width/height of elements that have padding applied can be a pain. Getting that number just right after adding borders, subtracting padding, and failing to finger-count is just boring, and error-prone, and that’s before the guy you’re designing for requests that [...]





