Skip to content

Instantly share code, notes, and snippets.

View irohiroki's full-sized avatar

Hiroki Yoshioka irohiroki

View GitHub Profile
mysql> select * from items;
+------+----+
| name | id |
+------+----+
| aaa | 1 |
| bbb | 2 |
| ccc | 3 |
| ddd | 4 |
+------+----+
4 rows in set (0.00 sec)
@irohiroki
irohiroki / gist:805622
Created February 1, 2011 09:14
A shell function that clones a github project into a directory of its account name.
# clone a github project
function clone {
# check arguments
acc=${1%%/*}
prj=${1##*/}
if [ -z "$acc" -o -z "$prj" ] ; then
echo 'usage: clone <github_account>/<project>'
return 1
fi
require 'ruby-debug'
require 'socket'
require 'forwardable'
class SporkDebugger
DEFAULT_PORT = 10_123
HOST = '127.0.0.1'
extend Forwardable
def_delegators :state, *[:prepare_debugger, :initialize]
diff --git a/lib/guard/spork/fake_spawn.rb b/lib/guard/spork/fake_spawn.rb
new file mode 100644
index 0000000..8551778
--- /dev/null
+++ b/lib/guard/spork/fake_spawn.rb
@@ -0,0 +1,7 @@
+module FakeSpawn
+ if RUBY_VERSION < '1.9'
+ def spawn(cmd)
+ system(cmd + ' >/dev/null 2>&1 < /dev/null &')
@irohiroki
irohiroki / gist:909284
Created April 8, 2011 04:27
jQuery Mobile Red theme for Buttons
.ui-btn-up-f, .ui-btn-hover-f, .ui-btn-down-f {
color: white;
font-weight: bold;
text-decoration: none; }
.ui-btn-up-f {
border: 1px solid #711414;
background: #ab2525;
text-shadow: 0 -1px 1px #711414;
background-image: -moz-linear-gradient(top, #c44f4f, #ab2525);
@irohiroki
irohiroki / gist:1300090
Created October 20, 2011 00:32
webrick oneliner function
function webrick {
if [ -z "$1" ] ; then
port=3333
else
port=$1
fi
ruby -rwebrick -e "WEBrick::HTTPServer.new(:DocumentRoot => './', :Port => ${port}).tap{|w| Signal.trap(:INT){w.shutdown()} }.start"
}
@irohiroki
irohiroki / blackhole.rb
Created October 28, 2011 16:18
A sinatra server that accepts POSTs from anywhere(!) ... and disposes them ;p
require 'sinatra'
configure do
set :port, 9999
end
allow_all = {
'Access-Control-Allow-Headers' => 'X-Requested-With, X-File-Name, Content-Type',
'Access-Control-Allow-Origin' => '*',
}
@irohiroki
irohiroki / singleton.coffee
Created December 1, 2011 02:11 — forked from meltingice/singleton.coffee
Example singleton class and example for Coffeescript
class Singleton
# We can make private variables!
instance = null
# Static singleton retriever/loader
@get: ->
unless instance
instance = new @
instance.init()
@irohiroki
irohiroki / cairo-test.rb
Created January 11, 2012 11:31
make a pdf doc of an image
require 'base64'
require 'cairo'
require 'stringio'
png_b64 = <<END
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAC7mlDQ1BJQ0Mg
UHJvZmlsZQAAeAGFVM9rE0EU/jZuqdAiCFprDrJ4kCJJWatoRdQ2/RFiawzb
H7ZFkGQzSdZuNuvuJrWliOTi0SreRe2hB/+AHnrwZC9KhVpFKN6rKGKhFy3x
zW5MtqXqwM5+8943731vdt8ADXLSNPWABOQNx1KiEWlsfEJq/IgAjqIJQTQl
VdvsTiQGQYNz+Xvn2HoPgVtWw3v7d7J3rZrStpoHhP1A4Eea2Sqw7xdxClkS
@irohiroki
irohiroki / singleton.coffee
Created January 17, 2012 00:30
Singleton class in CoffeeScript
app = window.app
class app.Singleton
instance = null
@get: ->
unless instance
instance = new this
instance.init()
instance