test
- tnoda-clojure • Crunching Numbers with Clojure - 11 Tips to Boost Your Performance
- clojurewest2012-slides/Solano-Gómez-Crunching-Numbers-with-Clojure.pdf at master · strangeloop/clojurewest2012-slides · GitHub
個人的にはコレクションと配列との使用メモリ量比較が参考になりました.1M 個の long を格納するとして,vector だと 30MB, vector-of だと 9MB, 配列だと 8MB というのは覚えておいて損は無さそうです.案外 vector はメモリを食いません.
(defn current-total-memory-usage []

test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro memoize-fn [name args body] | |
`(let [mem# (atom {})] | |
(fn ~args | |
(if-let [e# (find @mem# ~args)] | |
(val e#) | |
(let [ret# ~body] | |
(swap! mem# assoc ~args ret#) | |
ret#))))) | |
(->> (range 35) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handbrake_path = "/Volumes/HandBrake-0.9.8-MacOSX.6_CLI_x86_64/HandBrakeCLI" | |
preset = "--preset=\"iPhone & iPod Touch\"" | |
native_language = "--native-language eng" | |
subtitle = "--subtitle 2 --subtitle-burn 2" | |
input_base_dir = "/Users/yasuhisa/Desktop" | |
output_base_dir = "/Users/yasuhisa/Desktop" | |
cdr_id = 1 | |
(1..4).each {|chapter| | |
opts = ["-i", "#{input_base_dir}/FRIENDS_1_#{cdr_id}.cdr", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /opt/local/bin/ruby1.9 | |
# -*- coding: utf-8 -*- | |
require 'mechanize' | |
require 'logger' | |
require 'time' | |
require 'optparse' | |
require 'pp' | |
class HatenaGroupKeyword | |
attr_accessor :agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class Entry | |
attr_accessor :name | |
def initialize(name) | |
@name = name | |
end | |
def display(indent=0) | |
end | |
def make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/ruby1.9 | |
# -*- coding: utf-8 -*- | |
require 'hparser' | |
puts HParser::Parser.new.parse(STDIN.read).map {|e| e.to_html }.join("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require "optparse" | |
@options = { | |
:hatena => nil, #はてなで開く | |
} | |
opts = OptionParser.new |