Skip to content

Instantly share code, notes, and snippets.

View chsh's full-sized avatar
👍
Love your code.

CHIKURA Shinsaku chsh

👍
Love your code.
View GitHub Profile
@chsh
chsh / git-tracker.rb
Created October 11, 2013 03:35
Open Pivotal Tracker url from feature/nnnnnnn.
#!/usr/bin/env ruby
branch = `git rev-parse --abbrev-ref HEAD`.chomp
if branch =~ /^feature\/(\d+)$/
url = "http://www.pivotaltracker.com/story/show/#{$1}"
puts "Open #{url}"
exec "open #{url}"
else
puts "Ignore. Tracker branch should be feature/nnnnnnn."
end
@chsh
chsh / checkspeed.sh
Created October 26, 2013 02:54
Check internet connection speed using curl's result. :-)
#!/bin/bash
# clear log
cat /dev/null > speed.log
for i in {0..15}
do
echo "Starting $i/15"
echo "speedtest server" >> speed.log
date >> speed.log
@chsh
chsh / get_url_shorten_service_list.rb
Created November 4, 2013 01:13
Get URL Shorten service list from LongURL.
require 'open-uri'
require 'json'
url = 'http://api.longurl.org/v2/services?format=json'
r = open(url, 'User-Agent' => 'Your-Script-Name/1.0').read
j = JSON.parse r
puts j.values.map { |v| v['domain'] }
@chsh
chsh / settings.rb
Created November 9, 2013 05:33
Read multiple setting files in Settingslogic.
class Settings < Settingslogic
# load default app
cf = File.join(Rails.root, 'config', 'settings', 'application.yml')
source cf if File.exist? cf
cf = File.join(Rails.root, 'config', 'settings', "#{Rails.env}.yml")
instance.deep_merge! Settings.new(cf) if File.exist? cf
end
@chsh
chsh / cap3-todo.md
Created December 7, 2013 14:32
Reminder to upgrade Capistrano 2 to 3.

Changes

  1. shared/pids -> shared/tmp/pids
  2. cp shared/system/* shared/public/system/
  3. change pid path for /etc/init.d/unicorn

TODOs

  1. delayed_job tasks integration.
@chsh
chsh / prepare-rbenv.sh
Created January 8, 2014 16:30
Prepare rbenv with git installation for Ubuntu 13.10.
sudo aptitude install git
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
@chsh
chsh / stdin_string.rb
Created February 10, 2014 07:53
You can chain string with shell command output. -> StdinString.new(`ls -l`).run('grep *.pid')
require 'tempfile'
class StdinString < String
def run(*commands)
r = `cat #{tf.path} | #{commands.join(' ')}`
remove_tf
StdinString.new r
end
private
@chsh
chsh / git-release
Created March 22, 2014 03:48
Shortcut git flow release process.
#!/bin/sh
pfx='rel'
d=`date +%Y%m%d%H%M%S`
git flow release start $pfx-$d
git flow release finish -m"Release:$d" $pfx-$d
@chsh
chsh / unicorn-rbenv
Created April 15, 2014 14:56
unicorn with rbenv init.d script
#!/bin/sh
#
# chkconfig: 345 98 20
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by [email protected] http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
@chsh
chsh / git-issue
Created April 26, 2014 15:54
Create issue for GitLab and create task for Todoist same time.
#!/usr/bin/env ruby
require 'cgi'
gem 'gitlab'
gem 'todoist'
require 'gitlab'
require 'todoist'
class IssueCreator