Skip to content

Instantly share code, notes, and snippets.

@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"))
@Quantisan
Quantisan / corr_demo.clj
Created June 26, 2011 00:49
first try using Incanter to analyse stocks data
(ns inc-sandbox.corr-demo
(:require [clojure.set :as set])
(:use (incanter core stats charts io))
(:require [clj-time.core :as time])
(:use (clj-time [format :only (formatter formatters parse)]
[coerce :only (to-long)])))
(defn sym-to-dataset
"returns a dataset read from a local CSV in './data/' given a Yahoo Finance symbol name"
[yf-symbol]
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@Chouser
Chouser / gmail.clj
Created March 24, 2012 18:18
Send email via gmail from Clojure
(ns foo
(:import (java.util Properties)
javax.mail.internet.MimeMessage
(javax.mail.internet MimeMessage InternetAddress)
(javax.mail Session Transport Authenticator
PasswordAuthentication Message$RecipientType)))
(defn send-gmail [{:keys [from to subject text user password]}]
(let [auth (proxy [Authenticator] []
(getPasswordAuthentication []
@bobby
bobby / datomic-helpers.clj
Created July 20, 2012 14:12
Some Datomic helpers I sometimes use with ring or pedestal-service apps
(ns datomic-helpers
(:require [datomic.api :as d]))
;;; Expose Datomic vars here, for convenience
;;; Ring middleware
(defn wrap-datomic
"A Ring middleware that provides a request-consistent database connection and
value for the life of a request."
(defn fight-one-round [[a b :as fighters]]
(let [ticks (apply min (map :cooldown-remaining fighters))
damage-dealt (fn [fighter]
(if (= ticks (:cooldown-remaining fighter))
(:dmg fighter)
0))
tick (fn [fighter]
(update-in fighter [:cooldown-remaining]
(fn [cdr]
(if (= cdr ticks)
@austinhaas
austinhaas / core.clj
Created September 4, 2012 23:53
Using virtual hosts with Clojure and Jetty
;;; This is my first pass at setting up virtual hosts; it works, but there is room for improvement.
;;; dependencies
;;[ring "1.1.5"]
;;[javax.servlet/servlet-api "2.5"]
;;[org.eclipse.jetty/jetty-server "7.6.1.v20120215"]
;;[org.eclipse.jetty/jetty-servlet "7.6.1.v20120215"]
(ns app.core
(:require [ring.util.servlet :refer (servlet)]
@afeld
afeld / gist:4952991
Last active February 8, 2022 03:13
good APIs for mashups

This list has been superseded by Public APIs. Check there for APIs with Auth: No, HTTPS and CORS Yes.


List of data APIs that require no server-side auth or private credentials, and are thus good for small browser-only JS projects.

@abp
abp / draft.txt
Last active December 13, 2015 19:59
Every request is an endpoint to start some computation.
The input is the request, the output is the response.
Typical stages between those are:
Parsing, validation, storage, retrieving stored data and rendering an output.
Based on Ring and Compojure, we do the following to integrate routes with
Prismatic Graph:
Compojure matches the request against routes, calling the route handlers,
until a non nil result is returned.
Routes for integration with the Graph return route-keys,
@hiredman
hiredman / boot.cljs
Created March 15, 2013 04:43
clojurescript drag and drop
(defn handle-file-select [evt]
(.stopPropagation evt)
(.preventDefault evt)
(let [files (.-files (.-dataTransfer evt))]
(dotimes [i (.-length files)]
(let [rdr (js/FileReader.)
the-file (aget files i)]
(set! (.-onload rdr)
(fn [e]
(let [file-content (.-result (.-target e))