Skip to content

Instantly share code, notes, and snippets.

View savetheclocktower's full-sized avatar

Andrew Dupont savetheclocktower

View GitHub Profile
// ==UserScript==
// @name Mock Geolocation
// @description MONKEYS!
// @version 2009-01-19
// @namespace http://andrewdupont.net/greasemonkey
// @include *
// ==/UserScript==
// Mock geolocation. Ugh.
if (!('geolocation' in navigator)) {
// ==UserScript==
// @name Score Monitor
// @namespace http://andrewdupont.net/greasemonkey
// @description Monitors fantasy football scores.
// @include http://*.football.cbssports.com/scoring/live/*
// @author Andrew Dupont
// ==/UserScript==
(function () {
if (!window.fluid) return;
module PDoc
module Generators
module Html
module Helpers
module BaseHelper
end
module LinkHelper
end
// ==UserScript==
// @name Reddit Uppers and Downers
// @namespace mistercow
// @description Show up-votes and down-votes next to the total score on reddit comments.
// @include http://*.reddit.com/*/comments/*
// @include http://reddit.com/*/comments/*
// ==/UserScript==
/*
This code is provided as is, with no warranty of any kind.
/**
* Krang.deepExtend(destination, source) -> Object
*
* A "deep" version of `Object.extend`. Performs a recursive deep extension.
*
* Used within Krang to blend user-set options with the defaults.
**/
Krang.deepExtend = function(destination, source) {
for (var property in source) {
Object.extend(Ajax, {
registerURL: function(url, options) {
options = Object.extend({
instancePooling: true,
autoUpdatePlayer: true
}, options || {});
this._registry.set(url, options);
},
window.tests = {
"make" : function(){
var fromcode;
for (var i = 0; i < 250; i++) {
fromcode = new Element('ul');
document.body.appendChild(fromcode);
$w('one two three').each( function(word){
fromcode.appendChild(new Element('li').update(word));
});

Sprockets: Beautiful and angular

Over at SvN, Sam announced the 1.0 release of Sprockets, the new dependency management and concatenation tool that makes it easy to modularize your JavaScript. Sprockets is Prototype's new build system, but you can use it, too; it's been extracted into a Ruby library so you can use it anywhere you write JavaScript.

There are many great ways to use Sprockets in your own projects. You can use it the way Prototype does — split up your JavaScript into small, maintainable files, then [create "meta-files"](http://github.com/sstephenson/prototype/blob/ab1313ea202e0d0bfb7cd0f563b035040710

Element.Storage = {
UID: 1
};
Element.addMethods({
getStorage: function(element) {
if (!(element = $(element))) return;
if (Object.isUndefined(element._prototypeUID))
element._prototypeUID = Element.Storage.UID++;
require 'rubygems'
require 'css_parser'
require 'hpricot'
require 'open-uri'
def fix_file(html_input_file, css_input_file, html_output_file, css_output_file)
# Instantiate Hpricot doc object
doc = Hpricot(File.read(html_input_file))
parser = CssParser::Parser.new