Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am f440 on github.
  • I am f440 (https://keybase.io/f440) on keybase.
  • I have a public key whose fingerprint is 4092 7D7D F720 F29F 312D 7FEA 951C 83FA 73A9 9D00

To claim this, I am signing this object:

@f440
f440 / aws-env
Last active November 6, 2015 03:38
eval "$(aws-env XXX)" することで、 credential から XXX profile を探して AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION をセット
#!/usr/bin/env ruby
class Parser
# python's config format: https://docs.python.org/2/library/configparser.html
def self.parse(contents)
sections = {}
contents.each_line do |line|
case line
when /\s*[#;]/, /^\s*$/
# skip
@f440
f440 / .gitignore
Created June 23, 2015 14:48
Terraform Template
terraform.tfstate*
@f440
f440 / redis_watch.rb
Last active August 29, 2015 14:07
redis-rb で watch
require 'redis'
require 'hiredis'
# usage:
# 端末(1) : 更新し続ける
# watch -n 0.1 "echo incr r | redis-cli"
# 端末(2) : watch しつつ更新する
# ruby redis_watch.rb 1000000
r = Redis.new(driver: :hiredis, timeout: 60) # デフォルトだと、5秒でタイムアウト
@f440
f440 / nginx-openresty.init
Created September 22, 2014 03:47
nginx-openresty init file
#!/bin/sh
#
# nginx-openresty - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse ¥
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/openresty/nginx/conf/nginx.conf
# config: /etc/sysconfig/nginx
@f440
f440 / curl.log
Last active August 29, 2015 14:06
HTTP 1.0 で画像にアクセス # curl --verbose --http1.0 https://pbs.twimg.com/media/B.....
* Adding handle: conn: 0x7fdc20804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fdc20804000) send_pipe: 1, recv_pipe: 0
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to pbs.twimg.com port 443 (#0)
* Trying 117.18.237.139...
@f440
f440 / zsh-autosuggestions.rb
Created April 30, 2014 01:59
brew install ./zsh-autosuggestions.rb --HEAD
require 'formula'
class ZshAutosuggestions < Formula
homepage 'https://github.com/tarruda/zsh-autosuggestions'
head 'https://github.com/tarruda/zsh-autosuggestions.git'
def install
(share/'zsh-autosuggestions').install Dir['*']
end
@f440
f440 / evernote2txt.rb
Created April 20, 2014 14:32
Evernote xml (enex) to txt
#!/usr/bin/env ruby
#-*- encoding: utf-8 -*-
# http://blog.evernote.com/tech/2013/08/08/evernote-export-format-enex/
require 'nokogiri'
require 'date'
require 'ostruct'
class Note < OpenStruct; end
@f440
f440 / pass.zsh
Created April 5, 2014 14:51
Incremental search for pass by zaw
# -*- sh -*-
# [Pass](http://www.zx2c4.com/projects/password-store/)
# the standard unix password manager
# [zaw](https://github.com/zsh-users/zaw)
# zsh anything.el-like widget
function zaw-src-pass() {
candidates=("${(ps:\n:)$(builtin cd ~/.password-store >/dev/null ; find . -type f ! -name .gpg-id | sed -e 's/\.\/\(.*\).gpg$/\1/')}")
actions=("zaw-callback-pass-append-to-buffer")
@f440
f440 / delicious2pinboard.rb
Created March 30, 2014 11:41
Import from delicious to pinboard
#!/usr/bin/env ruby
require 'nokogiri'
require 'date'
require 'faraday'
html = Nokogiri::HTML(open("delicious.html"))
posts = []
html.xpath("//dd | //dt").each do |element|