Skip to content

Instantly share code, notes, and snippets.

View jeremyheiler's full-sized avatar

Jeremy Heiler jeremyheiler

View GitHub Profile
@pjstadig
pjstadig / transducers.md
Last active June 8, 2021 13:22
The secret feature of transducers that no one talks about!

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute:

@djg
djg / reading-list.md
Last active February 19, 2024 18:09
Fabian's Recommened Reading List
@pjstadig
pjstadig / core.clj
Created March 20, 2017 13:06
A little type hint hint
(ns typehint.core)
;; A little type hint hint...
(set! *warn-on-reflection* true)
;; There are two ways to type hint the return value of a function, but one is
;; (technically) wrong:
(defn ^String as-string0
@pjstadig
pjstadig / core.clj
Created March 6, 2017 16:28
In Clojure you can fetch items from a map three different ways. Which should you use when?
(ns maps.core)
;; In Clojure you can fetch items from a map three different ways. Which should
;; you use when?
(= "bar" ({:foo "bar"} :foo)) ; map as function
(= "bar" (:foo {:foo "bar"})) ; key as function
(= "bar" (get {:foo "bar"} :foo)) ; `get` as function
;; <INCIDENTALLY>
@geoff-kruss
geoff-kruss / peerwatch.clj
Last active February 23, 2017 19:14
Datomic peer CloudWatch metrics
; Metric callback handler for pushing Datomic metrics to CloudWatch
;
; http://docs.datomic.com/monitoring.html
;
; Instructions:
; 1) Add CloudWatch sdk to your project.clj
;
; [com.amazonaws/aws-java-sdk-cloudwatch "1.11.6"]
;
; 2) Specify the handler function as the metrics callback handler with a java opt at run time

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@favila
favila / entity-changes.clj
Last active October 16, 2019 13:14
enity-changes Return transaction history for a datomic entity and its components.
(require '[datomic.api :as d])
(defn entity-changes
"Return transaction history for an entity and its components.
Returns a sequence of maps, each is the transaction map (tx metadata) plus a
key `:entity-changes`, which is a nested map of keys: entity id, attribute
ident, `:db/add` or `:db/retract`, and the value added or retracted, e.g.:
{12345678910 {:long-card-1-attr {:db/retract 1
:db/add 0}
:long-card-many-attr {:db/add #{0}}
@dimitardanailov
dimitardanailov / sample-nginx.conf
Last active June 3, 2021 17:30
Configuration for single page application(Framework: Angularjs, Web server: Nginx)
server {
listen 80 default deferred;
server_name myapp.com;
root /var/www/project-folder/;
# Nginx and Angularjs with html mode 5 - https://gist.github.com/cjus/b46a243ba610661a7efb
index index.html;
@SeanTAllen
SeanTAllen / gist:7cbb72339806f3decee2
Last active October 7, 2015 22:53
The Tech "People" Bookclub
Here's the idea,
You work in tech. You're in the NYC area.
You care about "people" issues. You think the hardest problem in computing is "people".
You are interested in how we work. How to structure work. How to work together.
How to help your colleagues succeed.
And...
There's so much to learn:
@kisom
kisom / gtcov
Created October 19, 2014 01:24
gtcov
#!/bin/sh
# Produce an HTML file displaying code coverage. Dependencies:
# - cloc (apt-get install cloc)
# - cover (go get code.google.com/p/go.tools/cmd/cover)
if [ -z "$1" ]; then
PKG=""
else
PKG=$1
fi