Skip to content

Instantly share code, notes, and snippets.

@artm
artm / xmas.rb
Created December 20, 2012 10:25
a derivative work from climagick's "Let It Snow In Your Terminal" (http://climagic.org/coolstuff/let-it-snow.html), see also https://gist.github.com/4344001
require 'set'
rows,columns = `stty size`.scan(/\d+/).map{|x| x.to_i}
# ruby 1.8.x compatible way to say "\u2743"
Flake = ["2743".to_i(16)].pack("U*")
# Shapes from far away to still closer
Snow = ['.','*',Flake]
# flake state descriptor
@phillbaker
phillbaker / lmu.m
Created November 17, 2012 20:23
Macbook ambient light sensor data
// Compile with $ gcc -o lmutracker lmu.m -framework IOKit -framework CoreFoundation -framework Foundation
// Usage: ./lmu [now]
// Prints out the value from the ambient light sensor and the back light LED every 1/10 of a second. Optionally print just one value.
// Inspired by the code found at
// http://google-mac-qtz-patches.googlecode.com/svn-history/r5/trunk/AmbientLightSensor
// and http://osxbook.com/book/bonus/chapter10/light/
// and http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/Archives/Computing/2010_February_10#Mac_OS_X_keyboard_backlight_drivers
// http://forums.macrumors.com/showthread.php?t=1133446
#include <stdio.h>
@westonruter
westonruter / canPlayAudioMP3.js
Created December 10, 2009 07:13
HTML5 MP3 Audio detection
/**
* Detect if the browser can play MP3 audio using native HTML5 Audio.
* Invokes the callack function with first parameter is the boolean success
* value; if that value is false, a second error parameter is passed. This error
* is either HTMLMediaError or some other DOMException or Error object.
* Note the callback is likely to be invoked asynchronously!
* @param {function(boolean, Object|undefined)} callback
*/
function canPlayAudioMP3(callback){
try {