Skip to content

Instantly share code, notes, and snippets.

View savetheclocktower's full-sized avatar

Andrew Dupont savetheclocktower

View GitHub Profile
From 9c8f4bd13483e7eea28a78a7fffffcc5cc337c21 Mon Sep 17 00:00:00 2001
From: Andrew Dupont <prototype@andrewdupont.net>
Date: Tue, 9 Sep 2008 10:38:34 -0500
Subject: [PATCH] Preliminary support for Google Chrome in unit tests.
---
Rakefile | 2 +-
test/lib/jstest.rb | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletions(-)
mode change 100644 => 100755 Rakefile
From 797e8a43b49fdc26720b1cda80da2735fe724c66 Mon Sep 17 00:00:00 2001
From: Andrew Dupont <prototype@andrewdupont.net>
Date: Sat, 25 Oct 2008 16:16:39 -0500
Subject: [PATCH] Fix links for switching to and downloading themes (they require a POST for security reasons).
---
app/views/admin/themes/_tools.rhtml | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/admin/themes/_tools.rhtml b/app/views/admin/themes/_tools.rhtml
Object.extend(NativeObject.prototype, function() {
function computeSomethingWhenAwesomeCapabilityIsAvailable() {
// ...
}
function computeSomethingWhenSomeStupidIEBugIsPresent() {
// ...
}
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
Element.Storage = {
UID: 1
};
Element.addMethods({
getStorage: function(element) {
if (!(element = $(element))) return;
if (Object.isUndefined(element._prototypeUID))
element._prototypeUID = Element.Storage.UID++;

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

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));
});
Object.extend(Ajax, {
registerURL: function(url, options) {
options = Object.extend({
instancePooling: true,
autoUpdatePlayer: true
}, options || {});
this._registry.set(url, options);
},
/**
* 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) {
// ==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.