Skip to content

Instantly share code, notes, and snippets.

@stanaka
stanaka / ltsv2json.rb
Created February 16, 2013 15:36
a converter from LTSV to JSON.
#!/usr/bin/env ruby
require 'optparse'
require 'json'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: ltsv2json.rb [options]"
opts.on("-f", "--format FORMAT", "Select format.") do |v|
@stanaka
stanaka / moped_test.rb
Created February 22, 2013 09:41
a sample script to send LARGE requests to mongodb. note: mongodb cannot deal with this request properly.
require 'moped'
session = Moped::Session.new([ "127.0.0.1:27017" ])
session.use "test"
str = ''
1_000_000.times do
str << '0123456789'
end
@stanaka
stanaka / elscreen.el.patch
Created March 21, 2013 04:01
a patch for elscreen.el to use last-command-event instead of last-command-char, which is removed since emacs 24.3.
--- elscreen.el.original 2013-03-21 12:58:17.000000000 +0900
+++ elscreen.el 2013-03-21 12:59:05.000000000 +0900
@@ -984,7 +984,7 @@
(defun elscreen-jump ()
"Switch to specified screen."
(interactive)
- (let ((next-screen (string-to-number (string last-command-char))))
+ (let ((next-screen (string-to-number (string last-command-event))))
(if (and (<= 0 next-screen) (<= next-screen 9))
(elscreen-goto next-screen))))
@stanaka
stanaka / main.go
Created September 17, 2014 07:34
time.Now()を実行するだけのGo
package main
import "fmt"
import "time"
func main() {
t := time.Now()
fmt.Printf("Now: %v\n", t)
}
- Official Blog https://blog.docker.com/2014/10/announcing-docker-global-hack-day-2/
- Kick off presentation from the core team https://docker.com/community/globalhackday
-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.mackerel</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
#! /usr/bin/env ruby
$ioreg = `ioreg -r -n AppleSmartBattery`
$now = Time.now
def asb(item)
ret = $ioreg.match(/(#{item})[\"= ]+(\d+)$/)
ret[2].to_i
end
pidfile = "/usr/local/var/run/mackerel-agent.pid"
root = "/usr/local/var/mackerel-agent"
verbose = false
apikey = "APIKEY"
[plugin.metrics.battery]
command = "ruby /usr/local/bin/mackerel-osx-battery.rb"
#! /usr/bin/env ruby
$now = Time.now
$cmd = "/Users/stanaka/git/github.com/stanaka/mackerel-osx/smc"
def smc(item)
ret = `#{$cmd} read #{item}`
ret = ret.split(/\t/)
if ret[1]
ret[1].to_i