Skip to content

Instantly share code, notes, and snippets.

View pokutuna's full-sized avatar
👁️
👄👁👂

pokutuna pokutuna

👁️
👄👁👂
View GitHub Profile
object Timing {
def measure[T](taskName:String)(exec: => T):Unit = {
val begin = System.currentTimeMillis()
val result = exec
val end = System.currentTimeMillis()
println(taskName + ": " + (end - begin).toFloat / 1000 + " sec")
return result
}
}
@pokutuna
pokutuna / script.patch
Created April 4, 2011 06:08
gyazo through proxy
*** script 2011-04-04 14:33:41.000000000 +0900
--- script.proxy 2011-04-04 14:55:51.000000000 +0900
***************
*** 60,83 ****
'User-Agent' => UA
}
! Net::HTTP.start(HOST,80){|http|
res = http.post(CGI,data,header)
! url = res.response.to_ary[1]
n = gets.to_i
prims = []
list = (2..n).to_a
while true
head = list.shift
prims.push head
list.delete_if{ |i| i % head == 0 }
;;;init.el
;; load-path追加関数
(defun add-to-load-path (&rest paths)
(let (path)
(dolist (path paths paths)
(let ((default-directory (expand-file-name (concat user-emacs-directory path))))
(add-to-list 'load-path default-directory)
(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
(normal-top-level-add-subdirs-to-load-path))))))
proxy='http://proxy.ksc.kwansei.ac.jp:8080'
apply_proxy()
{
export http_proxy=$1
export ALL_PROXY=$1
git config --global http.proxy "$1"
}
//http://www29.atwiki.jp/tmiya/pages/55.html
import scala.annotation.tailrec
object Exercises {
def succ(n:Int) = n + 1
def pred(n:Int) = n - 1
@tailrec
def add(x:Int, y:Int):Int =
#usage $ ruby generate_gemset.rb gemdir
path = ARGV[0]
gems = Dir.glob(path + '/*').map{ |i| File.basename(i)}
File.open('generated.gems','w'){ |f|
gems.each do |g|
gem = g.split(/(.*)-(.+)$/)
f.puts gem[1] + ' -v' + gem[2]
end
}
import java.sql.*;
public class SQLiteSample {
public static void main(String[] args) {
try {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:sensing.db");
Statement stat = conn.createStatement();
import java.util.*;
import com.pokutuna.lifelog.db.model.SensingModel.BtDetected;
public class SetSample {
public static void main(String[] args) {
//もともとあるリスト
List<String> list = new LinkedList<String>();
list.add("hoge");
list.add("hoge");