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
(map #(map second (re-seq #"((?:\"[^\"]*\"|[^ ]+)+)(?: |$)" (second %))) (re-seq #"((?:(?:\"[^\"]*\")+|[^\"\n]+)+)(?:\n|$)" input-string)) | |
Working from the inside out: | |
(re-seq #"((?:(?:\"[^\"]*\")+|[^\"\n]+)+)(?:\n|$)" input-string) | |
Breaks down into: | |
( | |
(?: |
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
;; Not useful as a generic HTTrack conversion tool as we don't bother trying to undo the URL-rewriting. PANDORA | |
;; crawls are often manually edited and sometimes collected with tools other than HTTrack. | |
;; Instead we just generate records with the URLs as they deliver in the PANDORA archive: | |
;; http://pandora.nla.gov.au/pan/... | |
;; | |
;; Example output: | |
;; | |
;; WARC/1.0 | |
;; WARC-Type: resource | |
;; WARC-Target-URI: http://pandora.nla.gov.au/pan/85187/20080605-1425/www.tams.act.gov.au/__data/assets/pdf_file/0010/102250/Alcohol_and_Drugs_discussion_paper.pdf |
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
// "unsigned long" is 64-bit on x86_64 so changed to uint32_t to test this like it would be on a 32-bit platform | |
// commented out the delay logic so that it thinks it's just received all 1s | |
// | |
// output: | |
// $ g++ buggy.cpp -o buggy && ./buggy | |
// 7fffffff | |
#include <stdio.h> | |
#include <stdint.h> |
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
#!/bin/sh | |
# Starter script for Clojure liverepl | |
[ -z "$JDK_HOME" ] && JDK_HOME=/usr/lib/jvm/default-java | |
LIVEREPL_HOME="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" | |
CLOJURE_JAR="$LIVEREPL_HOME/clojure.jar" | |
if [ ! -f "$JDK_HOME/lib/tools.jar" ]; then | |
echo 'Unable to find $JDK_HOME/lib/tools.jar' | |
echo "Please set the JDK_HOME environment variable to the location of your JDK." |
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
// simplified and fixed bug where too many \b characters were printed | |
#include <stdio.h> | |
#include <unistd.h> | |
int main (int argc, const char *argv[]) | |
{ | |
int i; | |
const char scroller[] = "|/-\\"; | |
for(i=0; i<20; ++i) { | |
printf("%c", scroller[i % (sizeof(scroller) - 1)]); |
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 with notifications! | |
function wget() { | |
command wget "$@" | |
ret=$? | |
notify-send -i $HOME/.icons/down.svg "Download complete" "wget $*" &> /dev/null | |
return $ret | |
} |
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 randArray | |
(for [y (range 100)] | |
(persistent! | |
(reduce (fn [v _] (conj! v (rand))) | |
(transient []) (range (* 100 1000)))))) | |
(def sums (map #(reduce + %) randArray)) | |
(time (dorun (map println sums))) |
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 dostuff [] | |
(couch/get document-id) | |
(couch/set document-id)) | |
(defn dootherstuff [] | |
(couch/get document-id)) | |
(defn main [] | |
(couch/with-couch host db | |
(dostuff) |
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 esj-problem | |
[n limit s] | |
(if-not (seq s) ; reached end of input? | |
(when-not (zero? n) ; if there's anything left-over return it | |
(list n)) | |
(if (>= n limit) ; have we reached the limit? | |
(lazy-seq ; if so, spit out a new output | |
(cons n (esj-problem 0 limit s))) | |
; haven't reached limit, gobble some more input | |
(recur (+ n (first s)) limit (next 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
(defmacro one [] | |
"a one") | |
(defmacro two [] | |
"and a two") | |
(defmacro whee [sym] | |
`(~sym)) | |
(defmacro wheez [s] |
OlderNewer