Skip to content

Instantly share code, notes, and snippets.

View kminiatures's full-sized avatar

kmini kminiatures

  • tokyo
View GitHub Profile
/*
A.P. Shield 05 Demo Program
Created by @shigaku / KORESS
http://koress.jp/
http://twitter.com/shigaku
*/
int sensorPin = 4;
int ledPin = 13;
int sensorValue = 0;
@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 / gist:4f314baeb9cf6e0977ea
Last active September 10, 2018 11:51
munin temperature plugin. for Raspberry Pi and DS18B20
#!/bin/sh
case $1 in
config)
cat <<'EOM'
graph_title Temperature
graph_vlabel Temperature
temperature.label temperature
EOM
exit 0;;
@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
}