Skip to content

Instantly share code, notes, and snippets.

@ponkore
ponkore / gist:2134255
Created March 20, 2012 11:24
tumblr css customize v1
.gist{
margin: 15px 0 !important;
}
.gist-file{
border: none !important;
}
.gist-meta{
border: 1px solid #d2d2d2 !important;
@ponkore
ponkore / settings.xml
Created March 24, 2012 12:01
.m2/settings.xml
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.hoge.fuga.com</host>
<port>8080</port>
</proxy>
</proxies>
</settings>
@ponkore
ponkore / factorial-run.clj
Created March 25, 2012 12:09
Calculate factorial
;; calculate elapsed time
(defmacro tm [form]
`(let [t# (System/currentTimeMillis)]
(do
(~@form)
(- (System/currentTimeMillis) t#))))
;; call 4 version of fact-* 10 times x 5 loop
(dotimes [i 5]
(println "fact-call: " (tm (dotimes [n 10] (fact-call 10000))))
@ponkore
ponkore / fizzbuzz.clj
Created March 26, 2012 04:23
FizzBuzz in Clojure
;; FizzBuzz in Clojure
(defn fizzbuzz [max]
(map (fn [n]
(cond
(= (mod n 15) 0) "FizzBuzz"
(= (mod n 3) 0) "Fizz"
(= (mod n 5) 0) "Buzz"
:else n))
(take max (iterate inc 1))))
@ponkore
ponkore / fibo.clj
Created March 26, 2012 14:21
fibo.clj
;; 何のひねりもない fibo
(defn fibo [x]
(if (or (= 0 x) (= 1 x))
1
(+ (fibo (- x 1)) (fibo (- x 2)))))
;;
(map #(fibo %) (take 10 (iterate inc 1)))
;; => (1 2 3 5 8 13 21 34 55 89)
@ponkore
ponkore / groovyserver.txt
Created March 28, 2012 03:04
groovy & groovyserv installation on OSX Lion
# groovy client with no arguments (startup server)
bash$ groovyclient
Invoking server: 'groovyserver' -p 1961
Groovy home directory: (none)
Groovy command path: /opt/local/bin/groovy (found at PATH)
GroovyServ home directory: /opt/local/share/devel/groovyserv
GroovyServ work directory: /Users/masao/.groovy/groovyserv
Original classpath: (none)
GroovyServ default classpath: /opt/local/share/devel/groovyserv/lib/*
Starting.....
@ponkore
ponkore / gcd-1.clj
Created April 3, 2012 01:04
ユークリッド互除法による最大公約数
;; mod を普通に使う
(defn gcd [m n]
(if (zero? n) m
(gcd n (mod m n))))
(gcd 1763 1927)
; => 41
@ponkore
ponkore / 1..10-sequence-result.txt
Created April 11, 2012 10:14
Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (Ruby 1st)
irb(main):008:0> (1..10).each { |i| puts "This is sentence number #{i}" }
This is sentence number 1
This is sentence number 2
This is sentence number 3
This is sentence number 4
This is sentence number 5
This is sentence number 6
This is sentence number 7
This is sentence number 8
This is sentence number 9
@ponkore
ponkore / b.rb
Created April 11, 2012 12:23
Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (Ruby 2nd)
#!/usr/bin/env ruby
arr = (1..16).to_a
tmp = []
arr.each do |val|
tmp.push(val)
if tmp.length == 4
puts tmp.join(",")
tmp = []
end
end
@ponkore
ponkore / grep.clj
Created April 12, 2012 04:09
Cheap grep by Clojure
;;;
;;; 簡単 grep。のつもりが、あんまりかっこ良くないorz
;;;
(use '[clojure.java.io :as io])
(defn indexed [coll]
(map vector (iterate inc 1) coll))
(defn grep [re file]
(with-open [rdr (io/reader file)]