Skip to content

Instantly share code, notes, and snippets.

View maxweber's full-sized avatar

Max Weber maxweber

View GitHub Profile
(comment
;; Starting the REPL with `clojure -J-Djdk.tracePinnedThreads=full -J--enable-preview ...`
(.start (Thread/ofVirtual)
(fn []
(doall
;; LazySeq:
(map
(fn [n]
(Thread/sleep 1)
@maxweber
maxweber / README.md
Created August 15, 2023 18:11
Send requests to the Google Sheets API (v4).
@maxweber
maxweber / atom_clojure_setup.md
Created March 30, 2017 08:36 — forked from jasongilman/atom_clojure_setup.md
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

(ns example
(:require [clara.rules :refer :all]))
(def view-counts
{123 1000})
(def view-event
{:type :view-event
:video 123})
@maxweber
maxweber / query_check.clj
Created May 13, 2016 16:41
Checks if a Datomic datalog query contains only allowed symbols / functions.
(require '[datomic.api :as d]
'[clojure.string :as str])
(defn normalize-query
"Turns a vector formatted Datomic datalog query into a map formatted
one."
[query]
(let [pairs (partition-by keyword? query)]
(assert (even? (count pairs)))
(into
(defn io-map
([number-of-threads f seq]
(let [executor (java.util.concurrent.Executors/newFixedThreadPool number-of-threads)
results (.invokeAll executor (map (fn [x] #(f x)) seq))
result (doall (map deref results))]
(.shutdown executor)
result))
([f seq] (io-map 50 f seq)))
@maxweber
maxweber / git-mirror.sh
Created November 10, 2015 10:09
Duplicates one complete git repo into another empty git repo. Based on https://help.github.com/articles/duplicating-a-repository/
#!/bin/bash
temp_dir=`mktemp -d -t repo`
echo $temp_dir
git clone --bare $1 $temp_dir
cd $temp_dir
@maxweber
maxweber / pomodoro.sh
Created October 19, 2015 09:21
A very plain pomodoro timer (only for Mac)
#!/bin/bash
# 25 minutes
sleep 1500 && osascript -e 'tell app "System Events" to display dialog "Pomodoro: 25 minutes are over"' &
(ns sortable-table.core
(:require [reagent.core :as reagent :refer [atom]]))
(def data
(atom
{:header ["Id" "Name" "City"]
:rows [["1" "Joe" "New York"]
["2" "Harry" "Boston"]
["3" "Alicia" "Miami"]]}))
@maxweber
maxweber / cartesian_product.clj
Last active August 31, 2015 10:49
Cartesian Product
(def data [[1 2] [11 22] [111 222]])
(defn combine [a b]
(mapcat
(fn [x]
(map
(fn [y]
(flatten [x y]))
b))
a))