Skip to content

Instantly share code, notes, and snippets.

View yoko's full-sized avatar
🍐
I like pear

yksk yoko

🍐
I like pear
View GitHub Profile
$.support.placeholder = 'placeholder' in document.createElement('input');
@yoko
yoko / dispatcher.js
Created October 27, 2010 12:43
a URL dispatcher.
var dispatcher = {
location: window.location,
stash : [],
connect: function(paths, action) {
if (paths || paths === 0) {
paths = paths.valueOf();
if (!(typeof paths == 'object' && !(paths instanceof RegExp))) // webkit: typeof RegExp == 'function'
paths = { pathname: paths };
dispatcher.stash.push([paths, action]);
#!/usr/bin/env sh
appcfg.py update ~/Sites/static.carbonfairy.org
echo
node tumblr-update-theme.js username password account theme_file
#!ruby -Ku
require 'csv'
tr = []
CSV.open(ARGV[0], 'r') do |row|
td = []
row.each do |i|
if i
td.push("<td id=\"#{i}\" class=\"border\">#{i.sub(/\D+/, '')}</td>\n")
hashState = function(queries) {
var k, q;
if (queries === null) {
// fx 3.0.x reloads page when hash is empty
location.hash = '#';
return null;
}
else if (!queries) {
q = location.hash.slice(1);
// fx decodes automatically
(function($) {
$.fn.replaceClass = function(proc) {
return this.each(function() {
var classes = this.className.split(/\s+/), new_classes = [];
for (var i = 0, klass, ret; klass = classes[i]; ++i) {
ret = proc.call(this, i, klass);
if (ret) {
new_classes.push(typeof ret == 'string' ? ret : classes[i]);
}
}
foo && foo( {
"name": "Tumblr, Inc.",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [ {
"id": "p1",
"address": "Nyc Dance and Tumble, 209 Branchview Dr NE, Concord, NC 28025, USA",
"AddressDetails": {
@yoko
yoko / rarely.js
Created February 24, 2011 04:46
using with onscroll, onresize etc.
(function(ns) {
ns.rarely = rarely();
function rarely() {
var timer = null;
return rarely;
function element(tag_name, properties) {
var element = document.createElement(tag_name);
for (var k in properties) {
element[k] = properties[k];
}
return element;
}
(function($) {
$.support.placeholder = 'placeholder' in document.createElement('input');
$.fn.placeholder = function() {
var supported = $.support.placeholder;
if (!supported) {
this.each(function() {
var input = $('input[placeholder]', this);
if (input.length) {
var placeholder = $('<div class="placeholder">' + input.attr('placeholder') + '</div>')