Skip to content

Instantly share code, notes, and snippets.

Element.implement({
matchFromRoot: function(selector){
return document.getElements(selector, true).contains(this);
}
});
myElement.match('div') // true
myElement.match('body div') // false
myElement.matchFromRoot('div') // true
var Dictionary = new Native({
name: 'Dictionary',
initialize: function(){
this.keys = [];
this.values = [];
}
});
@subtleGradient
subtleGradient / gist:24610
Created November 13, 2008 20:38
Shortcuts and Functionality needed in Espresso
escape - completion of words in the current document
⌘/ - comment selection/line with line comments
⌘⌥/ - comment selection/line with block comment
command option . - close current HTML/XML tag
command-shift-l - select current line
command-option-a - edit all selected rows
command-option-return - insert terminator at end of line
command-shift-t - select file by name / focus project search
command-ctrl-t - select command/snippet by name
From d954fbce5fbfc5d6070d796afacf998036c0cd51 Mon Sep 17 00:00:00 2001
From: subtleGradient <oblivious+github@subtleGradient.com>
Date: Thu, 20 Nov 2008 08:51:07 -0700
Subject: [PATCH] Move observe into a method so that it can be observed
---
Autocompleter.js | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Autocompleter.js b/Autocompleter.js
var SubtleBenchmarker = new new Class({
benchmarks:{},
start : function(key){
this.benchmarks[key] = this.benchmarks[key] || [];
this.benchmarks[key].push({ start:new Date() });
},
end : function(key){
this.benchmarks[key][this.benchmarks[key].length-1].end = new Date();
@subtleGradient
subtleGradient / curtain.css
Created December 18, 2008 22:51
Lightbox Background Curtain using only CSS
/*Style*/
.curtain{
color: rgb(32,32,32);
background-color: rgb(32,32,32);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
filter: alpha(opacity=80);
-moz-opacity: 0.8;
opacity: 0.8;
}
/*Positioning*/
@subtleGradient
subtleGradient / csv_to_json_hash
Created January 10, 2009 17:56
convert CSV to JSON hash of hashes
#!/usr/bin/env ruby
# convert CSV to JSON hash of hashes
# uses the first column as the ID column, must be unique per row
# takes the CSV filepath as first argument
# fallsback to STDIN when there are no arguments
require 'rubygems'
require 'csv'
require 'json'
@subtleGradient
subtleGradient / Mootools excanvas wrapper.js
Created January 22, 2009 01:44
Mootools excanvas wrapper, because ibolmo moocanvas doesn't support image rotate well. MIT Licenced - Daniel Steigerwald (daniel.steigerwald.cz)
/*
* Mootools excanvas wrapper, because ibolmo moocanvas doesn't support image rotate well.
*
* MIT Licenced - Daniel Steigerwald (daniel.steigerwald.cz)
*
*/
var Canvas = new Class({
initialize: function() {
var params = Array.link(arguments, { document: Document.type, properties: Object.type });
@subtleGradient
subtleGradient / Functional ASCii Art
Created January 22, 2009 21:17
Stupid Javascript tricks: self-chained function; Functional ASCii Art.js
function chained(){ console.log(arguments); return arguments.callee; };
chained(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
{ scopeName = 'source.ruby.experimental';
foldingStartMarker = '(?x)^
(\s*+
(module|class|def
|unless|if
|case
|begin
|for|while|until
|^=begin
|( "(\\.|[^"])*+" # eat a double quoted string