February 2009
5 posts
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...
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...
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...
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...
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...
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.
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...
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(/ +/, ' ')
...
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...
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...