Skip to content

Instantly share code, notes, and snippets.

View bdotdub's full-sized avatar

Benny Wong bdotdub

View GitHub Profile
# this is really silly
irb(main):035:0> hash = {:x => 'y'}
=> {:x=>"y"}
irb(main):036:0> hash()
=> 113830
irb(main):037:0> hash { puts 'blah' }
=> 113830
irb(main):038:0> hash{:x}
=> 113830
function rotatePages() {
if (navigator.appVersion.indexOf('iPhone OS ') < 0) { // Don't rotate on iPhone.
posts = document.getElementsByClassName('postRotationContainer');
for (i = 0; i < posts.length; i++) {
// console.log("Post "+i+": Height: "+posts[i].clientHeight+" Current:"+posts[i].style.webkitTransform);
if (typeof posts[i].parentNode.className == 'string' // we can read the parent's classname
&& posts[i].parentNode.className.indexOf('noRotation') < 1 // - and it's not set to noRotation
&& ! posts[i].style.webkitTransform) // - and not already rotated
{
posts[i].style.webkitTransform = 'rotate(' + ((Math.random() * maxRotationAngle * 2) - maxRotationAngle) + 'deg)';
logger = env['rack.errors']
STDOUT.reopen(logger)
STDERR.reopen(logger)
# Taken from http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText
define ensure_key_value($file, $key, $value, $delimiter = " ") {
# append line if "$key" not in "$file"
exec { "echo '$key$delimiter$value' >> $file":
unless => "grep -qe '^$key[[:space:]]*$delimiter' -- $file",
path => "/bin:/usr/bin"
}
# update it if it already exists...
exec { "sed -i '' 's/^$key[[:space:]]*$delimiter.*$/$key$delimiter$value/g' $file":
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
**/
function SHA256(s){
require 'rubygems'
dependencies = <<-EOS
rack 0.9.1
activesupport >= 2.2.2
daemons >= 1.0.10
djanowski-workling
djanowski-collage >= 0.1.3
faker >= 0.3.1
fiveruns-memcache-client >= 1.5.0
:%s/\e\[\%([01]\|3[0-7]\|4[0-7]\)\%(;\%([01]\|3[0-7]\|4[0-7]\)\)*m//g
# ----------------------------------------------------------------------------------------------------
# Python / Skype4Py example that prints out chat messages
# Adapted from: http://github.com/pneff/SkypeBot
#
# Tested with Skype4Py version 0.9.28.5 and Skype verson 3.8.0.96
import sys
import Skype4Py
CHAT_NAME = '#blah/$SHA1'
#!/bin/sh
# This is a script that will automatically download the latest video from the
# Final Gear torrent feed. I don't write many shell scripts so please excuse
# any bad shell scripting.
# My setup is to have Transmission automatically open torrents that are in
# my $HOME/Downloads/Torrents directory. You can set this in:
# Transfers > Auto Add
@bdotdub
bdotdub / snapper.rb
Created February 3, 2010 23:16 — forked from mnutt/snapper.rb
#!/usr/bin/env macruby
# from tomafro.net
framework 'Cocoa'
framework 'WebKit'
class Snapper
attr_accessor :options, :view, :window
def initialize(options = {})