Skip to content

Instantly share code, notes, and snippets.

$ dig gori.me
; <<>> DiG 9.8.5-P1 <<>> gori.me
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2496
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
;gori.me. IN A
@a2ikm
a2ikm / gist:10471496
Created April 11, 2014 14:02
Defining private methods in concerning block hides public methods defined in following concerning
class A
extend ActiveSupport::Concern
def a
puts "a"
end
concerning :B do
def b
puts "b"
@a2ikm
a2ikm / bundle-open-with-shell
Created April 30, 2014 15:10
Set BUNDLER_EDITOR=/path/to/bundle-open-with-shell to open gem's directory with your shell by `bundle open GEM`
#!/usr/bin/env ruby
puts "Opening #{ARGV[0]}"
puts "Type `exit` to close this session."
exec ENV["SHELL"]
puts "Bye."
@a2ikm
a2ikm / HOW
Last active August 29, 2015 14:02
patch for git's diff-highlight to show utf8 strings properly. originally from https://gist.github.com/kaosf/d361cd5169fb36297d9c
$ wget https://raw.githubusercontent.com/git/git/34d9819e0a387be6d49cffe67458036450d6d0d5/contrib/diff-highlight/diff-highlight
$ wget https://gist.githubusercontent.com/a2ikm/2dbfb89114dfa5c543ed/raw/e2d8d550ef601c9310712f4187b803658427dd42/diff-highlight.utf8.patch
$ patch -u diff-highlight < diff-highlight.utf8.patch
$ chmod +x diff-highlight
@a2ikm
a2ikm / gist:2932d9b1a2cd290f5753
Created September 28, 2014 06:54
Get current AZ for specific RDS instance with aws-cli and jq
aws rds describe-db-instances | jq '.DBInstances[]|select(.DBInstanceIdentifier == "${INSTANCE_IDENTIFIER}")|{DBInstanceIdentifier,AvailabilityZone}'
@a2ikm
a2ikm / ec2knife-solo.rb
Last active August 29, 2015 14:07
Use like: ec2knife-solo cook -x ec2-user -i ~/.ssh/my-keypair.pem
#!/usr/bin/env ruby
SOLO_COMMANDS = %w(bootstrap clean cook prepare)
def usage
name = File.basename($0)
puts <<-EOF
Usage:
#{name} bootstrap [<options>]
@a2ikm
a2ikm / array_rstrip.rb
Last active August 29, 2015 14:17
Array#rstrip
class Array
def rstrip
index =
if block_given?
rindex { |item| !yield(item) }
else
rindex { |item| !item.nil? }
end
if index
@a2ikm
a2ikm / etc--pam.d--imap
Created April 21, 2015 16:27
postfix+saslauthdでPAMを通してshadow認証する
#%PAM-1.0
auth required pam_nologin.so
auth include system-auth
account include system-auth
session include system-auth
@a2ikm
a2ikm / webrick
Last active August 29, 2015 14:20
WEBrickを使ったdaemonなWebサーバ
#!/usr/bin/env ruby
#
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "optparse"
require "webrick"
include WEBrick
Process.setproctitle(File.basename(__FILE__)) if Process.respond_to?(:setproctitle)