Skip to content

Instantly share code, notes, and snippets.

Gijs Stuurman thegeez

Block or report user

Report or block thegeez

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
View crepl_svg_smiley.cljs
(ns crepl.svg.smiley
(:require [reagent.core :as r]
crepl.atom-sync))
(def happiness (crepl.atom-sync/atom-sync 30))
(defn smiley []
[:svg {:x 0 :y 0 :width 100 :height 100}
[:rect {:x 50 :y 50 :width 10 :height 10}]
[:circle {:cx 50 :cy 50 :r 40 :fill
@thegeez
thegeez / crepl_tic-tac-toe.clj
Created Feb 11, 2017
crepl Tic Tac Toe example with atom sync
View crepl_tic-tac-toe.clj
(ns crepl.tic-tac-toe
(:require [reagent.core :as r]
crepl.atom-sync))
;; use this instead of reagent.core/atom to keep the state in sync
(def data (crepl.atom-sync/atom-sync {:turn :X}))
(def win-lines (-> #{}
(into (for [i (range 3)]
(for [j (range 3)]
@thegeez
thegeez / crepl_reagent_example.cljs
Created Feb 5, 2017
An example with Reagent for crepl.thegeez.net
View crepl_reagent_example.cljs
(ns crepl.reagent.example
(:require [reagent.core :as r]))
(def temp-data (r/atom {:celsius 20 :fahrenheit 68}))
(defn calc-temperature []
(let [{:keys [celsius fahrenheit] :as data} @temp-data]
(if (nil? celsius)
(assoc data :celsius (* (- fahrenheit 32) 5/9))
(assoc data :fahrenheit (+ (* celsius 9/5) 32)))))
@thegeez
thegeez / spec_parsing.clj
Last active Jan 2, 2019
Parsing with clojure.spec for the Advent of Code challenge
View spec_parsing.clj
(ns net.thegeez.advent.spec-parsing
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.spec.gen :as gen]
[clojure.test.check.generators :as tgen]))
;; Dependencies:
;; [org.clojure/clojure "1.9.0-alpha14"]
;; [org.clojure/test.check "0.9.0"]
;; Advent of Code is a series of code challenges in the form of an advent
@thegeez
thegeez / adt.clj
Created Jul 19, 2016
match for spec
View adt.clj
(ns adt
(:require [clojure.spec :as s]))
(defmacro match [spec x & cases]
(let [fr (s/form spec)
[ffr & frcases] fr
_ (assert (= `s/or ffr)
"match only works on clojure.spec/or specs")
expected-cases (set (take-nth 2 frcases))
found-cases (set (map first cases))
@thegeez
thegeez / 4clojure-editor
Created Jan 10, 2014
4clojure in an editor
View 4clojure-editor
;; 1. Common test utility
(require '[clojure.walk :as walk])
(defmacro to-test [name & source]
`(defn ~(symbol (str name "-test")) [] ~@(for [case (filter list? source)]
`(assert ~(walk/postwalk-replace {'__ name} case)))))
;; 2. for each problem I write:
(def pNN
(fn ...solution here...))
View park.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View get.clj
;; bin/repl with datomic-free-0.8.3664
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://future")
(d/create-database uri)
(def conn (d/connect uri))
;; balance attr
@thegeez
thegeez / clj15
Created May 22, 2012
Clojure snapshot usage
View clj15
(defproject clj15 "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.5.0-master-SNAPSHOT"]]
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
)
View clomian.clj
(ns scratch.clomian
(:require clojure.java.io)
(:use [incanter core charts]))
;(set! *warn-on-reflection* true)
(def files (filter (fn [^java.io.File f]
(let [^String n (.getName f)]
(and
(.endsWith n ".dat")
You can’t perform that action at this time.