Pages

Tuesday, March 24, 2015

Bell Labs Innovation

From Trust Me I'm a Scientist. The article is about audio sampling rates, but this passage stood out.

The mid-20th century was a heady time at Bell Laboratories. Just before its closing, it employed upward of 25,000 people, dedicated entirely to research and development.

Their innovations were enormous ones, and they lie at the root of the very device you are reading this on: The transistor, the laser, semi-conduction, the solar cell, television, C++ programming, the fax machine, and by the 1960s, the goddamn video phone.

For the sake of contrast, Google, one of our greatest innovators of today, employs roughly 50,000 people across all of its departments, and it’s greatest offerings have been, well… a slightly improved version of the fax machine and the videophone.

This passage is perhaps too dismissive of Google, but it is amazing how one of the technological powerhouses of our era pales in the face of Bell Labs.

Math & Code in Blogger

I use Blogger because of its simplicity and general lack of features. I’ve installed WordPress, and for me it’s a quagmire of tinkering and playing with plugins and themes, all in avoidance of writing. Blogger’s lack of features is itself a feature in the same way that full-screen text editors are a feature: it blocks out lots of potential time wasters.

Having said that, there are a few features I miss on Blogger, namely syntax highlighting and math formatting. Luckily there are a couple of easy javascript libraries that can do the job.

Syntax Highlighting with Google Code Prettify

Google has a javascript library for code syntax. It’s pretty basic in its formatting options, but good enough for me. Most importantly, installation is simple. I simply point to a javascript library hosted by google. Installation requires one line in the template:

<script src='https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js'/>

This add a css class, prettyprint. Use it in a pre tag for a code block. This HTML code:

<pre class="prettyprint">
int main(argc, argv[]) {
    printf("Hello, world!\n");
    return 0;
}
</pre>

is formatted like this:

int main(argc, argv[]) {
    printf("Hello, world!\n");
    return 0;
}

Tag inline code with <code> so that <code class="prettyprint">int i = 0;</code> becomes int i = 0;

Most "normal" (i.e., C-like) languages are recognized with the default. If you like oddball languages, like I do, you might need to specify your language. For example, I specify Scheme when I import the javascript like this:

<script src='https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=scm'/>

and then again specify the language in side the class

<code class="pretty-print lang-scm">
(define (area-of-disk r) 
  (* 3.14 (* r r)))
</code>

Becomes

(define (area-of-disk r) 
  (* 3.14 (* r r)))

I stick with the default style, which is pretty subtle. If you like more emphatic highlighting, the README has instructions of changing themes and other options like line numbering. It also contains the definitive language list.

Math Formatting with MathJax

I don't do a lot of math, but when I do it's important to me that the notation is clear.MathJax is a javascript library to format math. If you use their CDN, installation is one line in the Blogger template:

<script src='//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' type='text/javascript' />

Equations are delimited with \[ \]. Now by entering this:

∖[ x = ∖frac{-b ∖pm ∖sqrt{b^2 - 4ac}} {2a} ∖]

You'll get this:

\[ x = \frac{-b \pm \sqrt{b^2 - 4ac}} {2a} \]

Inline latex is delimited with \( \) so that ∖(e = mc^2 ∖) becomes \( e= mc^2 \).

I like working with MathJax so much, it makes me want to include more posts with math.

Drawbacks

One drawback of this method is that you're entering a lot raw HTML in <code> and <pre> tags. It would be nice

Another drawback is that every page is loading the CSS and JavaScript for code and math on every page, regardless of whether there's any need for it or not.

Finally, while MathJax is well maintained, Google Code Prettify is a bit less active. As I write this, the last commit to the subversion repository was Mon, 03 Mar 2014. I won't be holding my breath for a Swift lexer.

Wednesday, December 24, 2014

Why is the Mac DHCP Client so Awesome?

Once upon a time I worked in Apple support, even before the organization was known as AppleCare. I authored a Knowledge Base article that documented the behavior of the Mac DHCP client in Mac OS 8 and 9. It was an implicit answer to the question, “Why don't Macs behave like the other clients?” At the time that meant, “Why don't they behave like Widows?”

With that background, I’m happy to see the article, Rapid DHCP: Or, how do Macs get on the network so fast? These days, the Mac DHCP client kinda kicks ass.

Friday, December 19, 2014

Privacy Matters

Gizmodo on the Sony Hack:

The most painful stuff in the Sony cache is a doctor shopping for Ritalin. It's an email about trying to get pregnant. It's shit-talking coworkers behind their backs, and people's credit card log-ins. It's literally thousands of Social Security numbers laid bare. It's even the harmless, mundane, trivial stuff that makes up any day's email load that suddenly feels ugly and raw out in the open, a digital Babadook brought to life by a scorched earth cyberattack.

These are people who did nothing wrong. They didn't click on phishing links, or use dumb passwords (or even if they did, they didn't cause this). They just showed up. They sent the same banal workplace emails you send every day, some personal, some not, some thoughtful, some dumb. Even if they didn't have the expectation of full privacy, at most they may have assumed that an IT creeper might flip through their inbox, or that it was being crunched in an NSA server somewhere. For better or worse, we've become inured to small, anonymous violations. What happened to Sony Pictures employees, though, is public. And it is total.

The next time you hear about the death of privacy, or some idiot scolds you by saying, “If you have something that you don't want anyone to know, maybe you shouldn't be doing it in the first place,” remember this. There's lot of little niggling things we do every day that need to stay private just to keep our daily lives going.

Stanford Algorithms Course

Stanford is offering their Algorithms I course again (via Coursera): Algorithms: Design and Analysis, Part 1

I took it the first time it was offered, and it was a fantastic course. They take the "analysis" part seriously, covering big-O notation fairly rigorously and covering the Master Method. It's fairly mathematical. I ran into problems when we covered probabilistic algorithms, as I never really studied probability mathematically. It will take a lot of your time, but if you can devote enough time to it, it will be worth it.

Wednesday, December 17, 2014

Blogger Template Formats

I looked into the Blogger template syntax, wondering if I could make a simple template on my own, using Bootstrap or something like that. Google, it turns out, has little documentation. They have a few docs in their support section, but nothing like developer documentation. This one, for example, covers two tags: b:section and b:widget. I can see others in the template: b:loop, b:if, b:else. I can make a good guess about what these do, but I shouldn't have to.

The template is a standard XML document with some blogger-specific tags. Seem like a good system. But what tags are available? What do they mean? Normally, the XML declaration has a source for such questions. Here's the tag from my current template.

<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

Guess what? All those links are broken. So maybe I won't put any more time into this after all. It hardly inspires confidence. I remember what happened with the last Google product I really liked. It's a shame, because I like Blogger. It's one case where my interests align pretty well with Google's.

Later, that same decade…

A while back I started this blog to keep track of my progress through SICP. Then I put that project on hold. The problem with putting a project like that on hold is that you forget your progress, then have to backtrack. That kills the fun. I guess I'm saying that I abandoned that project. At the least, you shouldn't expect any more SICP posts here. If I start it up again, consider it a bonus.

It seems a shame to kill the blog just because I'm no longer working through SICP. So I'm going to start back, with a much less focus. I'll probably stick to the geekier end of things, but I'm no longer using this exclusively for study notes.