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
# inspired by http://www.msng.info/archives/2012/12/php-not.php | |
module AutoNot | |
def method_missing(method, *args) | |
if /\Anot_(.*\?)\z/ =~ method | |
! send($1, *args) | |
end | |
end | |
end |
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 | |
# nautilus script: send to running emacs | |
echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | xargs -I XX sh -c 'emacsclient -e "(find-file \"XX\")" || gdialog --msgbox "coluld not open XX"' |
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 | |
exec dc -e "[d]sd[q]sq[p]sp[1+dljr%0=ddlg>a]sa[+z1<s]ss[dsj2/sg0laxs_z1=qlsxdlj=p]sx[lilxxclid1+silz!<l]sl$1sz1sillx" |
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/bash | |
get_col() { | |
local str=$1 fs=$2 keycol=$3 | |
local -a a | |
IFS=$fs a=($str) | |
echo ${a[$keycol]} | |
} | |
cmp_str() { [[ $1 < $2 ]]; } |
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
# answer of http://d.hatena.ne.jp/Yamashiro0217/20120727/1343371036 | |
## q1 | |
cat log.txt | |
## q2 | |
cut -d , -f 1,4 log.txt | |
## q3 | |
grep ^server4 log.txt | |
## q4 | |
wc -l < log.txt | |
## q5 |
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
(require 'hi-lock) | |
(defun grepf->regexp (file) | |
(with-temp-buffer | |
(insert-file-contents file) | |
(goto-char (point-max)) | |
(when (looking-back "\n") | |
(delete-char -1) ) | |
(goto-char (point-min)) | |
(while (search-forward "\n" nil t) |
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 | |
require 'nokogiri' | |
require 'open-uri' | |
def scrape | |
html = open('http://forkwell.com/') {|io| io.read } | |
Nokogiri::HTML(html, 'utf-8').css('div.grid-unit').map do |sect| | |
title = sect.css('header h1 a')[0]['alt'] | |
items = [] |
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
(defvar marusuji-ary ["⓪" "①" "②" "③" "④" "⑤" "⑥" "⑦" "⑧" "⑨" | |
"⑩" "⑪" "⑫" "⑬" "⑭" "⑮" "⑯" "⑰" "⑱" "⑲" | |
"⑳" "㉑" "㉒" "㉓" "㉔" "㉕" "㉖" "㉗" "㉘" "㉙" | |
"㉚" "㉛" "㉜" "㉝" "㉞" "㉟" "㊱" "㊲" "㊳" "㊴" | |
"㊵" "㊶" "㊷" "㊸" "㊹" "㊺" "㊻" "㊼" "㊽" "㊾" "㊿" ]) | |
(defun region-to-marusuji (beg end) | |
(interactive "r") | |
(let ((n (string-to-int (buffer-substring beg end)))) | |
(when (and (<= 0 n) (<= n 50)) |
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/bash | |
udisks --monitor | while read ev; do | |
if [[ "$ev" == changed:* ]]; then | |
dev=${ev##*/} | |
if [[ "$dev" == *_* ]]; then | |
dev=$(echo -e ${dev//_/\\x}) # "_2d" -> "-" | |
fi | |
mp=$(udisks --show-info "/dev/$dev" | sed -n '/^ mount paths: */{s///;p}') | |
if [ -n "$mp" ]; then | |
notify-send mounted "$dev -> $mp" |
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
diff -up ruby-1.9.2-p290/ruby.c filter-ruby-1.9.2-p290/ruby.c | |
--- ruby-1.9.2-p290/ruby.c 2010-12-23 19:49:13.000000000 +0900 | |
+++ filter-ruby-1.9.2-p290/ruby.c 2011-10-28 21:50:44.452623054 +0900 | |
@@ -1618,7 +1618,16 @@ load_file_internal(VALUE arg) | |
return (VALUE)rb_parser_compile_string(parser, fname, f, line_start); | |
} | |
rb_funcall(f, set_encoding, 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-")); | |
- tree = rb_parser_compile_file(parser, fname, f, line_start); | |
+ { | |
+ VALUE source_filter = rb_intern("source_filter"); |