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
(ns euler14 | |
(:use [clojure.repl])) | |
(defn max-euler14 [count-fn upper-bound] | |
(->> (range 1 (inc upper-bound)) | |
(map (juxt identity count-fn)) | |
(reduce (partial max-key second)))) | |
; idiomatic | |
(defn euler14-terms [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
(ns euler14 | |
(:use [clojure.repl])) | |
(defn max-euler14 [count-fn upper-bound] | |
(->> (range 1 (inc upper-bound)) | |
(map (juxt identity count-fn)) | |
(reduce (partial max-key second)))) | |
; idiomatic | |
(defn euler14-terms [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
BEGIN{S="BEGIN{S=\"%s\";s=S;gsub(/\\\\/,\"\\\\\\\\\",s);gsub(/\\\"/,\"\\\\\\\"\",s);printf(S,s)}";s=S;gsub(/\\/,"\\\\",s);gsub(/\"/,"\\\"",s);printf(S,s)} |
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
Programming Languages Panel | |
September 20, 2011 | |
StrangeLoop | |
St. Louis, Missouri | |
Members: | |
Dean Wampler: Moderator | |
Rich Hickey: Clojure | |
Jeremy Ashkenas: CoffeeScript, NY Times | |
Dr. Gerald Sussman: MIT Prof, SICP |
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
;; :dependencies [[org.apache.mahout/mahout-core "0.5"]] | |
;; :dev-dependencies [[slamhound "1.2.0"]] | |
(ns mia.mahout | |
(:import | |
(java.io File) | |
(org.apache.mahout.cf.taste.eval RecommenderBuilder) | |
(org.apache.mahout.cf.taste.impl.eval | |
AverageAbsoluteDifferenceRecommenderEvaluator | |
GenericRecommenderIRStatsEvaluator) | |
(org.apache.mahout.cf.taste.impl.model.file FileDataModel) |
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
;; Y-combinator | |
(defn Y [f] ((fn [x] (f (fn [y] ((x x) y)))) | |
(fn [x] (f (fn [y] ((x x) y)))))) | |
;; Y-combinator memoized | |
(defn Y [f] | |
(let [c (atom {}) | |
fp-gen (fn [x] (f (fn [y] | |
(or (@c y) |
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
// ==UserScript== | |
// @name YouTube Recommended Channel Remover | |
// @namespace pmbauer | |
// @description This extremely simple script removes the annoying sidebar on www.youtube.com. | |
// @include http://*.youtube.* | |
// @include https://*.youtube.* | |
// ==/UserScript== | |
document.getElementById("video-sidebar").style.display = "none"; |
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
(get-in {:k :v} [:k]) ;; => :v | |
(update-in {:k :v} [:k] (constantly :x)) ;; => {:k :x} | |
(get-in {:k :v} []) ;; => {:k :v} | |
(update-in {:k :v} [] (constantly {:k :x})) ;; => {nil {:k :x}, :k :v} |
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
# wget -O https://gist.github.com/pmbauer/5166100/raw/c72b880ba82dfd598c3cf27a3045833cadec32e2/install_python.sh | |
# chmod +x install_python.sh | |
# ./install_python.sh | |
#!/bin/sh | |
pushd /usr/local/src | |
echo " - Install compilers" | |
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel 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
;; based on my code from test.benchmark | |
(ns raw-threadring | |
(:import [java.util.concurrent Exchanger])) | |
(def ^Exchanger output-pipe (Exchanger.)) | |
(defn relay [state msg] | |
(if (> msg 0) | |
(send (:next state) relay (dec msg)) |
OlderNewer