Skip to content

Instantly share code, notes, and snippets.

View kminiatures's full-sized avatar

kmini kminiatures

  • tokyo
View GitHub Profile
@kminiatures
kminiatures / reset_date_by_exif.rb
Last active August 29, 2015 14:00
reset jpg file created,updated time by exif. for mac.
#!/usr/bin/env ruby
require 'time'
# usage
# resetdate.rb *.jpg
ARGV.each do |file|
exif = {}
`jhead #{file}`.strip.split("\n").each do|exif_data|
k,v = exif_data.split(/ +: /)
git co master; git pull; git co -; git merge master
@kminiatures
kminiatures / Dash and MacVim snipet bug
Created May 12, 2014 02:35
last 8 charactor deleting
# snipet ( abbreviation: code.. )
----------------------
```@cursor```
----------------------
# example
----- before ---------
1234567890
1234567890
@kminiatures
kminiatures / gist:df34f50e390b80f51a4c
Created May 23, 2014 02:01
bitbucket pull-request POST hook to Slack chat
<?
function hash_value($obj, $keys){
if(empty($keys)) return $obj;
$key = array_shift($keys);
if(isset($obj[$key])){
return hash_value($obj[$key], $keys);
}else{
return '';
}
}
@kminiatures
kminiatures / gist:a7e0ae99ada406bcac41
Created June 19, 2014 06:04
remove color sequence
sed -e 's/.\[[0-9]\{1,2\}m//g' colored.log
@kminiatures
kminiatures / gist:5a9855f70d0341c9ad46
Created August 1, 2014 05:33
mysql select を配列でかえす
class MySQL
def initialize(database, password, user = 'root')
@database = database
@password = password
@user = user
end
def select(sql)
rows = []
`mysql -u#{@user} -p#{@password} #{@database} -e "#{sql} \\G"`.strip.split(/\*\*\*\*.*/).each do |result|
@kminiatures
kminiatures / peco-kill
Created August 22, 2014 03:01
incremental search, the process you want to kill.
function peco-kill(){
proc=`ps aux | peco`
pid=`echo "$proc" | awk '{print $2}'`
echo "kill pid:$pid. [$proc]"
kill $pid
}
@kminiatures
kminiatures / peco-hist
Last active August 29, 2015 14:05
incremental search for history using peco.
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
}
@kminiatures
kminiatures / MySQL.rb
Created September 25, 2014 04:55
small mysql exec
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
@kminiatures
kminiatures / gist:5d21bcc2ab3899a0629a
Last active August 29, 2015 14:17
merged_branch for bash_completion
# 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.