Skip to content

Instantly share code, notes, and snippets.

@machu
machu / oauth-sample.rb
Created August 19, 2009 03:18
OAuth Consumer Example with Sinatra: http://www.machu.jp/diary/20090818.html#p01
require 'rubygems'
require 'sinatra'
require 'oauth'
require 'twitter'
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
@maraigue
maraigue / devnull.rb
Created April 17, 2010 15:46
Ruby implementation of null file (like /dev/null on Un*x, NUL on Windows) The newest version is available by "gem install devnull". See also: http://github.com/maraigue/devnull
# NOTE:
# This version is out-of-date.
# Please access http://github.com/maraigue/devnull for the versions under development.
# Ruby implementation of null file (like /dev/null on Un*x, NUL on Windows)
# (C) 2010- H.Hiro(Maraigue) [email protected]
#
# DevNull works like an IO object. For example:
# dn = DevNull.new
# dn.puts "foo" # => nil (do nothing)
# sinatra でのリダイレクト設定
# hoge/ のような '/' 終わりを '/' 無しへリダイレクト
# ただし、 http://example.com の場合は末尾 '/' が付く
get %r{^(.+)/$} do |c|
redirect c, 303
end
# sinatra でのリダイレクト設定
# http://.../hoge のような '/' なしを '/' ありへリダイレクト
# ただし、 http://example.com の場合は末尾 '/' が付く
get %r{^(.+[^/])$} do |c|
redirect c + "/", 303
end
js <<EOM
// <c-x>
(function() {
liberator.modules.mappings.addUserMap([liberator.modules.modes.COMMAND_LINE], ['<c-x>'],
"insert current URL to command line",
function () {
var curcmd = ':' + commandline.command;
if (!curcmd.match(/ $/)) curcmd += ' ';
commandline.open(curcmd, liberator.modules.buffer.URL);
}
command! -nargs=+ lazy autocmd VimperatorEnter .* <args>
lazy fmaps -urls='^http://twitter\.com/' j k ?
lazy fmaps -urls='^http://twitter\.com/' -events=vkeydown n m t r gh gr gp gf gm
@gyuque
gyuque / gist:627852
Created October 15, 2010 08:33
repl.rb
require 'rubygems'
require 'json'
require 'net/telnet'
target_url = "http://www.jewelpet.jp/"
prompt = /^repl> /
INJECT_JS = <<EOS
repl.print( (function(doc){
var _j = function(s) {
@seki
seki / otto.rb
Created December 11, 2010 13:01
require 'drb'
require 'pp'
require 'net/https'
require 'oauth'
require 'json'
class JSONStream
def initialize(drop)
@buf = ''
@drop = drop
@hryk
hryk / glitch.rb
Created May 10, 2011 11:13
glitch your display.
#!/usr/bin/env macruby
#
# MacRubyで画面グリッチをフルスクリーン表示する
#
# http://twitter.com/negipo/status/67572370247913473
#
# ## Usage
#
# ./glitch.rb
#
#!/usr/bin/env ruby
SOI = "\xff\xd8"
APP0 = "\xff\xe0"
DQT = "\xff\xdb"
DHT = "\xff\xc4"
SOF0 = "\xff\xc0"
SOS = "\xff\xda"
EOI = "\xff\xd9"