Posts

New Samuel: a font derived from Morse code

Image
New Samuel is a font by Aurelian Hallhuber that he derived from Morse code (Samuel is one of Morse ’s given names). Creating New Samuel The following steps were used to create the font: In Morse code, each of the 26 letters of the basic Latin alphabet is encoded via at most 4 signals (dot or dash). Write those dots and dashes into a 2×2 matrix, starting at the bottom left cell, continuing counter-clockwise. Create a square whose corners encode what’s in the matrix: If a cell is empty then the corner is a single line (e.g. / for the top left corner). If a cell contains a dot then the corner is round. If a cell contains a dash then the corner is angular. Add features to these squares to make them recognizable as characters. As a result, you get a font whose characters reflect their Morse code combinations. The following diagram illustrates the process: This is the full alphabet: Morse code signals: more than bits 4-signal morse codes give you more combi...

JavaScript puzzle: equal, but not the same

The following puzzle has been posted on Reddit by davvblack: What are the values of x and y , given the following interaction? > x === y true > 1/x > 1/y true Show answer x is +0, y is -0. +0 and -0 are the only two values that are not the same, but are still considered strictly equal [1] . They can only be distinguished indirectly, by applying a mathematical operation to them that produces distinguishable results. Dividing 1 by zero is one of several operations that does so: > 1/-0 -Infinity > 1/+0 Infinity The infinities are distinguishable: > -Infinity === Infinity false Further reading: “ Stricter equality in JavaScript ” explores more consequences of strict equality’s special treatment of +0, -0 and NaN . “ JavaScript’s two zeros ” provides more information on the two zeros. For example, other ways than the above for distinguishing them.

A few thoughts on iTunes 11

Apple recently released a new version of iTunes , iTunes 11. In the words of John Gruber (for Daring Fireball): There are redesigns and there are redesigns . This one’s the real deal. It’s not a rewrite though. Clearly, in its heart, under the hood, this is still the same iTunes. It’s what you see [...] that’s all new. It was time. The old design felt bloated and cluttered. Two general thoughts: iTunes has effectively been split into three applications: the iTunes Store, the Library and iOS device management. iOS device management is only reachable from the Library and could thus be considered a sub-application, but it still exsists in a separate window. I love it. Previously, you had a kludgey integration via the sidebar, now there is a clear separation of responsibility. That opens up the possibility of having separate apps or even of a web-based iTunes Store. Knowing Apple, the latter is not likely, but it would still offer many advantages [1] . I like the user inte...

Using ES6 template strings for regular expressions

ECMAScript 6 template strings [1] give us multi-line raw (backslash has no special meaning) string literals and interpolation. But they can also be tagged, in which case a library can determine the meaning of their content. Steven Levithan has recently given an example of how they could be used for his regular expression library XRegExp . (As an aside, XRegExp is highly recommended if you are working with regular expressions. You get many advanced features, but there is only a small performance penalty – once at creation time – because XRegExp compiles its input to native regular expressions.) Without template strings, you write code such as the following: var parts = '/2012/10/Page.html'.match(XRegExp( '^ # match at start of string only \n' + '/ (?<year> [^/]+ ) # capture top dir name as year \n' + '/ (?<month> [^/]+ ) # capture subdir name as month \n' + '/ (?<title> [^/]+ ) # capture base name as tit...

Long Ago When the World Was Ending

Image
These days, it is hard to escape the end times predictions and their prognosticators.   The most recent is of course, the end of the Mayan calendar t his month.   Cable news and websites, always eager to grab public attention with frightening headlines, have been quick to trumpet the coming cataclysm.   History tells us that end of the world stories are common in every age, but one event stands out as a point when such dark imaginings had roots in some very scary current events. The frightful stories began as rumors.   Ships washed up on shore with the entire crew dead at their posts.   Some made it into port with sailors dead and dying, telling stories of whole towns wiped out, of empty cities in the east, thousands of bodies dead and left to rot in the streets.   Survivors reported strange, hooded and cloaked figures roaming the fields, some carrying scythes.   They walked through the grain, ripened and ready for harvest, swinging their blades, ye...

I’m the new JavaScript Weekly editor

Update 2014-04-11: I stepped down as editor of JavaScript Weekly, I had a fun 15 months, but now need to focus on Ecmanauten , my company that provides all kinds of JavaScript training. JavaScript Weekly (JSW) is a popular JavaScript email newsletter. It is reaching 35,000 subscribers and published by Cooper Press (along with several other developer-related newsletters). Peter Cooper, its creator and editor, has hinted at passing the torch to a mysterious new editor for a while. We can now finally reveal who it is: Starting with this Friday’s (Dec 7) issue, I’ll edit JSW. Peter will remain active in the background, doing quality control, suggesting links, etc. But most of the editorial work will be done by me. I’ve always been a fan of the format and have recommended it to everyone interested in JavaScript: With the rampant information overload these days, having curated content is important. Peter brought a level of polish and precision to this publication that made it a pleasure ...

A new way of delivering Retina images on the web

Recently, high-resolution screens (Apple calls them Retina displays) have become popular – first on cell phones, then on tablets and now on laptops. I have been waiting for those for literally decades: all other computer components (memory, processor speed, etc.) improved predictably, but screen resolutions did not get much better over the years. The problem for web developers is that things look nicely on these displays if resolution-independent mechanism are used: fonts, vector graphics, CSS effects, etc. However, with bitmap graphics, you are forced to deliver images with many more pixels. That has the potential of greatly slowing things down on the web if you are using a Retina device. Daan Jobsis has found an interesting solution: Use a high-resolution JPEG image, but but with an extreme compression rate (e.g. 75%): [...] this image was razor sharp. The difference is even noticable on the iPad 1, 2 and normal computer screens. How bizarre, the filesize is smaller than the orig...