Skip to content

Instantly share code, notes, and snippets.

View H2DateFun.java
package errorist;
import org.h2.jdbcx.JdbcConnectionPool;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDate;
import java.time.ZoneId;
@methylene
methylene / collect.sh
Last active May 22, 2016
rsync backup script
View collect.sh
#!/bin/bash -e
CONF_PATHNAMES=${HOME}/.config/collect/pathnames.txt
function warn { echo -e " \e[93m[$1]\e[0m"; }
function printDone { echo -e " \e[92m[DONE]\e[0m"; }
# Backup a path
function performBackup {
# Use absolute path
View prime_field.v
Require Import ZArith.
Require Import Znumtheory.
Definition prime_z := {f | prime f}.
Record prime_field (f: prime_z) : Set := pf_make {n: Z}.
Definition pf_add {p: prime_z} (x y : (prime_field p)) :=
pf_make p ((n _ x) + (n _ y)).
View CoreTest.java
package foo.bar;
import io.atlassian.fugue.Option;
import org.junit.Test;
import java.util.Objects;
import java.util.Optional;
// https://developer.atlassian.com/blog/2015/08/optional-broken/
public class CoreTest {
View friedman_ackermann.lisp
(in-package :cl-user)
(ql:quickload :optima)
(defpackage :ack-mann
(:use :common-lisp :optima)
(:export :ackermann))
(in-package :ack-mann)
View friedman_ackermann.clj
;; A version of the ackermann function, described in https://u.osu.edu/friedman.8/files/2014/01/LongFinSeq98-2f0wmq3.pdf
(require '[clojure.core.match :refer [match]])
(defn ackermann [[k & r :as s] n]
(if (not (seq s))
n
(match [k n]
[1 _] (recur r (*' 2 n))
[_ 1] (recur (cons (dec k) r) 1)
@methylene
methylene / invert_map.clj
Created Jan 15, 2014
clojure invert multi-valued map
View invert_map.clj
(defn invert-map [m]
(reduce-kv
(fn [acc k v]
(merge-with (comp vec concat)
acc
(apply array-map (interleave v (repeat [k])))))
{} m))
@methylene
methylene / murmur.clj
Last active Nov 29, 2016
murmur hash in clojure
View murmur.clj
(def murmur
(let [m (com.google.common.hash.Hashing/murmur3_128)]
(fn ^Long [^String s]
(-> (doto (.newHasher m)
(.putString s com.google.common.base.Charsets/UTF_8))
(.hash)
(.asLong)))))
View peirce_implies_lem.v
(*
https://www.youtube.com/watch?v=7sk8hPWAMSw
http://en.wikipedia.org/wiki/Law_of_excluded_middle
http://en.wikipedia.org/wiki/Peirce_law
*)
Definition peirce := forall (p q : Prop),
((p -> q) -> p) -> p.
@methylene
methylene / dabblet.css
Created Jan 4, 2013
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
background: #ggh;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
You can’t perform that action at this time.