This file contains hidden or 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 throw-catch [f] | |
[(try | |
(f) | |
(catch ArithmeticException e "No dividing by zero!") | |
(catch Exception e (str "You are so bad " (.getMessage e))) | |
(finally (println "returning... ")))]) |
This file contains hidden or 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
(throw (Exception. "Oh noes!")) | |
(defn throw-catch [f] | |
(try | |
(f) | |
(catch ArithmeticException e "Are you bad at math?") | |
(catch Exception e (str "That didn't work!" e)) | |
(finally (println "returning...")))) |
This file contains hidden or 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 xors | |
"Returns bitwise XORs" | |
[max-x max-y] | |
(for [x (range max-x) | |
y (range max-y)] | |
[x y (bit-xor x y)])) | |
(def frame (java.awt.Frame.)) | |
(.setVisible frame true) | |
(.setSize frame (java.awt.Dimension. 512 512)) |
This file contains hidden or 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 mkframe [] | |
(let [frame (java.awt.Frame.)] | |
(.setVisible frame true) | |
(.setSize frame (java.awt.Dimension. 512 512)) | |
(let [gfx (.getGraphics frame)] | |
(.drawString gfx (.. (java.util.Date.) toString) 160 256)))) |
This file contains hidden or 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 frac-pp [x] | |
(let [rat (if (rational? x) x (rationalize x)) | |
num (numerator rat) | |
den (denominator rat)] | |
(println num) | |
(println "-----") | |
(println den))) | |
(frac-pp 1.5) | |
(frac-pp (/ 3 2)) |
This file contains hidden or 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 lang-map | |
(:use [clojure.data.json :only (json-str write-json read-json)])) | |
(defn wiki-lookup [word] | |
(let [query (str "http://en.wikipedia.org/w/api.php?action=opensearch&search=" word "&namespace=0&format=json")] | |
(read-json (slurp query)))) | |
(wiki-lookup "Scheme") |
This file contains hidden or 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 acc-tail-merge | |
"Trololo" | |
[acc list1 list2 func] | |
(cond | |
(empty? list1) (concat acc list2) | |
(empty? list2) (concat acc list1) | |
:else (let [[first1 & rest1] list1 | |
[first2 & rest2] list2 | |
[small-first small-rest large-list] (if (func first1 first2) [first1 rest1 list2] [first2 rest2 list1]) | |
new-acc (concat acc [small-first])] |
This file contains hidden or 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
trololo! |
This file contains hidden or 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 Instapaper Fonts | |
// @namespace http://www.philippcomans.de/userscripts | |
// @description Changes fonts on Instapaper | |
// @match http://www.instapaper.com/read/* | |
// ==/UserScript== | |
(function() { | |
var head = document.getElementsByTagName('head')[0]; | |
var wf = document.createElement('link'); |
This file contains hidden or 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
SITE | TOTAL_VISITS | CHARGE_FREE | PERCENT_CHANGE | |
---|---|---|---|---|
British Museum | 5842138 | F | 4.90% | |
Tate Modern | 5061172 | F | 7.00% | |
National Gallery | 4954914 | F | 3.70% | |
Natural History Museum | 4647613 | F | 13.20% | |
Science Museum (South Kensington) | 2751902 | F | -0.50% | |
V&A (South Kensington) | 2629065 | F | 16.00% | |
National Maritime Museum | 2419802 | F | 2.19% | |
Tower of London (HRP) | 2414541 | C | 1.04% | |
St Paul's Cathedral | 1892467 | F/C | 4.00% |