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
(if needed) gem install rb-appscript | |
ruby -e 'require "appscript"; include Appscript; tune = app("iTunes").selection.get.first.location.get; qt=app("QuickTime Player"); qt.open(tune); qt.activate; app("System Events").keystroke " "' |
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
<%- doctype = capture do -%><%= yield(:doctype) %><%- end; if doctype.strip.blank? -%> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<%- else -%><%= doctype %><%- end -%> |
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
Spec::Runner.configure do |config| | |
# disable transactional_fixtures to get webrat working as it doesn't run inside the transactions | |
config.use_transactional_fixtures = false | |
# truncate the databases before each run | |
config.before(:each) do | |
ActiveRecord::Base.connection.tables.each do |table| | |
ActiveRecord::Base.connection.execute("DELETE FROM #{table}") | |
ActiveRecord::Base.connection.execute("DELETE FROM sqlite_sequence where name='#{table}'") | |
end | |
ActiveRecord::Base.connection.execute("VACUUM") |
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
=ERROR REPORT==== 2009-08-02 11:13:18 === | |
Error in process <0.186.0> on node 'ejabberd@localhost' with exit value: {{case_clause,{error,{open_error,-12}}},[{ejabberd_app,init,0}]} | |
=INFO REPORT==== 2009-08-02 11:13:18 === | |
application: ejabberd | |
exited: {bad_return, | |
{{ejabberd_app,start,[normal,[]]}, | |
{'EXIT', | |
{badarg, |
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
(defn filter-multiples-of [p r] | |
(filter #(or (not= 0 (mod % p)) | |
(= p %)) r)) | |
(defn gen-primes | |
([n] | |
(gen-primes n 2 (range 2 n))) | |
([n p unfiltered] | |
(let [updated-unfiltered (filter-multiples-of p unfiltered)] | |
(when-first [next-p (filter #(> % p) updated-unfiltered)] |
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
(defn take-potential-divisors [p coll] | |
"Takes only those number from coll, whose square less or equal than p" | |
(take-while #(>= p (* % %)) coll)) | |
(defn prime? [p coll] | |
"Test whether p is prime or not. coll - prime numbers less than p" | |
(nil? (some #(zero? (rem p %)) (take-potential-divisors p coll)))) | |
(defn primes-seq [x] (lazy-cat | |
[2] (filter #(prime? % (primes-seq x)) (iterate inc x)))) |
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
(defn square [x] (* x x)) | |
(defn search | |
([a b c] | |
(if (and (= (+ (square a) (square b)) (square c)) | |
(= 12 (+ a b c))) [[a b c]])) | |
([b c] | |
(first (filter seq (map #(search % b c) (range 1 b))))) | |
([c] | |
(first (filter seq (map #(search % c) (range 1 c))))) |
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
(defn prime-after [primes-before] | |
(first (drop-while #(some (fn [x] (zero? (mod % x))) primes-before) | |
(iterate inc (+ 1 (last primes-before)))))) | |
(defn primes-after-seq [primes-before] | |
(let [this-prime (prime-after primes-before) | |
before-and-this (cons this-prime primes-before)] | |
(lazy-seq (cons this-prime (primes-after-seq before-and-this))))) | |
(def primes (primes-after-seq (list 2))) |
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
(def nums (map #(Integer/parseInt (str %)) (seq "731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749303589072962904915604407723907138105158593079608667017242712188399879790879227492190169972088809377665727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474821663704844031998900088952434506585412275886668811642717147992444292823086346567481391912316282458617866458359124566529476545682848912883142607690042242190226710556263211111093705442175069416589604080719840385096245544436298123098787992724428490918884580156166097919133875499200524063689912560717606058861164671094050775410022569831552000559357297257163626956188267042825248 |
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
(use 'clojure.test) | |
(defn groups-of [n vec] | |
(cond (<= (count vec) n) [vec] | |
:else (lazy-seq (cons (subvec vec 0 n) (groups-of n (subvec vec 1)))))) | |
(defn swap [coll i j] | |
(let [ci (coll i) cj (coll j)] | |
(assoc coll i cj j ci))) | |
OlderNewer