This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
begin | |
OPTS = {unit: 'patch'} | |
opt = OptionParser.new | |
units = %w{major minor patch} | |
opt.on('-u [UNIT]', '--unit', units) {|v| OPTS[:unit] = v} | |
opt.parse!(ARGV) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def length_w | |
alpha = self.scan /[a-zA-Z0-9 ]/ | |
double = self.length - alpha.length | |
double * 2 + alpha.length | |
end | |
def ljust_w(width) | |
len = width - (self.length_w) | |
len = 0 if len < 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
class FindHeavyFile | |
def self.find(depth = 0) | |
size, file = `du -sh *`.strip.split("\n").max_by do |f| | |
size,file = f.split "\t" | |
to_bytes(size) | |
end.split("\t") | |
puts "#{' ' * depth}#{size} #{file}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv='content-type' content='text/html; charset=utf-8'> | |
<meta name="viewport" content="width=360,initial-scale=1"> | |
<title>emoji</title> | |
<style type="text/css"> | |
body{ | |
color: #666; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<root> | |
<!-- define Photos --> | |
<appdef> | |
<appname>PHOTOS</appname> | |
<equal>com.apple.Photos</equal> | |
</appdef> | |
<item> | |
<name>Use "hjkl" keys as arrow keys if you are not editing text for Photos.</name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding:utf-8 -*- | |
require 'net/http' | |
require 'rexml/document' | |
require 'json' | |
class Alfred | |
def initialize | |
@items = [] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash_completion | |
merged_branch () { | |
local branches | |
local input=$2 | |
branches=`git b --no-color --merged | grep -v master` | |
# echo $branches | |
COMPREPLY=($(compgen -W '$branches' -- $input)) | |
} | |
# Delete Remote(pub) and Local Branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySQL | |
def initialize(database) | |
@database = database.to_s | |
end | |
def exec(sql) | |
if sql =~ /\.sql$/ and File.exists? sql | |
sql = File.read(sql, encoding: Encoding::UTF_8) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function peco-hist() { | |
time_column=`echo $HISTTIMEFORMAT | awk '{printf("%s",NF)}'` | |
column=`expr $time_column + 3` | |
cmd=`history | tac | peco | sed -e 38;5;208m's/^ //' | sed -e 's/ +/ /g' | cut -d " " -f $column-` | |
history -s "$cmd" | |
eval $cmd | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function peco-kill(){ | |
proc=`ps aux | peco` | |
pid=`echo "$proc" | awk '{print $2}'` | |
echo "kill pid:$pid. [$proc]" | |
kill $pid | |
} |
NewerOlder