Skip to content

Instantly share code, notes, and snippets.

;; from Nurullah Akkaya's gist at http://gist.github.com/399127
(ns scraper
(:use [clojure.contrib.duck-streams :only [spit]]
[clojure.contrib.seq-utils :only [partition-all]])
(:import (java.net URL)
(java.io BufferedReader InputStreamReader FileReader)
java.util.Date java.text.SimpleDateFormat))
(defn scrape [url]
(try
(ns
#^{:author "Eric Schulte",
:license "GPLV3",
:doc "Simple concurrent propagator system."}
propagator
(:use clojure.contrib.repl-utils clojure.contrib.math))
(defmacro cell "Define a new cell."
[name state]
`(def ~name (agent ~state)))
(in-ns 'propagator)
(cell guess 1)
(cell x 9)
(cell done false)
(cell margin 0.1)
(propagator enough [x guess] [done]
(Thread/sleep 1000)
(if (< (abs (- (* guess guess) x)) @margin) true false))
;;; Code:
(require 'ob)
(require 'comint)
(declare-function org-babel-get-src-block-info "ext:ob" (&optional hvo))
(html
[:head [:title "Org-server"]]
[:body
[:center
[:h2 "Org-server"]
[:p
"Generate pdf documents from existing templates or from new raw
Org-mode files."]
[:p
(form-to [:POST "/upload"]
(defun org-babel-ref-index-list (index lis)
"Return the subset of LIS indexed by INDEX.
Indices are 0 based and negative indices count from the end of
LIS, so 0 references the first element of LIS and -1 references
the last. If INDEX is separated by \",\"s then each \"portion\"
is assumed to index into the next deepest nesting or dimension.
A valid \"portion\" can consist of either an integer index, two
integers separated by a \":\" in which case the entire range is
(defn first-where
"Return the index in coll of the first place where f returns true."
[f coll]
(loop [ind 0 c coll] (if (f (nth c ind)) ind (recur (inc ind) coll))))
(define foo
(lambda (i)
(if (= i 0)
(lambda (x) x)
(lambda (x) (foo (- i 1))))))
(dorun
(take (to-int out-num)
(filter
#(= (:fitness %) (to-int test-num))
(map
#(do (println (pr-str %)) %)
(let [cross (to-int cross)
cross (if (< cross 1) cross (/ cross 100))]
(pmap
#(evaluate-asm % script (to-int timeout))
@eschulte
eschulte / neural-net.clj
Created November 10, 2010 22:13
Neural Network DSL
(ns neural-net.core) ; Copyright Eric Schulte, GPL V3
(defprotocol Neural
"Protocol implemented by any element of a neural network."
(run [this x] "Evaluates the net")
(train [this x y d] "Trains the net returning the updated net and deltas")
(collect [this key] "Collect key from the network")
(inputs [this] "Number of inputs")
(outputs [this] "Number of outputs")
(check [this] "Ensure that the number of inputs matches the outputs"))