Skip to content

Instantly share code, notes, and snippets.

# echo に -n オプションを付けないと改行が入ってしまい、正しくないハッシュ値になってしまう。
echo -n "password" | sha1sum - | tr a-z A-Z
@momo-lab
momo-lab / forgot-colon.rb
Created June 1, 2012 13:53
コマンドを打つときにコロンを付け忘れる派の人のためのearthquake.gem用プラグイン
# -*- coding: utf-8 -*-
# earthquake.gem plugin
# execute command even if you forgot colon
Earthquake.init do
input_filter do |text|
if (command = command(":#{text}")) and confirm("execute :#{text}", :y)
input(":#{text}")
return nil
end
text
@momo-lab
momo-lab / pocket.rb
Created May 31, 2012 14:35
Pocket(旧 ReadItLater)にツイート内のURLを追加するearthquake.gem用プラグイン
# -*- coding: utf-8 -*-
# earthquake.gem plugin
# add url to Pocket(http://getpocket.com)
require 'uri'
require 'open-uri'
Earthquake.init do
cfg = config[:pocket] || {}
command :pocket do |m|
pocket_uri = URI.parse('https://readitlaterlist.com/v2/add')
@momo-lab
momo-lab / marker.rb
Created May 29, 2012 11:13
「ここまで読んだ」マークを付けるearthquake.gem用プラグイン
# -*- coding: utf-8 -*-
# earthquake.gem plugin
# insert maker
Earthquake.init do
cfg = config[:marker] || {}
command :marker do
input(":marker #{cfg[:comment]}")
end
@momo-lab
momo-lab / deep_expand_url.rb
Created May 29, 2012 05:37
短縮URLを展開するearthquake.gem用プラグイン。…短縮じゃないやつでもひたすら展開するけど。
# -*- coding: utf-8 -*-
# earthquake.gem plugin
# expand url
require 'open-uri'
require 'uri'
require 'net/http'
def get_location(url)
begin
url = URI.parse(url.to_s)
@momo-lab
momo-lab / clear.rb
Created May 29, 2012 01:05
コンソールをクリアするだけのearthquake.gem用プラグイン
# -*- coding: utf-8 -*-
# earthquake.gem plugin
# screen cleaer command
Earthquake.init do
command :clear do
system "clear"
end
help :clear, "clear screen"
end
@momo-lab
momo-lab / cr.bat
Created May 16, 2012 08:29
Eclipseのプロジェクト/Subversion/Gitのルートに移動するWindows用バッチファイル
@ECHO OFF
REM プロジェクトのルートディレクトリに移動する。
REM PUSHDしてあるので、元のディレクトリに戻りたい場合はPOPDすればよい。
REM
REM ルートディレクトリの定義(上位ほど優先順位高)
REM .projectファイルがある(Eclipseのプロジェクトルート)
REM .gitディレクトリがある(gitのルート)
REM .svnディレクトリがあるtrunkディレクトリ(svnのルート)
PUSHD .
@momo-lab
momo-lab / optparse.sh
Created May 15, 2012 10:31
オプションの説明文(ヘルプ)内容から、オプションの解析を行うbash用スクリプト
#!/bin/bash
# コマンドの説明(ヘルプ)の文章をそれなりに解釈して、
# 引数のオプション解析を行うbash用関数
#
# 詳しくは後ろの方にある使用例を参照のこと。
function optparse() {
if [[ ! $optparse_prefix ]]; then
optparse_prefix="opt_"
fi
var util = require('util');
var url = require('url');
var http = require('http');
function download(u) {
u = url.parse(u)
var client = http.createClient(u.port || 80, u.hostname);
var req = client.request('GET', u.pathname, {host: u.hostname});
req.end();
req.on('response', function(res) {
@momo-lab
momo-lab / support_http_proxy_auth.diff
Created May 10, 2012 06:30
gistコマンドでProxy認証を使えるようにする差分。SSLのverifyがうまく動かなかったのでNONEにしてしまったので、なんとなくforkするのがはばかられる
diff --git a/lib/gist.rb b/lib/gist.rb
index d0be256..2274d7e 100644
--- a/lib/gist.rb
+++ b/lib/gist.rb
@@ -33,11 +33,17 @@ module Gist
PROXY = URI(ENV['HTTPS_PROXY'])
elsif ENV['HTTP_PROXY']
PROXY = URI(ENV['HTTP_PROXY'])
+ elsif ENV['http_proxy']
+ PROXY = URI(ENV['http_proxy'])