Skip to content

Instantly share code, notes, and snippets.

View kminiatures's full-sized avatar

kmini kminiatures

  • tokyo
View GitHub Profile
@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 / bump_version.rb
Created August 24, 2017 03:36
bump version script. 1.2.3 => 1.2.4
#!/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)
@kminiatures
kminiatures / double_width.rb
Created January 5, 2017 09:48
幅の広い文字がある場合の ljust である ljust_w を String に追加する...
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
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}"
@kminiatures
kminiatures / emoji-search.html
Last active March 2, 2016 00:56
utf emoji search
<!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;
/*
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 / private.xml
Created June 19, 2015 04:12
Karabiner hjkl Setting for Phots.app
<?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>
@kminiatures
kminiatures / translate.rb
Created April 10, 2015 03:58
Alfred Microsoft Translator Workflow
#!/usr/bin/env ruby
# -*- coding:utf-8 -*-
require 'net/http'
require 'rexml/document'
require 'json'
class Alfred
def initialize
@items = []
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.
@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