Skip to content

Instantly share code, notes, and snippets.

@methylene
methylene / murmur.clj
Last active March 26, 2023 17:25
murmur hash in clojure
(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)))))
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 16:12
rsync backup script
#!/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
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)).
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 {
@methylene
methylene / invert_map.clj
Created January 15, 2014 16:38
clojure invert multi-valued map
(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 / peirce_implies_lem.v
Last active December 11, 2015 05:28
coq problems
(*
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 January 4, 2013 23:16
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #ggh;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
<!DOCTYPE html>
<html>
<head>
<meta name='description' content='AngularJS + jQuery UI Drag-n-Drop'/>
<title>JS Bin</title>
<link href='//ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css' rel='stylesheet'/>
<link href='//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.min.css' rel='stylesheet'>
(in-package :cl-user)
(ql:quickload :optima)
(defpackage :ack-mann
(:use :common-lisp :optima)
(:export :ackermann))
(in-package :ack-mann)