Skip to content

Instantly share code, notes, and snippets.

View potix2's full-sized avatar
:octocat:

Katsunori Kanda potix2

:octocat:
View GitHub Profile
@potix2
potix2 / gist:5211862
Last active December 15, 2015 05:49
Example: Multiple Assignment in groovy
list = [1, 2, 3]
def (c, d, e) = list
println c
println d
println e
@potix2
potix2 / core.clj
Created March 17, 2013 09:28
example of carmine
(ns carmine-test.core
(:require [taoensso.carmine :as car])
(:require [taoensso.carmine.locks :as carl]))
(def pool (car/make-conn-pool))
(def spec-server1 (car/make-conn-spec))
(defmacro wcar [& body] `(car/with-conn pool spec-server1 ~@body))
(wcar
@potix2
potix2 / td2json.pl
Last active December 14, 2015 16:18
スレッドダンプからRUNNABLEなものだけ抽出する
#!/usr/bin/perl -w
#usage: perl td2json.pl < jvm-thread-dump.log
use strict;
use warnings;
use JSON;
my $buf = '';
my $row = 0;
my $thread_info = {};
@potix2
potix2 / gist:5024367
Created February 24, 2013 16:12
compojure example
(ns adder.handler
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]))
(defn parse-input [s]
(Integer. (re-find #"[0-9]*" s)))
(def fibs
((fn rfib
@potix2
potix2 / gist:4562014
Created January 18, 2013 02:55
repeatedly execute commands
#!/bin/sh
#example:
#
#$repeat 3 echo 'hoge'
#hoge
#hoge
#hoge
N=$1
@potix2
potix2 / gist:4407555
Created December 29, 2012 15:27
非同期処理の完了を待つ
//継続的デリバリー p.265から
private void ConfirmEmailWasReceived() {
TimeStamp testStart = TimeStamp.NOW;
do {
if (EmailFound()) {
return;
}
Wait(SMALL_PAUSE);
} while(TimeStamp.NOW < testStart + DELAY_PRRIOD);
Fail("時間内にメールを受け取れなかった");
@potix2
potix2 / gist:4166134
Created November 29, 2012 01:29
botoでSNSを使う
#!/usr/bin/python
import boto.sns
import datetime
topic = 'arn:aws:sns:xxxx:xxx:xxx'
message = 'Hello World!'
conn = boto.connect_sns()
conn.publish(topic, message)
@potix2
potix2 / gist:3951125
Created October 25, 2012 07:16
fabric runs_once test
from fabric.api import env, task
from fabric.decorators import runs_once
env.hosts = ['host1','host2','host3']
@runs_once
def _pull():
print "pull artifacts"
@task
@potix2
potix2 / gist:3917056
Created October 19, 2012 09:00
get network address
#!/bin/sh
DEFAULTIF="eth0"
IPADDR=`/sbin/ifconfig $DEFAULTIF | grep "inet addr" | awk '{ print $2 }' | sed 's/addr://'`
NETMASK=`/sbin/ifconfig $DEFAULTIF | grep "inet addr" | awk '{ print $4 }' | sed 's/Mask://'`
NETADDR=`ipcalc -n "$IPADDR" "$NETMASK" | sed 's/NETWORK=//'`
echo "ip: $IPADDR"
echo "mask: $NETMASK"
echo "net: $NETADDR"
@potix2
potix2 / gist:3686783
Created September 9, 2012 19:41
Add ssh verbose mode for Vagrant
diff --git a/config/default.rb b/config/default.rb
index 8a50b7e..2dfb27a 100644
--- a/config/default.rb
+++ b/config/default.rb
@@ -11,6 +11,7 @@ Vagrant.configure("1") do |config|
config.ssh.forward_agent = false
config.ssh.forward_x11 = false
config.ssh.shell = "bash -l"
+ config.ssh.verbose = false