Skip to content

Instantly share code, notes, and snippets.

@Gab-km
Gab-km / github-flow.ja.md
Last active April 25, 2024 04:01 — forked from juno/github-flow.ja.md
GitHub Flow (Japanese translation)
# Rack middleware that drops non properly encoded cookies that would hurt the ActionDispatch::Cookies middleware.
#
# This is actually a hotfix for issues
# * https://github.com/rack/rack/issues/225
# * https://github.com/rails/rails/issues/2622
module CleanCookies
# Tests whether a string may be decoded as a form component
def decodable?(string)
URI.decode_www_form_component(string)
true
#!/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"
@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
#
@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
@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) {
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
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);
}
# sinatra でのリダイレクト設定
# http://.../hoge のような '/' なしを '/' ありへリダイレクト
# ただし、 http://example.com の場合は末尾 '/' が付く
get %r{^(.+[^/])$} do |c|
redirect c + "/", 303
end
# sinatra でのリダイレクト設定
# hoge/ のような '/' 終わりを '/' 無しへリダイレクト
# ただし、 http://example.com の場合は末尾 '/' が付く
get %r{^(.+)/$} do |c|
redirect c, 303
end