Skip to content

Instantly share code, notes, and snippets.

View rgrove's full-sized avatar
🥧

Ryan Grove rgrove

🥧
View GitHub Profile
$ ruby route_test.rb
W [2009-04-25 23:49:56 $27423] WARN | : No explicit root folder found, assuming it is .
D [2009-04-25 23:49:56 $27423] DEBUG | : Using webrick
I [2009-04-25 23:49:56 $27423] INFO | : WEBrick 1.3.1
I [2009-04-25 23:49:56 $27423] INFO | : ruby 1.8.6 (2008-03-03) [universal-darwin9.0]
D [2009-04-25 23:49:56 $27423] DEBUG | : TCPServer.new(0.0.0.0, 7000)
D [2009-04-25 23:49:56 $27423] DEBUG | : Rack::Handler::WEBrick is mounted on /.
I [2009-04-25 23:49:56 $27423] INFO | : WEBrick::HTTPServer#start: pid=27423 port=7000
D [2009-04-25 23:50:05 $27423] DEBUG | : accept: 127.0.0.1:57986
D [2009-04-25 23:50:05 $27423] DEBUG | : Rack::Handler::WEBrick is invoked.
YAHOO.namespace('util').HTML = (function () {
var d = document,
Y = YAHOO,
isArray = Y.lang.isArray,
isObject = Y.lang.isObject,
isString = Y.lang.isString,
ATTRIBUTES = !d.documentElement.hasAttribute ? {
// IE < 8
module Thoth
class MainController
after(:index) do
@page = Page[:name => 'front']
@show_page_edit = true
end
end
end
<!DOCTYPE html>
<html>
<head>
<script>
// Shaving off even more characters, because I can
function L(U,C){var d=document,f='firstChild',r='readyState',h=d.documentElement[f],s=d.createElement('script'),m=s[r]?'onreadystatechange':0;s.src=U;s[m||'onload']=function(){if(!m||/ded|te/.test(s[r])){s[m]=null;C()}};h.insertBefore(s,h[f]);}
// async loading of javascript files, starting asap.
L("http://example.com/example.js",function () {
doSomething();
@rgrove
rgrove / history-lite.js
Created September 23, 2009 00:56
Lightweight Ajax browser history for YUI 3
/**
* The History Lite utility is similar in purpose to the YUI Browser History
* utility, but with a more flexible API, no initialization or markup
* requirements, limited IE6/7 support, and a much smaller footprint.
*
* @module history-lite
*/
/**
* @class HistoryLite
@rgrove
rgrove / storage.js
Created October 16, 2009 05:26
A persistent local key/value data store similar to HTML5's localStorage. Works in IE5+, Firefox 2+, Safari 3.1+, and any browser with Google Gears installed (including Chrome).
/**
* Implements a persistent local key/value data store similar to HTML5's
* localStorage. Should work in IE5+, Firefox 2+, Safari 3.1+, and any browser
* with Google Gears installed (including Chrome). Doesn't work in Opera.
*
* @module storage
* @namespace YAHOO.Search
* @requires yahoo, event, json
*/
(function () {
@rgrove
rgrove / gist:282168
Created January 20, 2010 19:49 — forked from ahx/gist:281893
# remove content of script tags using Sanitize
require 'sanitize'
html = '<p>Do not<script>fail();</script> kill the <a href="/cats/42">cat</a>.</p>'
Sanitize.clean(html, Sanitize::Config::BASIC.merge(
:transformers => lambda { |env|
node = env[:node]
if node.name.downcase == 'script'
@rgrove
rgrove / capmon.rb
Created February 26, 2010 00:47
Ruby script to retrieve and display Comcast data usage. See http://wonko.com/post/ruby-script-to-display-comcast-data-usage
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
URL_LOGIN = 'https://login.comcast.net/login?continue=https://login.comcast.net/account'
URL_USERS = 'https://customer.comcast.com/Secure/Users.aspx'
abort "Usage: #{$0} <username> <password>" unless ARGV.length == 2
var count = 10,
http = require("http"),
sys = require("sys"),
twitter = http.createClient(80, "search.twitter.com"),
i, request;
for (i = 1; i <= count; i++) {
request = twitter.request("GET", "/search.json?q=crockfordfact+OR+crockfordfacts&rpp=100&page=" + i, {"host": "search.twitter.com"});
request.addListener('response', function (response) {
var responseData = [];
function buildQueryString(parameterMap) {
var params = [];
for (name in parameterMap) {
if (parameterMap.hasOwnProperty(name)) {
params.push(encodeURIComponent(name) + '=' + encodeURIComponent(parameterMap[name]));
}
}
return params.join('&');