Skip to content

Instantly share code, notes, and snippets.

@hara-y-u
hara-y-u / gist:1950055
Created March 1, 2012 14:10
同期的にシェルコマンドを実行して出力を返す elisp 関数
(defun exec-shell-command-sync (command &rest args)
(let (ret
(process
(apply 'start-process-shell-command "exec" nil command args)))
(set-process-filter
process
'(lambda (process output)
(setq ret (cons output ret))
))
(while (not (equalp (process-status process) 'exit))
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix(https://www.google.co.jp/reader),
url-prefix(https://www.google.com/reader) {
#gb:not(:hover),
#gb:not(:hover) > * {
max-height: 5px !important;
}
@hara-y-u
hara-y-u / gist:1327332
Created October 31, 2011 11:47
Easy userAgent Access
var UA = (function(ua) {
var browsers = {
// Capture: Major#, #2, #3, #4, alphaBeta, alphaBeta#
ie: /InternetExplorer/
, fx: /firefox\/(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?(?:(a|b)(\d*))?/i
, cr: /Chrome/
, sf: /Safari/
, op: /Opera/
}, key, ret, obj = {};
@hara-y-u
hara-y-u / gist:1325883
Created October 30, 2011 13:04
get (alphabet) word at point
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];
@hara-y-u
hara-y-u / gist:1325845
Created October 30, 2011 12:16
wait for multiple events jQuery Plugin
(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;
@hara-y-u
hara-y-u / gist:1315679
Created October 26, 2011 07:24
ランダムな要素をフィルタするjQueryメソッド(プラグイン)
(function($){
$.fn.random = function(n) {
var elms = Array.prototype.slice.call(this), option = {
number: 1
}, ret = [];
$.extend(option, { number: n});
n = option.number;
@hara-y-u
hara-y-u / gist:1301274
Created October 20, 2011 14:26
Regex to extract google query from location.href
[&?]q=([^&#?]+)(?!.*[&?]q=[^&#?]+)
@hara-y-u
hara-y-u / recurClone.js
Created October 19, 2011 02:58
clone Array recursively
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 {
@hara-y-u
hara-y-u / recursivePush.js
Created October 18, 2011 09:56
push to array recursively
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); };
@hara-y-u
hara-y-u / coffee-run-file-saving.el
Created July 24, 2011 16:07
run coffee script file bound to current buffer
(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 '())))