Skip to content

Instantly share code, notes, and snippets.

View bouzuya's full-sized avatar

bouzuya bouzuya

View GitHub Profile
Option Explicit
Private Function GetNamedArguments(ByVal strName, ByVal strDefault)
If WScript.Arguments.Named.Exists(strName) Then
GetNamedArguments = WScript.Arguments.Named.Item(strName)
Else
GetNamedArguments = strDefault
End If
End Function
(ns clj-ex-mkd.core
(:import (com.petebevin.markdown MarkdownProcessor)))
(defn markdown-to-html
[markdown]
(->
(MarkdownProcessor.)
(.markdown markdown)))
(defn read-markdown-file
(defn load-jekyll-post-file
[post-file]
(let [text (slurp post-file)
[_ yaml content] (re-find #"(?m)(?s)^---\s*(.*?)^---\s*^(.*)" text)]
(reduce (fn [m [_ k v]] (assoc m (keyword k) v))
{:content (markdown-to-html content)}
(re-seq #"(\w+):\s*(.*)\n" yaml))))
(ns clj-ex-mkd.core
(:require [clojure.java.io :as io]
[net.cgrand.enlive-html :as eh])
(:import (com.petebevin.markdown MarkdownProcessor)))
(defn markdown-to-html
[markdown]
(->
(MarkdownProcessor.)
(.markdown markdown)))
@bouzuya
bouzuya / core.clj
Created August 24, 2012 23:08
:template-dirで返るパスが*base-dir*からの相対パスなので、compileが通らない。
(defn get-template-files
"Get all template files. Find specified directory with `:dir` option."
[& {:keys [dir] :or {dir (str *base-dir* (:template-dir *config*))}}] ;; :template-dirで返るパスが*base-dir*からの相対パスなので、compileが通らない。
(let [exts (get-watch-file-extensions)]
(filter
(fn [file]
(some #(has-extension? % file) exts))
(find-files dir))))
@bouzuya
bouzuya / my-misaki-directory.txt
Created September 8, 2012 01:30
misaki directory
; my misaki's directory
; #"^_" is ignore pattern.
;
; *base-dir* "/" ;
; :public-dir "_public/" ;
; :tag-out-dir "tag/" ; :public-dir/:tag-out-dir
; :coffee-script-out-dir "script/" ; :public-dir/:coffee-out-dir
; :lesscss-out-dir "style/" ; :public-dir/:lesscss-out-dir
; :template-dir *base-dir*
; :post-dir "_post/" ; :template-dir/:post-dir
; ファイルの書き込み
(spit "test.txt" "foobarbaz") ; => nil
; ファイルの読み込み
(slurp "test.txt") ; => "foobarbaz"
(defn str-to-int
[s]
{:pre [(string? s)]
:post [(number? %)]}
(Integer/parseInt s))
(str-to-int 10) ; java.lang.AssertionError
(str-to-int "10") ; => 10
(apply + (filter #(or (zero? (mod % 3)) (zero? (mod % 5))) (range 1000)))
;;; Project Euler #8
;;; http://projecteuler.net/problem=8
;;; http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%208
(use 'clojure.test)
(def input
(str
"73167176531330624919225119674426574742355349194934"
"96983520312774506326239578318016984801869478851843"