Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
# doesn't work on thin and webrick
set :server, 'mongrel'
get '/' do
boundary = 'ThisRandomString'
response['Content-Type'] = 'multipart/x-mixed-replace;boundary=' + boundary
require 'rubygems'
require 'sinatra'
# doesn't work on thin and webrick
set :server, 'mongrel'
get '/' do
<<HTML
<html>
<head>
module Rack
class Glitch
def initialize(app, options = {})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
if headers['content-type'] =~ /jpeg/
require 'rubygems'
require 'tidy'
module Rack
class CleanHTML
def initialize(app, options = {})
options = options.dup
Tidy.path = options.delete(:tidy_path)
require 'rubygems'
require 'sinatra'
require 'open-uri'
# doesn't work on thin and webrick
set :server, 'mongrel'
get '/' do
boundary = 'ThisRandomString'
response['Content-Type'] = 'multipart/x-mixed-replace;boundary=' + boundary
// ==UserScript==
// @name make b.hatena.jp/youpy usable
// @namespace http://d.hatena.ne.jp/youpy/
// @include http://b.hatena.ne.jp/youpy*
// @require https://raw.github.com/gist/3242/62166dfb4126bfd1b26ba586551fe96c469aec77/dollarX.js
// ==/UserScript==
$X('//style')[0].innerHTML = '';
#!/usr/bin/env ruby
require 'rubygems'
require 'pit'
require 'scissor/echonest'
config = Pit.get('echonest.com', :require => {
'api_key' => 'your Echo Nest API key'
})
Scissor.echonest_api_key = config['api_key']
#!/usr/bin/env ruby
require 'rubygems'
require 'pit'
require 'gdata'
title = 'ieijiroflashcards'
config = Pit.get('google.com', :require => {
'username' => 'your google.com username',
'password' => 'your google.com password'
})
;; kill ring をOSX のクリップボードと共有
;; http://blog.lathi.net/articles/2007/11/07/sharing-the-mac-clipboard-with-emacs
;; http://d.hatena.ne.jp/edvakf/20080929/1222657230
(defun copy-from-osx ()
;; (shell-command-to-string "pbpaste"))
(shell-command-to-string "__CF_USER_TEXT_ENCODING=0x$(printf %x $(id -u)):0x08000100:14 pbpaste | nkf -W"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
;; (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
#!/usr/bin/env ruby
# usage: git-commit-as github-username -m 'commit message'
require 'open-uri'
require 'rexml/document'
def main
username = ARGV.shift
userid = userid(username)