July 2011
1 post
4 tags
WatchWatch
Algorithms That Govern Our Lives Turntable.fm defies this trend, and that’s why it’s so good. A minor victory against our algorithmic overlords.
Jul 6th
9 notes
April 2011
1 post
Apr 23rd
4 notes
June 2010
1 post
3 tags
npm install jison
Tinkering with new projects should be easy. You should be able to click a link or invoke a command and BAM, there goes your Sunday afternoon. I’m not sure how many people build parsers on the weekend, but hey, Jison is easy to install now anyway. If you’re using Node.js you should already have the excellent npm installed. If not, that’s easy: curl -L...
Jun 15th
April 2010
3 posts
4 tags
Lambda Calculus Evaluator
After writing Jison, I began more experimentation with other facets of programming language design, namely interpreters. I was first exposed to their workings two years ago in a programming languages course at my university, where we wrote an interpreter for a minimal functional language using SML. As an experiment, I used the same technique to evaluate lambda calculus expressions. Well, that...
Apr 25th
4 tags
Replication Speed: CouchDB vs. MongoDB
I’m posting this because I hadn’t seen this comparison done before. Therefore, it might be useful to someone else. Maybe. This was a rough test to see how long a slave would take to catch up with its master, which was sustaining about 500 document insertions per second with about 5 million documents already stored. The general verdict was that MongoDB replication is much faster, at...
Apr 20th
2 notes
4 tags
Slides and code from "Build Your Own Programming...
I gave a Track B presentation this year at JSConf titled “Build Your Own Programming Language with JavaScript”. The conference was incredible, but I’ll post about that later, perhaps. I’ve pushed the code and slides from the talk to github for people to play with.
Apr 20th
March 2010
2 posts
2 tags
A Common, Universal Scripting Language
Where is it? Hint: JavaScript. There’s an interpreter on every consumer platform and it’s already the most widely used scripting language in the world[citation needed]. The core language is also very simple, and beginner friendly by design. Heck, every programmer already knows about half of the language through dealing with JSON. Throw in functions and you can get by. It may not be...
Mar 30th
4 tags
Localized JSON Lint
I stumbled upon jsonlint.com recently, a service that sends your JSON data to a server for validation and returns the results. I decided to create a pure JavaScript version, which makes it is easy to host your self. It also comes as a CommonJS module in case you want to include it in some other tool.
Mar 13th
1 note
February 2010
1 post
3 tags
CoffeeScript compiler now uses Jison
The new CoffeeScript self compiler uses Jison for generating the parser. The whole build script runs on Node. Jeremy, the creator of CoffeeScript, spurred me to make some quick performance improvements (and bug fixes) to Jison so that the CoffeeScript grammar could build in a timely fashion. And while there are still many improvements to be made, handling such a large and complex grammar is...
Feb 25th
January 2010
1 post
7 tags
Jison, now with more Bison flavor.
I pushed a new version of Jison (0.1.5) the other day that adds some interesting features, namely the ability to use Bison-like grammar definitions and Flex-like lexer definitions. Bison flavored grammars The following is a valid Bison grammar: %token NUMBER %% E : E '+' T | T ; T : NUMBER ; Now it is also a valid Jison grammar. You can generate a parser using it...
Jan 29th
December 2009
4 posts
4 tags
Orderly.js Web Version
I’ve commited a minified, dependency-free version* of orderly.js for use on the web. It introduces an orderly object, with parse and compile methods. Usage is straight forward: <script src="orderly.js"></script> <script> var orderlySource = "array {};"; var jsonSchemaSource = orderly.compile(orderlySource); var jsonSchemaObject =...
Dec 31st
7 tags
Jison: An API for creating parsers in JavaScript
Bottom-up parsing When you hear of someone writing a parser, it is usually of the top-down, recursive descent variety. Visualizing the source as an abstract syntax tree (AST), this means the parser tries to match the root, and by doing so, may recursively try to match branches and stems of the AST as it works its way down. Bottom-up parsing is different: Bottom-up parsing (also known...
Dec 28th
2 notes
8 tags
Orderly.js: Orderly to JSONSchema Compiler
Orderly is a textual format for describing JSON. Orderly can be compiled into JSONSchema. It is designed to be easy to read and write. I decided to give Jison a real-world spin by creating an Orderly to JSONSchema compiler for JavaScript. After about three days, interspersed with lots of eating and family vists, I have a working implementation, which I call Orderly.js. Usage var orderly =...
Dec 27th
1 note
6 tags
Stay parsey, my friends.
I hinted on twitter that I was implementing some kind of compiler in JavaScript. It was a project I began to help study for a compilers course I was taking, which also gave me an opportunity to earn extra credit. Though, really, I just thought it was a friggen cool thing to implement. I ended up focusing on the compiler front-end to create a parser generator, which I call Jison. Anyway, the...
Dec 23rd
November 2009
4 posts
4 tags
Random Notes on Computability
I felt like venting a bit. Let’s take a brief stroll through computability land. The difference is computability. Computability is important to a programmer. It’s fundamental to the act, even. Let’s just say it’s basically everything. Why waste cycles trying to compute the uncomputable! Or better yet, why introduce bugs trying to compute a problem using an insufficient...
Nov 24th
1 tag
Momentum and The Web
Recent events have my mind spinning (pun semi intended,) so excuse the perspective-rather-than-directive here. Ahem. There’s nothing stopping the web now. Not to say that there was doubt before, but man, there’s nothing stopping it now. This is the fastest I’ve ever seen it move (granted, my observing eye awoke to a stagnant age where the blue E ruled all.) The momentum of...
Nov 20th
3 tags
Number.prototype
Monkey-patching the Number global in JavaScript seems innocuous, and usually, that would be correct. I mean, who actually uses methods on Number instances, right? Your only worry is that someone else had the same idea in a another library, with different semantics. Other than that, you’re fine. Anyway, this is my favorite Number trick: Number.prototype.times = function(funct){ if(typeof...
Nov 13th
4 tags
Flip Text Jetpack
I was surprised when I didn’t find a Jetpack that already did this. Who doesn’t love the flipped-text Unicode trick? ˙op ǝɹns I Now you can flip text at will.
Nov 12th
October 2009
1 post
6 tags
Another Way to Run Narwhal
What’s Narwhal? Ahem: Narwhal is a cross-platform, multi-interpreter, general purpose JavaScript platform. It aims to provide a solid foundation for building JavaScript applications, primarily outside the web browser. Narwhal includes a package manager, module system, and standard library for multiple JavaScript interpreters. - narwhaljs.org It basically enables you to do things in...
Oct 7th
1 note
July 2009
1 post
5 tags
Cross-site HTTP Request for jsonip
I’ve added cross-site HTTP request support for jsonip, a micro-service I introduced previously that retrieves a client’s IP address. Now, with HTTP access controls and a browser that supports them (such as Firefox 3.5,) any site can use a regular XmlHTTPRequest to utilize the service instead of JSONP. This might not be terribly useful today, as most browsers don’t support HTTP...
Jul 3rd
June 2009
3 posts
2 tags
Stop Using arguments.callee
Please, it’s no longer needed. It’s also deprecated and uncool. I still see authors use it to recursively call an anonymous function when really, they should be using a named function. E.g. instead of this (from MDC): function makeFactorialFunc() { alert('making a factorial function!'); return function(x) { if (x <= 1) return 1; return x *...
Jun 22nd
7 tags
403 Error When Configuring APE Server
The steps for installing and configuring APE went fairly smooth for me, except for a small snag. I’m just noting it below for reference. I was getting 403 Permission denied errors until I configured mod_proxy to Allow from my APE sub domains: <Proxy *> Allow from *.ape-test.local </Proxy> You could place this in your Apache configuration file, but instead, I created...
Jun 19th
1 note
3 tags
A Naive, JScript Compatible Getter Pattern
Modern JavaScript implementations let you define getters and setters for properties of objects. The new syntax involved will, of course, make your code incompatible with less capable JavaScript VMs if you chose to use it, but the behavior of the rest of your code will also be different, even when syntactically identical. This little experiment of mine was aimed to address the latter issue (well,...
Jun 1st
May 2009
5 posts
3 tags
Unobtrusive JavaScript in Rails 3
One of the coolest features I’ve heard about the upcoming Rails version 3 is its support for unobtrusive JavaScript. The current JavaScript helpers in Rails produce HTML littered with in-line Prototype specific code: <a href="#" onclick="new Ajax.Request('/comments/1', {asynchronous:true, evalScripts:ture, method:'delete'}); return false;">Destroy</a> The new technique...
May 23rd
6 tags
A Matter of Philosophy (and necessity)
The article comparing Mootools and jQuery is great — go ahead and take a gander. The author definitely did his research. In fact, there are only a few nitpicks I had with it. The author demonstrates well his awareness of the different philosophies of each project. The aim of jQuery is to provide a succinct API for dealing with browser shortcomings and inconsistencies, whereas Mootools aims...
May 22nd
1 note
2 tags
RE: Null and Undefined as Objects in JavaScript
I regret not making everything an object, FWIW. “Make it look like Java” + lazy/fast machine types for numbers + zero time to implement in May 1995. - Brendan Eich (creator of JavaScript) Wouldn’t that have been something.
May 15th
2 tags
Firefox is Not a Browser
It’s a platform, silly.
May 9th
1 tag
Just Kidding
It turns out I’ll be sticking around to do my Honors thesis, and possibly add on a minor in Math. Isn’t this the day before graduation, you ask? Why yes, yes it is. If you have ideas for a thesis, let me know. I’m leaning toward something where I get to design and implement a programming language, or maybe something with neural networks or evolutionary programming. Or maybe...
May 2nd
April 2009
1 post
1 tag
Graduation
I’ll be receiving my bachelors degree in Computer Science on Saturday. A swift four years it has been, indeed. Most of my peers are crying in jubilation at this moment, but I feel like there is some unfinished business for me. I’m not entirely sold on graduate school, yet, but I’m leaning towards it. Programming languages have caught my fancy…
Apr 29th
March 2009
1 post
4 tags
Sweet, sweet Reia
Reia is sweet. At first glance, it looks like Ruby with parenthesis and pattern matching. Pattern matching! From my brief stints with SML (and Erlang,) I’ve longed to take pattern matching back with me to every language I use. At second glance — well, I’m still in the midst of taking a second glance, actually. But, here, some encouraging words: Reia is its own language and is...
Mar 17th
February 2009
5 posts
4 tags
The Open Art Project
Engineering Expo was held at my university a couple of weeks ago. Its an event where schools and families travel from afar to see just how awesome engineering actually is. Really, its like a college level science fair, including tons of robots, cars, Tesla coils and other engineered eye candy. But what does the computer scientist have to offer in this environment? Hm? How about, Firefox! Open...
Feb 27th
3 tags
Don't Push Your OOP On Me
Implementations of classical inheritance in JavaScript always leave a bad taste on my tongue. John Resig articulates why: I’m not convinced by this argument. “Because it’s what we’re familiar with” does not imply that it’s the best solution - or even a good solution - neither does “everyone else is doing it.” I’ve been doing JavaScript...
Feb 26th
2 tags
An Object That's Not
In JavaScript, objects just love their prototypes. And why wouldn’t they? Whenever they are in need of a property, hey, they can always check up the inheritance chain and try to find it. It’s good to know someone always has your back! But, what if no one had your back? $ js js> var obj = {}; js> obj.toString(); [object Object] js> obj.__proto__ = null; null js>...
Feb 23rd
3 tags
Voice Search on Android
Android now has voice search with the latest update. While trying to search for “couchdb”, it detected the following: tennis tv change db philips dvd It worked well for non-technical terms, however.
Feb 8th
1 note
1 tag
Fear
I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain. (from “Dune”)
Feb 4th
2 tags
The Miller Device on null and Other Lowly...
null and undefined are weird. Normally, you would check for them directly by using x === null or typeof x === undefined, etc, but what if we use the Miller Device? An example of usage: var myArray = []; if(Object.prototype.toString.apply(myArray) === '[object Array]') { // do array operations } Every browser gives consistent results for JavaScript’s other top level objects: object...
Feb 1st
3 tags
jsUnity
I was looking for a lightwieght, context-agnostic testing framework for JavaScript so I could describe the behavior of whatever script I was writing (and found one, thanks to Ates making it.) The particular script I was working on had no need for a browser or any of the extra environmental cruft - it was pure JavaScript, ready to be plugged in wherever it may go. Or perhaps it will never leave the...
Feb 1st
January 2009
10 posts
2 tags
Odd: Using prototype as a Singleton
I was perusing the JsUnit code examples and noticed how they used the object’s prototype as a singleton: var result = TextTestRunner.prototype.main( args ); JsUtil.prototype.quit( result ); Code like this appears throughout the page! This strikes me with much fear and confusion. Surely, for use as a singleton, any arbitrary property name would be more appropriate than prototype, the...
Jan 29th
1 tag
Android Applications for Fun and... Utility
These are some of my favorite Android applications that I actually use on a day to day basis. Some of them are useful, most of them are not, per se. I suppose social engagement can be useful. Favorites Besides all of the built in apps, here’s my list in the order memory serves me: Greed: An awesome Google Reader application. The Schwarts Unleashed: It’s exactly like the iPhone...
Jan 23rd
4 tags
C File Descriptors: A Novice Dialogue
In the Operating Systems class at my university, one of the projects we have to complete is a Unix shell. It’s a basic shell which should support piping, redirection, inverse redirection, and background processes. Needless to say, this was an immensely interesting and useful project, though sometimes difficult for the unassuming undergrad. I had completed it in a previous semester, but a...
Jan 19th
2 tags
Cast Iron Skillet
The ablity to cook good steaks like this in the wintertime is reason enough to buy and care for a cast iron skillet. In a disaster, I would grab my daughter, my wedding album, and my cast iron skillet that once belonged to my grandma. Everything else can be replaced. - newbatgirl There is a metaphor for development in there. And when I find it; steak for dinner.
Jan 19th
3 tags
The Future of the Web
The debate over supporting RDFa within HTML5 has been burning hot. A quote from the editor of the HTML5 specification reveals what the friction is really about: It’s not clear to me that the future of the Web is structured data. If anything, I’d predict it was unstructured data. It would be useful to know why you think structured data is the future. - Ian Hickson I’ve heard...
Jan 17th
3 tags
Removing duplicate characters
An interesting string method was brought to my attention on the ruby-talk mailing list: string.squeeze. It removes duplicate characters in a string, and performs better than regular expressions or splitting-joining, to boot. Craig posted some benchmarks: require 'benchmark' n = 1_000_000 Benchmark.bm(10) do |x| x.report("gsub") { n.times do "This is a test string.".gsub(/ +/, ' ') ...
Jan 11th
4 tags
Make it nice for Andoid and iPhones
Mobile Webkit recognizes some useful CSS media queries, which I’m using to include a special mobile stylesheet on my page: <link href="/style/mobile.css" rel="stylesheet" media="only screen and (max-device-width: 480px)" type="text/css" /> The key here being the media attribute value of only screen and (max-device-width: 480px). The mobile stylesheet contains just a few rules to...
Jan 10th
1 note
1 tag
What does that mean again?
Sometimes when reading an article I may stumble over a word and need a quick refresher on its meaning and how it relates to the given context. Ubiquity has proven to be most useful for such occasions. I’d say 90% of my Ubiquity invocations are for definition lookups. I press my key combo, Ctrl+Space, then type the command: def cromulent and the definition displays as I complete the...
Jan 6th
December 2008
2 posts
2 tags
Committing to a better editor
Yeah, I use vim. You know, for those trivial edits or during remote sessions. Nevermore! I finally got tired of selling myself short. This past weekend I committed myself to use vim (mostly gvim) for any and all of my daily coding. This is something that was long overdue, and after getting real friendly with vim this weekend, I wish I would have done it much sooner. … Once I got...
Dec 30th
2 tags
Blog migration
Wordpress was annoyingly slow for me, especially within the admin area, so naturally I went looking for an alternative. I don’t want all that extra cruft anyway - give me something lean I can hack on without having to read a whole manual (and preferably something not… PHP.) Upon seeing Scanty, I was pysched. It’s based off Sinatra, which I was already playing with at the time,...
Dec 28th
November 2008
2 posts
Mr. Empanadas
Mr. Empanadas, originally uploaded by zaach. So good…
Nov 9th
2 tags
My server name registry
When I get another set of servers to name, I think I’ll go with a candy theme. For future reference: hershey skittle jollyrancher twizzler snickers twix tootsieroll etc. Also, Google sets is cool.
Nov 8th
September 2008
3 posts
2 tags
jsonip, retrieve the client's IP address via JSONP
This question on Stackoverflow spurred me to write my first Google App Engine project and consequently my first Python script, jsonip. It lets you retrieve a client’s IP address without needing your own server-side script. Normally you could make a call to a local server script that prints the user’s IP address then use an XMLHttpRequest to retrieve it. jsonip uses JSONP, so you could...
Sep 22nd
1 note