Skip to content

Instantly share code, notes, and snippets.

Jared Lobberecht Jared314

Block or report user

Report or block Jared314

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Jared314
Jared314 / core.cljs
Created Feb 18, 2014
Om with core.async cleanup
View core.cljs
(ns processtest.core
(:require [cljs.core.async :refer [<! >! chan timeout]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn cell1 [data owner]
(reify
om/IInitState
(init-state [_] {:value 0 :class ""})
@Jared314
Jared314 / core.cljs
Created Feb 18, 2014
Om with core.async (1 channel per target)
View core.cljs
(ns processtest.core
(:require [cljs.core.async :as async
:refer [<! >! chan put! timeout]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn cell1 [data owner]
(reify
om/IInitState
@Jared314
Jared314 / core.cljs
Created Feb 18, 2014
Om with core.async
View core.cljs
(ns processtest.core
(:require [cljs.core.async :as async
:refer [<! >! chan put! timeout]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn cell1 [data owner]
(reify
om/IInitState
View pbpl_example.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#fixednode { background-color: red; color: white; }
#item1 { background-color: blue; color: white; }
</style>
<style type="text/x-pbpl">
@Jared314
Jared314 / nand2tetris-hdl-parse.clj
Created Dec 28, 2013
nand2tetris HDL parser using Instaparse
View nand2tetris-hdl-parse.clj
(ns stuff
(:require [instaparse.core :as insta]))
(def hdl-parse
(insta/parser
"CHIP = <'CHIP'> <SPACE+> NAME <SPACE*> <'{'> <SPACE*> INSPEC <SPACE*> OUTSPEC <SPACE*> PARTS <SPACE*> <'}'>
INSPEC = <'IN'> <SPACE+> (SPECITEM <SPACE*> <','?> <SPACE*>)* <';'>
OUTSPEC = <'OUT'> <SPACE+> (SPECITEM <SPACE*> <','?> <SPACE*>)* <';'>
PARTS = <'PARTS:'> <SPACE*> (PART <SPACE*>)*
PART = NAME <'('> (<SPACE*> PARTIO <','>?)+ <');'>
@Jared314
Jared314 / markov-chain.clj
Last active Dec 31, 2015
Clojure Markov Chain Example
View markov-chain.clj
(ns markov-chain
(:require [clojure.string :as string]))
(defn simple-weighted-rand-nth [m]
(let [ks (keys m)
vs (map m ks) ; Ensure map value ordering
ranges (reductions + vs)
x (rand-int (last ranges))
i (count (take-while #(<= % x) ranges))
k (nth ks i)]
@Jared314
Jared314 / consec-product.clj
Created Oct 26, 2013
Project Euler #8: Find the greatest product, of 5 consecutive digits, in a string
View consec-product.clj
(def data (str "37900490610897696126265185408732594047834333441947"
"01850393807417064181700348379116686008018966949867"
"75587222482716536850061657037580780205386629145841"
"06964490601037178417735301109842904952970798120105"
"47016802197685547844962006690576894353336688823830"
"22913337214734911490555218134123051689058329294117"
"83011983450277211542535458190375258738804563705619"
"55277740874464155295278944953199015261800156422805"
"72771774460964310684699893055144451845092626359982"
"79063901081322647763278370447051079759349248247518"))
View custom-lang.clj
(ns stuff
(:require [instaparse.core :as insta]
[clojure.walk :as walk]))
(defn hiccup->sexp [sym-ns data]
(let [sym-ns-fn #(symbol sym-ns %)]
(walk/postwalk (fn [x] (if (and (vector? x) (keyword? (first x)))
(conj (rest x) (-> x first name sym-ns-fn))
x))
data)))
View remove-node.clj
(require '[net.cgrand.enlive-html :as e])
(defn gen-transform [target]
[[(cond
(string? target) e/text-node
(map? target) (:tag target)
:else e/any-node)]
#(when (not= target %) %)])
(defn remove-node [coll & nodes]
@Jared314
Jared314 / testdata.txt
Last active Nov 4, 2018
Adventures in Validating Email Addresses with Clojure
View testdata.txt
admin@mailserver1
niceandsimple@example.com
very.common@example.com
a.little.lengthy.but.fine@dept.example.com
disposable.style.email.with+symbol@example.com
postbox@com
user@[192.168.2.1]
user@[IPv6:2001:db8:1ff::a0b:dbd0]
You can’t perform that action at this time.