This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#hoard.sh: Private twitter on the shell | |
#usage: | |
# hoard "some string here": for store your hoard into file | |
# hoard -s: hoard: for See your recent hoard | |
# hoard -e: for Edit your recent hoard | |
#Change these lines for your System. | |
hoarddir="/Users/$USER/Documents/Hoard/" | |
hoardfile="`date +%Y%m`.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// access nested hash data using string | |
// Usage: | |
// var hash = {"foo": {"bar": true, "baz": false }}; | |
// getVal(hash, "foo.bar".split(".")); //=> true | |
// getVal(hash, "foo.baz".split(".")); //=> false | |
// setVal(hash, "foo.baz".split("."), "hoge"); //=> "hoge" | |
// you can also create new keys step by step (same as accessing with array-style) | |
function getVal(hash, keys) { | |
var frst=keys.splice(0,1); | |
if(keys.length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# extract text node from xml file | |
# USAGE: | |
# xmltext.rb file_path xpath | |
require "rexml/document" | |
file = ARGV.shift.dup | |
xpath = ARGV.shift.dup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun coffee-run-file-saving () | |
"Run coffee script in current buffer in new window" | |
(interactive) | |
(if buffer-file-name | |
(progn | |
(save-buffer) | |
(set-buffer | |
(apply 'make-comint "CoffeeRun" | |
coffee-command nil (cons buffer-file-name '()))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recursivePush(arr, val) { | |
var execPush = false; | |
arr.forEach(function(_v) { | |
if(_v instanceof Array) { | |
recursivePush(_v, val); | |
} else { | |
execPush = true; | |
} | |
}); | |
if(execPush || !arr.length) { arr.push(val); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recurClone(input) { | |
var output = void(0), i, len; | |
if(input instanceof Array) { | |
output = []; | |
for(i=0,len=input.length; i<len; i++) { | |
output.push(recurClone(input[i])); | |
} | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[&?]q=([^&#?]+)(?!.*[&?]q=[^&#?]+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$.fn.random = function(n) { | |
var elms = Array.prototype.slice.call(this), option = { | |
number: 1 | |
}, ret = []; | |
$.extend(option, { number: n}); | |
n = option.number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
// eventSettings: e.g. { eventName1: 2, eventName2: 3 } | |
$.fn.waitEvents = function(eventSettings, fn) { | |
var key, ret = {}, evts = eventSettings, | |
origEvts = $.extend(true, {}, evts); | |
for(key in evts) { | |
if(evts.hasOwnProperty(key)) { | |
this.bind(key, function(ev) { | |
var ley; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wordAtPoint(text, point) { | |
var wordRx = /[a-zA-Z_]+/, separatorRx = /(\s)/, | |
words, word, i, len, n; | |
words = text.split(separatorRx); | |
for (i = n = 0, len = words.length; i < len; i++) { | |
if (point < (n += words[i].length)) { | |
if (wordRx.test(words[i])) { | |
word = words[i]; |
OlderNewer