Skip to content

Instantly share code, notes, and snippets.

View rgrove's full-sized avatar
🥧

Ryan Grove rgrove

🥧
View GitHub Profile
@flavorjones
flavorjones / README.markdown
Created August 19, 2009 05:46
Comparison of Loofah against other Ruby HTML sanitization libraries

Overview of the Benchmark

The following benchmark output was generated from the codes at http://github.com/flavorjones/loofah/tree/master/benchmark

These results show the performance of Loofah scrubbing methods against comparable methods from other common open-source libraries:

  • ActionView sanitize() and strip_tags()
  • Sanitize sanitize()
@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
@rgrove
rgrove / history-lite.js
Created August 11, 2010 16:44
History Lite for YUI 2.
/**
* Lightweight history utility for YUI 2. Similar in purpose to the YUI Browser
* History Manager, but with a more flexible API, no initialization requirement,
* no IE6/7 support, and a much smaller footprint.
*
* @module history-lite
* @requires YAHOO, Event
* @class HistoryLite
* @static
*/
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
/**
* Sanitize URL — Validate it looks like a URL, then make it less dirty.
*
* Oddnut Software
* Copyright (c) 2010 Eric Ferraiuolo - http://eric.ferraiuolo.name
* MIT License - http://www.opensource.org/licenses/mit-license.php
*
* Examples:
*
* 'Http://WWW.example.com/' » 'http://www.example.com/'
@czottmann
czottmann / gist:554938
Created August 28, 2010 09:22
YUIDoc's main.tmpl, formatted and whitespace-cleaned
#encoding UTF-8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>
API: $modulename
#if $classname#
$classname
#end if#
@rgrove
rgrove / node-combo.js
Created October 4, 2010 23:23
Simple NodeJS combo handler for YUI 3 (or anything, really).
#!/usr/bin/env node
/**
* Simple YUI combo handler using NodeJS and Express. Stick a caching and
* compressing proxy in front of this and you're ready to rock in production.
*
* Copyright (c) 2010 Ryan Grove <ryan@wonko.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
/*
Strong implementation must check that key is object,
hide weakMapN_ from enumeration, make it externally readonly and non deletable(Object.defineProperty, if presents),
but its bad for performance.
*/
(function($G)
{
var nextStoreKeyId = 0;
var supportedMimeTypes = ['video/mp4', 'video/x-ms-wmv'];
var supportedVideoExtensions = ['.mp4', '.wmv', '.mp4v', '.m4v'];
var getSupportedMediaSource = function(videoElement)
{
// If the video element source is supported, then we replace the tag.
if (videoElement.src
&& isWMPSupported(videoElement))
{
@ericf
ericf / gist:813606
Created February 6, 2011 18:55
New Y.Markout API
// the main difference between the new and current is convenience around writing text in node.
// also a new .node() method which return the Y.Node instance (.getNode() still exits).
// appends <h2>The New <a href="http://oddnut.com/markout/">Markout API</a></h2> to #foo
Y.Markout('#foo').h2('The New ').a({ href: 'http://oddnut.com/markout/' }, 'Markout API');
// appends <div></div> to #foo references the Y.Node instance through the .node method.
Y.Markout().div().node().appendTo('#foo');