Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
@joom
joom / euclidGcd.t
Last active June 28, 2017 08:05
Euclid's GCD algorithm, in Gödel's T
let val plus = \(n:nat) \(m:nat) rec m {
z => n
| s(x) with y => s(y)
}
in let val pred = \(n : nat) rec n {
z => z
| s(x) with y => x
}
in let val minus = \(n:nat) \(m:nat) rec m {
z => n
@macintux
macintux / erlang_dates.erl
Created June 22, 2016 20:06
Illustrate key Erlang date/time structures and conversions.
%% Date formats in Erlang are a bit tricky to keep straight,
%% especially since the `calendar' library leverages Gregorian seconds
%% (seconds since year 0) rather than the more traditional UNIX epoch
%% seconds.
%%
%% This module illustrates the structures and conversions.
-module(erlang_dates).
-compile(export_all).
@cmeiklejohn
cmeiklejohn / chain_replication.md
Last active December 1, 2015 18:27
Paper Lists

Papers on Chain Replication

@sdebnath
sdebnath / gist:36c235e042cb35db7d1f
Last active July 13, 2018 09:39
Add field to Riak YZ Schema with CRDTs
This gist captures what needs to be done to add a new field to Riak's Yokozuna
search index.
Sources:
- https://github.com/basho/yokozuna/issues/130
- http://riak-users.197444.n3.nabble.com/How-to-update-existed-schema-td4032143.html
The code below is for illustration purposes only. Use at your own risk.
1. Create/Update new schema file
@frenchy64
frenchy64 / schema.md
Created August 11, 2014 06:55
Schema vs core.typed

Schema

I think of Schema as a runtime contracts library (I believe it does coercion and validation, but they seem related to me).

Pros

  • small barrier to entry, thus immediately useful
    • just add a contract/coercion to a function and you're off
  • can manipulate contracts as regular clojure data
  • documentation
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
%% @doc Reports on percentage of modules, functions and types that are
%% documented.
-module(edoc_stats).
-export([file/1, file/2, files/1, files/2, aggregate/1, report/1, report_files/1, report_files/2]).
-include_lib("xmerl/include/xmerl.hrl").
-import(xmerl_xpath, [string/2]).
-define(QUERY_FUNS, [ fun module_has_description/2
, fun functions_have_descriptions/2
, fun types_have_descriptions/2
@john2x
john2x / 00_destructuring.md
Last active July 9, 2024 01:38
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@david-christiansen
david-christiansen / FizzBuzzC.idr
Last active August 29, 2022 20:00
Dependently typed FizzBuzz, now with 30% more constructive thinking
module FizzBuzzC
%default total
-- Dependently typed FizzBuzz, constructively
-- A number is fizzy if it is evenly divisible by 3
data Fizzy : Nat -> Type where
ZeroFizzy : Fizzy 0
Fizz : Fizzy n -> Fizzy (3 + n)
@jeremyheiler
jeremyheiler / WaitNotify1.java
Last active August 29, 2015 14:04
Basic example of using wait() and notify().
public class Main {
public static final Object LOCK = new Object();
public static void main(String[] args) throws InterruptedException {
new Thread(new A()).start();
new Thread(new B()).start();
}
}