Skip to content

Instantly share code, notes, and snippets.

@ponkore
ponkore / configure-memo.txt
Created November 5, 2012 05:57
postgis-2.0 on FreeBSD-9.1RC2 (configure でちょっとハマった)
## --with-libiconv と --with-projdir を省略するとだめだった。特に iconv の方はハマりどころ。
##
$ ./configure --with-libiconv=/usr/local --with-projdir=/usr/local
checking build system type... x86_64-unknown-freebsd9.1
checking host system type... x86_64-unknown-freebsd9.1
: (中略)
enabling PostgreSQL extension support...
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating extensions/Makefile
@ponkore
ponkore / index.html
Created November 4, 2012 13:39
map application sample
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<style type="text/css">
html, body, #map {
margin: 0;
width: 100%;
@ponkore
ponkore / files-in-dir.clj
Created October 20, 2012 14:31
Clojure でディレクトリにあるファイルの扱い
user=> (import 'java.io.File)
user=> (File. ".")
#<File .>
user=> (def curdir (File. "."))
#'user/curdir
user=> curdir
#<File .>
user=> (.list curdir)
#<String[] [Ljava.lang.String;@33d6798>
user=> (seq (.list curdir))
@ponkore
ponkore / remove-dup-declaration.diff
Created August 6, 2012 12:38
duplicated declaration in config.clj
diff --git a/src/misaki/config.clj b/src/misaki/config.clj
index ee06fbe..dfffb85 100644
--- a/src/misaki/config.clj
+++ b/src/misaki/config.clj
@@ -57,8 +57,6 @@
(declare ^:dynamic *post-sort-type*)
;; Compile options for ClojureScript
(declare ^:dynamic *cljs-compile-options*)
-;; Current site data
-(declare ^:dynamic *site*)
@ponkore
ponkore / notify-patch.diff
Created August 4, 2012 03:45
[misaki] テンプレート保存時にコンパイルエラーが発生した時に、Mac の Growl に通知を出してみる。
diff --git a/project.clj b/project.clj
index 99624f3..5b53fba 100644
--- a/project.clj
+++ b/project.clj
@@ -9,6 +9,7 @@
[clj-time "0.3.7"]
[clj-text-decoration "0.0.1"]
[clj-pretty-error "0.0.5"]
+ [clj-gntp "0.0.1"] ; https://github.com/mattn/clj-gntp
[uochan/watchtower "0.1.2"]
@ponkore
ponkore / memo.sh
Created August 3, 2012 05:19
github上でgithubにフォークしたリモートリポジトリを本家リモートリポジトリに追随する
# http://d.hatena.ne.jp/haru-s/20110405/1302006637 に答えがそのままあるが、一応メモ
# github fork 追従 で見つけた
$ git remote
origin
# 本家のリモートリポジトリの短縮名を登録する.
$ git remote add github git://github.com/liquidz/misaki.git
# 本家の更新をローカルで反映させる.
@ponkore
ponkore / hoge.clj
Created August 2, 2012 05:45
mapリテラルでは8対までは array-map、それより多い対は hash-map が生成される。
;; @___otabat___ さんのツイート https://twitter.com/___otabat___/status/230890089218195456
;; より引用
;; 「Clojureでmapリテラルを使うとき、8対目まではarray-map、9対目からhash-mapに変わるなどデータと内部実装が異なるのは注意。」
;; を試してみた。
user=> (class {:a 10 :b 20})
;= clojure.lang.PersistentArrayMap
user=> (class {:a 10 :b 20 :c 30 :d 40 :e 50 :f 60 :g 70 :h 80})
;= clojure.lang.PersistentArrayMap (:a〜:h 8対まで)
user=> (class {:a 10 :b 20 :c 30 :d 40 :e 50 :f 60 :g 70 :h 80 :i 90})
;= clojure.lang.PersistentHashMap (:a〜:i 9対、PersistentHashMap に変わった!!)
@ponkore
ponkore / logger-01.clj
Created July 25, 2012 01:49
Clojure Programming Chapter2 P.73〜P.76 logger
(defn print-logger
[writer]
#(binding [*out* writer]
(println %)))
(def *out*-logger (print-logger *out*))
;= #'user/*out*-logger
(*out*-logger "hello")
; hello
;= nil
@ponkore
ponkore / StatefulIntegerExample.clj
Created July 23, 2012 07:36
Clojure Programming Example 2-1. Implementation of a mutable integer in "Clojure"
;;; Clojure Programming Chapter 2. Functional Programming
;;; Example 2-1. Implementation of a mutable integer in "Clojure"
(defprotocol IStatefulInteger
(setInt [this new-state])
(intValue [this]))
(deftype StatefulInteger [^{:volatile-mutable true} state]
IStatefulInteger
(setInt [this new-state] (set! state new-state))
(intValue [this] state)
@ponkore
ponkore / hoge.clj
Created July 14, 2012 13:12
RubyにおけるシーケンスはObject#repeatに任せなさい!を Clojure でやってみた
;;; http://melborne.github.com/2012/07/12/object-repeat-take-care-of-sequence/
;;; を Clojure でやってみた。
;;; 9.、10. は挫折www
;;; 2012/07/16 11:02 追記:9.、10.についての解答をtnoda さんが作成されました。
;;; https://gist.github.com/3111930 の 9.、10. になります。
;;; 1. 初項1、公差2の等差数列の最初の20項を求めなさい。
(take 20 (iterate #(+ % 2) 1))
;;; => (1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39)