Skip to content

Instantly share code, notes, and snippets.

View jcsims's full-sized avatar
🌊

Chris Sims jcsims

🌊
  • Vancouver, WA
  • 16:26 (UTC -07:00)
View GitHub Profile
(defn select-folds
"Returns a vector of maps specifying training and holdout
observations to form k folds in a dataset"
[dataset k]
(let [rows (vec (range (m/row-count dataset)))
holdouts (vec (partition k (shuffle rows)))]
(map (fn [rows holdouts]
{:train (vec (remove (set rows) holdouts))
:holdout holdouts})
(repeat k rows) holdouts)))
@jcsims
jcsims / rbm.clj
Last active August 29, 2015 14:06
Saving to disk
;; This is designed for EDN printing, not actually visualizing the RBM
;; at the REPL
(defmethod clojure.core/print-method RBM [rbm ^Writer w]
(.write w (str "#deebn.rbm/RBM {"
" :w " (:w rbm)
" :vbias " (:vbias rbm)
" :hbias " (:hbias rbm)
" :w-vel " (:w-vel rbm)
" :vbias-vel " (:vbias-vel rbm)
" :hbias-vel " (:hbias-vel rbm)
@jcsims
jcsims / keybase.md
Last active October 3, 2015 20:35
keybase.md

Keybase proof

I hereby claim:

  • I am jcsims on github.
  • I am jcsims (https://keybase.io/jcsims) on keybase.
  • I have a public key whose fingerprint is DE17 4D49 435C C9CD 5A2A BD84 32D2 0D5D 6DB0 1A6B

To claim this, I am signing this object:

(ns om-tut.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [put! chan <!]]))
(enable-console-print!)
(def app-state
(atom
{:contacts
@jcsims
jcsims / gist:8277192
Created January 6, 2014 02:17
Various Clojure links
http://www.clojureatlas.com/
http://cemerick.com/
http://clj-me.cgrand.net/
https://github.com/ptaoussanis/timbre
https://vimeo.com/channels/wr2013
http://thinkrelevance.com/how-we-work/dev_team
http://thinkrelevance.com/blog/2009/10/07/brians-functional-brain-take-1-5
http://thinkrelevance.com/blog/2009/08/12/rifle-oriented-programming-with-clojure-2
http://incanter.org/
http://clojure.org/cheatsheet
(define (not x) (if x #f #t))
(define (null? obj) (if (eqv? obj '()) #t #f))
(define (list . objs) objs)
(define (id obj) obj)
(define (flip func) (lambda (arg1 arg2) (func arg2 arg1)))
(define (curry func arg1) (lambda (arg) (apply func (cons arg1 (list arg)))))
(define (compose f g) (lambda (arg) (f (apply g arg))))
@jcsims
jcsims / wrapper.clj
Created September 9, 2013 11:25
Simple wrapper for Incanter's #factorial
(ns jcsi.ms.wrapper
(:refer-clojure)
(:require [incanter.core :as incanter]))
(defn foo
[x]
(str "Hello, " x))
(defn -factorial
[this x]
@jcsims
jcsims / prime.clj
Created July 27, 2013 02:47
Infinite lazy sequence of prime numbers Source: http://stackoverflow.com/a/7625207
(defn gen-primes "Generates an infinite, lazy sequence of prime numbers"
[]
(let [reinsert (fn [table x prime]
(update-in table [(+ prime x)] conj prime))]
(defn primes-step [table d]
(if-let [factors (get table d)]
(recur (reduce #(reinsert %1 d %2) (dissoc table d) factors)
(inc d))
(lazy-seq (cons d (primes-step (assoc table (* d d) (list d))
(inc d))))))
@jcsims
jcsims / erc.el
Last active December 20, 2015 02:49
Simple function to connect to your favorite ZNC bouncer. Reads the password from the prompt, so you won't be saving the password to disk.
(defun start-irc ()
"Connect to IRC."
(interactive)
(erc-ssl :server "<server>"
:port <port>
:nick "<nick>"
:password (concat "<nick>/<server>:" (read-passwd "Password:"))
:full-name "<full-name>"
))
@jcsims
jcsims / programmer_prayer.txt
Created November 10, 2012 18:43 — forked from jperras/programmer_prayer.txt
The programmer's prayer.
Our root,
who art in Unix,
hallowed be thy shell.
Thy kernel come.
Thy commands be run
@localhost as they are in iNet.
Give us this day our daily updates,
And forgive us for our four-oh-threes,
as we forgive those who 403 against us.
And lead us not into segfaults,