Skip to content

Instantly share code, notes, and snippets.

Timothy Baldridge halgari

Block or report user

Report or block halgari

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 join.clj
(def data {:cards
[{:id "card-1", :idList "list-id-1", :name "Task 1"}],
:lists
[{:id "list-id-1", :name "List 1"}
{:id "list-id-2", :name "List 2"}]})
(vec (o/for-query
(o/and
(d/query-in data _ [:lists _] ?list-item)
(d/query data ?list-item :id ?list-id)
@halgari
halgari / word-count.clj
Created Mar 2, 2017
Word Count (MMap)
View word-count.clj
;; On my box, wc processes the 11GB JSON file in 50sec
;; This code does it in 11sec
;; Compiled with lein uberjar, and run with java -server -jar word-count-STANDALONE.jar
(ns word-count.core
(:import (java.io RandomAccessFile File)
(java.nio.channels FileChannel$MapMode)
(java.nio ByteBuffer))
(:gen-class))
View gist:ac93675c26109e5604057b9de3da85d3
(defn my-dsl-fn
([mp]
... do stuff with map ...
([k v & {:as mp}]
(my-dsl-fn (assoc mp k v))))
@halgari
halgari / gist:f431b2d1094e4ec1e933969969489854
Last active Jul 11, 2019
What I want from a Type System
View gist:f431b2d1094e4ec1e933969969489854
The question was asked why I (as a programmer who prefers dynamic languages) don't consider static types "worth it". Here
is a short list of what I would need from a type system for it to be truely useful to me:
1) Full type inference. I would really prefer to be able to write:
(defn concat-names [person]
(assoc person :full-name (str (:first-name person)
(:second-name person))))
And have the compiler know that whatever type required and produced from this function was acceptible as long as the
View fn-fx-3d.clj
(ns other-examples.shapes-3d
(:require [fn-fx.fx-dom :as dom]
[fn-fx.diff :refer [component defui render should-update?]]
[fn-fx.controls :as ui]))
(def red (ui/color :red 1 :blue 0 :green 0))
(def green (ui/color :red 0 :blue 0 :green 1))
(def blue (ui/color :red 0 :blue 1 :green 0))
(def grey (ui/color :red 0.5 :blue 0.5 :green 0.5))
View gist:9b83e28b180e32d003380db94f4d1744
(ns other-examples.shapes-3d
(:require [fn-fx.fx-dom :as dom]
[fn-fx.diff :refer [component defui render should-update?]]
[fn-fx.controls :as ui]))
(def red (ui/color :red 1 :blue 0 :green 0))
(def green (ui/color :red 0 :blue 0 :green 1))
(def blue (ui/color :red 0 :blue 1 :green 0))
(def grey (ui/color :red 0.5 :blue 0.5 :green 0.5))
View todo.clj
(ns other-examples.todo
(:require [fn-fx.fx-dom :as dom]
[fn-fx.diff :refer [component defui render should-update?]]
[fn-fx.controls :as ui]))
(def main-font (ui/font :family "Helvetica" :size 20))
(defui TodoItem
(render [this {:keys [done? idx text]}]
(ui/border-pane
View gist:f0cc5e5354a34ef19bd8227e57dcb3d0
(ns other-examples.todo
(:require [fn-fx.fx-dom :as dom]
[fn-fx.diff :refer [component defui render should-update?]]
[fn-fx.controls :as ui]))
(def main-font (ui/font :family "Helvetica" :size 20))
(defui TodoItem
(render [this {:keys [done? idx text]}]
(ui/border-pane
View gist:1c9297349063d0f9b110
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_74-b02
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
View gist:a0f4b3cf76044576c8a6
(q '[:find ?student-id ?model
:in $ ?year
:where
[?student-id :student/teacher ?teacher-id]
[?teacher-id :teacher/car ?car-id]
[?car-id :car/year ?year]
[?car-id :car/model ?model]]
db
2012)
You can’t perform that action at this time.