Skip to content

Instantly share code, notes, and snippets.

View wagenet's full-sized avatar

Peter Wagenet wagenet

View GitHub Profile
@wagenet
wagenet / gist:935079
Created April 21, 2011 17:46
Git Lines of Code
#!/usr/bin/env ruby
# encoding: UTF-8
require 'optparse'
class File
def self.binary?(name)
fstat = stat(name)
return false unless fstat.file?
@wagenet
wagenet / irc-counter.rb
Created January 6, 2011 01:52
Counts the number of users in an IRC room
#!/usr/local/bin/ruby
require "socket"
irc = TCPSocket.open('irc.freenode.net', 6667)
irc.send("USER blah blah blah :blah blah\n", 0)
irc.send("NICK ChanScanBot\n", 0)
irc.send("JOIN #sproutcore\n", 0)
names = []
@wagenet
wagenet / routes_hack.js
Created October 21, 2010 16:24
Fix to allow SC.routes to set a currentLocation without triggering routing.
SC.routes.currentLocationDidChange = function(){
this.set('location', this.get('currentLocation'));
};
SC.routes.addObserver('currentLocation', SC.routes, 'currentLocationDidChange');
SC.routes.locationDidChange = function(){
var location = this.get('location'),
current = this.get('currentLocation');
if (location !== current) {
this.trigger();
#######################
#### DOCUMENTATION ####
#######################
#
# Run as:
#
# ruby phonegap-sc.rb APP_NAME
# ruby phonegap-sc.rb APP_NAME PROJECT_PATH
# ruby phonegap-sc.rb APP_NAME PROJECT_PATH OUTPUT_PATH
#
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Morphing Power Cubes</title>
<style type="text/css" media="screen">
body {
background-color: black;
use Rack::ShowExceptions
use Rack::CommonLogger
require 'rack/request'
require 'rack/response'
require 'open-uri'
class HeaderProxy
def call(env)
req = Rack::Request.new(env)
MiniApp.Tappable = {
_tap_tapCount: null,
_tap_candidateTouch: null,
_tap_eventTimer: null,
tapWiggle: 10,
tapDelay: 200,
tapStart: function(evt){
<html>
<head>
<script type="text/javascript" charset="utf-8">
function transactionErrorCallback(error) {
console.error('Oops. Transaction error was '+error.message+' (Code '+error.code+')');
}
function transactionSuccessCallback() {
alert('Done');
}
<html>
<head>
<script type="text/javascript" charset="utf-8">
window.onload = function(){
var display = document.getElementById('display'),
count;
for(count=0; count < 100000; count++) {
// 1kb
sessionStorage.setItem('i'+count, '01234567890123456789012345678901234567890123456789'+
require 'uuid'
module ActiveRecord
module UUID
def self.included(base)
base.send :extend, ClassMethods
base.send :include, InstanceMethods
class << base
alias_method :uuid_exists?, :exists?