Skip to content

Instantly share code, notes, and snippets.

@EarlGray
EarlGray / SetExample.coq
Last active November 14, 2021 15:12
Proving X ∪ Y ∪ Z ∩ X ∪ Y ∩ (X \ Z) = X ∪ Y in Coq
Require Import Coq.Sets.Ensembles.
Require Import Coq.Sets.Powerset_facts.
Require Import Coq.Setoids.Setoid.
Section SetExample.
Variable U: Type.
Definition USet := Ensemble U.
Notation "X ∩ Y" := (Intersection U X Y) (at level 41).
#!/usr/bin/env python3
"""GoDaddy DNS API using credentials stored in a GPG-encrypted file.
The gpg-encrypted file (`dns.env.gpg` by default) must contain at least two
required variables:
GODADDY_PROD_KEY="..."
GODADDY_PROD_SECRET="..."

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@EarlGray
EarlGray / loop.erl
Last active February 10, 2017 20:38
-module(loop).
-export([for/2, for/4, while/2, repeat/2]).
%%% Let's make Erlang great again!
% Look, today we are going to fix the glaring omission,
% I promise you that.
% We are going to build a loop module for Erlang!
% A loop module for Erlang, yes!
(use-modules
(ice-9 hash-table)
(srfi srfi-1))
(define (for-each-file-line filepath thunk)
(with-input-from-file filepath (lambda ()
(let loop ((line (read-line)))
(if line
(begin
(thunk line)
#!/bin/bash
PLAYER=mplayer
PLAYER_OPTIONS=-prefer-ipv4
while getopts "gch" opt; do
case $opt in
g) PLAYER=smplayer
export DISPLAY=:0
;;

Keybase proof

I hereby claim:

  • I am earlgray on github.
  • I am dmytrish (https://keybase.io/dmytrish) on keybase.
  • I have a public key ASCFfXNoKHKpVJirONi0Mnkonm24w197pX66YTH8gtcMLQo

To claim this, I am signing this object:

@EarlGray
EarlGray / bheap.py
Last active April 26, 2016 16:16
Algorithms playground
class BinHeap:
def __init__(self):
self.h = []
def __len__(self):
return len(self.h)
def _parent_index(self, i):
return (i - 1) / 2
@EarlGray
EarlGray / deembed.erl
Created August 16, 2015 11:53
deembed: hs|erl
-module(deembed).
-export([main/1]).
read_bins(Data, 0) -> Data;
read_bins(<<NameSize, Name:NameSize/binary,
DataSize:32, _BinData:DataSize/binary,
Rest/binary>>, N) when N > 0 ->
io:format(" ~p (~p bytes)\n", [binary_to_list(Name), DataSize]),
read_bins(Rest, N - 1).
@EarlGray
EarlGray / average.hs
Last active August 29, 2015 14:24
average.hs with timings
-- GHC 7.8.3, Core i5 1.3 GHz
{-# LANGUAGE BangPatterns #-}
import Data.List
{- naive sum over length -}
average0 xs = sum xs / fromIntegral (length xs)
-- ghc -O0 : real 6.392s, sys 0.758s
-- ghc -O3 : real 2.198s, sys 0.323s
-- ghci: 7.54s, 2_574_335_872 b