Skip to content

Instantly share code, notes, and snippets.

@nikushi
nikushi / wordpressdotcom.rb
Created February 14, 2012 06:44
A tool to migrate wordpress xml file to jekyll. This is a copied version and I modified a bit for my wordpress data compatibirity. The original is here https://github.com/mojombo/jekyll .
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'yaml'
require 'time'
# for multi byte string
require 'stringed'
require 'nkf'
@nikushi
nikushi / private.xml
Created February 25, 2012 16:16
swap Tab + Command key with Tab + Ctrl key only in Terminal.app by using KeyRemap4Macbook
<?xml version="1.0"?>
<root>
<list>
<item>
<name>Command_L+Tab to Control_L+Tab (TERMINAL ONLY)</name>
<only>TERMINAL</only>
<identifier>private.remap.app_term_commandL_tab_2_to_controlL_tab_2</identifier>
<autogen>--KeyToKey--
KeyCode::TAB, ModifierFlag::COMMAND_L,
KeyCode::TAB, ModifierFlag::CONTROL_L
@nikushi
nikushi / instag.rb
Created March 20, 2012 12:45
A Liquid tag for Jekyll sites that allows embedding image file on Instagram.
# Title: A Liquid tag for Jekyll sites that allows embedding image file on
# Instagram.
# Authors: Nobuhiro Nikushi https://twitter.com/#!/niku4i
# Description: Easily embed image file on Instagram page.
#
# Syntax {% instag [class name(s)] http://instagr.am/p/IYYs5bo0jd/ [width [height]] [title text | "title text" ["alt text"]] %}
#
# Examples:
# {% instag http://instagr.am/p/IYYs5bo0jd/ %}
# {% instag left half http://instagr.am/p/IYYs5bo0jd/ my title %}
#!/usr/bin/env ruby
#
# Dump subtitle in text for TED
#
require 'json'
require 'open-uri'
base_url = 'http://www.ted.com/talks/subtitles'
@nikushi
nikushi / server.rb
Created April 30, 2012 16:30
A sample implementation of streaming server to make a lot concurrency connections. The connections are keepalived by server!
require 'sinatra'
require 'eventmachine'
get '/' do
stream :keep_open do |out|
interval = 1
size = 1000
EventMachine::PeriodicTimer.new(interval) { out << "#{gen_data(size)}\n" }
end
end
@nikushi
nikushi / .fetchmailrc
Created August 30, 2012 04:43
dot.fetchmailrc
set logfile "path/to/log"
defaults
protocol POP3
uidl
# fetchall
keep
no mimedecode
mda "/usr/local/bin/maildrop"
poll mail.example.com
@nikushi
nikushi / .maildrop
Created August 30, 2012 04:50
my maildrop filter
HOME="/home/nikushi"
MAILDIR="$HOME/Maildir"
DEFAULT="$MAILDIR/"
CONF="$HOME/etc/maildrop"
logfile "$HOME/log/maildrop.log"
### turn on when debug ###
#VERBOSE=5
ME="nikushi@example.com"
@nikushi
nikushi / etc_maildrop_archive
Created August 30, 2012 05:00
受信メールを日付フォルダにコピーするmaildropレシピ
HOME="/home/nikushi"
ARCHIVEBASE="$HOME/Maildir.Archives"
# parse Date: value
D=`egrep ^Date: | \
sed -e 's/^Date: *//' | \
perl -MDate::Parse -ne 'print Date::Parse::str2time("$_")' \
| perl -ne '@t=localtime($_); printf("%d%02d%02d",@t[5]+1900,@t[4]+1,@t[3])'`
if ( "$D" eq "" )
@nikushi
nikushi / etc_maildrop_mail2html
Created August 30, 2012 05:06
受信メールからメーリングリスト名を抽出しつつ、mhonarcに入力しhtml化するmaildropレシピ
HOME="/home/nikushi"
WWWBASE="$HOME/public_html/mail"
MLNAME=""
# is ML ?
if ( /^Subject:\s+\[(.+?)(:\s*[0-9]*|\s+[0-9]*|)\]\s+/ )
{
MLNAME=$MATCH1
}
if ( $MLNAME eq "" )
@nikushi
nikushi / private.xml
Created September 19, 2012 06:23
KeyRemap4Macbook Custom XML recipe to swap Command_R to Control_L only Terminal.app
<?xml version="1.0"?>
<root>
<list>
<item>
<name>Command_R to Control_L (TERMINAL ONLY)</name>
<only>TERMINAL</only>
<identifier>private.remap.app_term_commandR_2_to_controlL_2</identifier>
<autogen>--KeyToKey--
KeyCode::COMMAND_R,
KeyCode::CONTROL_L