This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function uuid() { | |
| var uuid = "", i, random; | |
| for (i = 0; i < 32; i++) { | |
| random = Math.random() * 16 | 0; | |
| if (i == 8 || i == 12 || i == 16 || i == 20) { | |
| uuid += "-" | |
| } | |
| uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ rbx memory.rb | |
| memory used: 19.4M | |
| $ bin/mspec ci -T -rmemory core/array | |
| rubinius 1.2.1 (1.8.7 cdbdd275 2011-02-15 JI) [i686-apple-darwin9.8.0] | |
| ................................................................................................................ | |
| Finished in 3.992361 seconds | |
| 112 files, 2166 examples, 4420 expectations, 0 failures, 0 errors |
Experimental Mongo support for ActiveRecord.
Here is an instructional video:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rubygems" | |
| require "chunky_png" | |
| require "base64" | |
| module Sass::Script::Functions | |
| def background_noise(c, noise = 0.5, opacity = 0.08, size = 200, mono = false) | |
| # Convert SASS numbers to Ruby classes | |
| noise = noise.to_s.to_f if noise.is_a? Sass::Script::Number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'json' | |
| ### | |
| # Stupid simple class for uploading to imgur. | |
| # | |
| # client = Imgur2.new 'my imgur key' | |
| # p File.open(ARGV[0], 'rb') { |f| | |
| # client.upload f | |
| # } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF | |
| Multi-Firefox Fixer - v0.2 - 4/26/2011 | |
| http://benalman.com/ | |
| Usage: `basename "$0"` | |
| Run this shell script from beside (in the same parent directory as) one or more | |
| Firefox*.app or Aurora*.app applications and it will "fix" those Firefoxes to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'slop' | |
| opts = Slop.parse do | |
| banner "Usage: ruby foo.rb [options]\n" | |
| on :n, :name, 'Your username', true | |
| on :a, :age, 'Your age (optional)', :optional => true | |
| on :V, :verbose, 'Run in verbose mode', :default => false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Bypass New York Times paywall (20 article limit) | |
| // @author Mathias Bynens <http://mathiasbynens.be/> | |
| // @link http://mths.be/axa | |
| // @match http://www.nytimes.com/* | |
| // ==/UserScript== | |
| (function(d) { | |
| d.getElementById('overlay').style.display = 'none'; | |
| d.getElementById('gatewayCreative').style.display = 'none'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is just an hint for a simple Redis caching "framework" using Sinatra | |
| # A friend of mine asked for something like that, after checking the first two gems realized there was | |
| # a lot of useless complexity (IMHO). That's the result. | |
| # | |
| # The use_cache parameter is useful if you want to cache only if the user is authenticated or | |
| # something like that, so you can do cache_url(ttl,User.logged_in?, ...) | |
| require 'rubygems' | |
| require 'sinatra' | |
| require 'redis' |

