Skip to content

Instantly share code, notes, and snippets.

View ghiden's full-sized avatar

Hidenari Nozaki ghiden

View GitHub Profile
@ghiden
ghiden / nodejs_decode_sample.js
Created June 29, 2011 05:11
decode a base64 encoded image file with node.js
var fs = require('fs'),
decode64 = require('base64').decode;
var data = fs.readFileSync('./encode.png', 'base64');
var buffer = new Buffer(data, 'base64');
fs.writeFileSync('./decode.png', decode64(buffer), 'binary')
@ghiden
ghiden / chromeThis
Created November 18, 2011 06:38
from Safari, open this page in Chrome
property theURL : ""
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
tell application "Google Chrome"
if not (window 1 exists) then
make new window
end if
@ghiden
ghiden / amqp_consumer.rb
Created January 20, 2012 08:16
ruby and node.js message exchange via rabbitmq
require 'amqp'
EventMachine.run do
connection = AMQP.connect(:host => '127.0.0.1', :username => 'guest', :password => 'guest')
puts "Connecting to AMQP broker. Running #{AMQP::VERSION} version of the gem..."
channel = AMQP::Channel.new(connection)
queue = channel.queue("rubyqueue", :auto_delete => true)
exchange = channel.default_exchange
@ghiden
ghiden / schedule.rb
Created March 28, 2012 06:09
specifying which day for "Whenever" gem
#https://github.com/javan/whenever
set :output, "#{path}/logs/cron.log"
every [:sunday, :monday, :tuesday, :wednesday, :thursday], :at => "15:50" do
command "ruby #{path}/something.rb"
end
@ghiden
ghiden / open-starred-n-unstar-em.py
Created April 27, 2012 13:13
Open Google Reader's Starred items in browser
#!/usr/bin/env python
import sys
import gdata.service
import subprocess
import getpass
import urllib
import re
import os
import ConfigParser
@ghiden
ghiden / bargraph.css
Last active May 29, 2024 01:29
D3.js bar graph example
.chart {
background: #b0e0f8;
margin: 5px;
}
.chart rect {
stroke: white;
fill: steelblue;
}
@ghiden
ghiden / mine.zsh-theme
Last active October 10, 2015 08:48
oh-my-zsh prompt with rbenv version along with git stuff
function ruby_version() {
echo `rbenv version | sed -e 's/ .*//'`
}
PROMPT='%{$fg[yellow]%}$(ruby_version)%{$fg[yellow]%} %{$fg_bold[red]%}➜ %{$fg_bold[green]%}%~ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}
$ '
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}] %{$fg[yellow]%}✗%{$reset_color%}"
@ghiden
ghiden / scala_grouped_and_sliding
Created February 6, 2013 10:11
Scala grouped and sliding
scala> val a = (1 to 10).toList
a: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> for (x <- a.grouped(2)) println(x)
List(1, 2)
List(3, 4)
List(5, 6)
List(7, 8)
List(9, 10)
@ghiden
ghiden / gitconfig
Created February 18, 2013 02:13
git config
[user]
name = ...
email = [email protected]
[core]
autocrlf = input
safecrlf = true
[alias]
co = checkout
ci = commit
st = status
HTML Font Size mapping
1: < 12px
2: < 15px
3: < 17px
4: < 21px
5: < 28px
6: < 40px
7: >= 40px