the whole world burns

Archive for category 'programming'

Untrusted - a user JavaScript adventure game

 #

Cute RPG where limited parts of the level code itself can be overwritten to solve puzzles (e.g., in one level, changing the behaviour of a door such that opening it does not remove the key from the player's inventory).

alert(1) to win - JavaScript injection game

 # [via]

Fun game of practical XSS. Some amazing tricks there and I am confident I have left some of these holes open in the past.

Xerox scanners randomly alter numbers in scanned documents

 #

Incorrect application of JBIG2 compression (which builds a dictionary of image "patches" such that similar areas can be compressed into a reference to a single patch) apparently leads this Xerox scanner to silently mangle documents -- the patch size is such that it confuses 6, 8, and perhaps other glyphs.

HUSL - Human-friendly HSL

 # [via]

HSL is problematic for uses such as randomly generating colour schemes because the human eye does not perceive all hues the same way. With HUSL it is much easier to, say, compare the lightness of two colours to determine if there is adequate contrast. Very interesting!

Falsehoods Programmers Believe About Names

 #

From "People have exactly one canonical full name" to "People have names": names are hard.

On variable naming conventions

 #

Isaac Schlueter:

[O]ur conventions for naming things should take into consideration the limitations of the human brain. The length of a variable's name should be proportional to the distance between its definition and its use, and inversely proportional to its frequency of use.

Global config setting that gets specified once and used in 4 places throughout the program? 10-20 characters is probably appropriate. Might wanna go with UPPER_SNAKE_CASE to make it stand out a bit more, even.

Iterator variable that you define in a 3-line for loop and then never see again outside of it? Call it "i".

Another way to look at this: The first time you meet someone, you learn their full name. When discussing them with someone else who knows them, you use just a single name. If they're standing right there, you don't bother using their name, but just make eye contact, and maybe a "Hey". Should be the same way with variables.

Python Logging 101

 #

Easy introduction to the Python logging module by its author. Short version: it's great.

A zip file quine

 # [via]

SPOILERS: the zip specification is crazy.

coolest FizzBuzz solution yet

 # [via]

Hiding the hard work in a magic number:

(1..100).map {|i| srand(1781773465) if (i%15)==1; [i, "Fizz", "Buzz", "FizzBuzz"][rand(4)]}

Context Free Art

 # [via]

A language for creating generative art.

Lamby's Law of Distributed Systems

 #

Some people, when confronted with a problem think "I know, I'll make it distributed!" Now they have 2 million problems.

Small things, links and miscellany, sparkling with light. Sam's tumblelog.

Related Tags