Skip to content

Instantly share code, notes, and snippets.

@friedbrice
friedbrice / Lift.hs
Last active November 16, 2018 21:50
Coming to a Haskell and a Scalaz near you!
----
-- Lift (reusable instance)
----
-- | Lift an instance through an applicative functor.
-- |
-- | Applicative functors preserve identities and associativity, though
-- | perhaps not commutativity. The most well-known example is perhaps
-- | that functions into a monoid themselves form a monoid.
-- |
// inspired by https://github.com/tj/git-extras/blob/master/bin/git-line-summary
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const execSync = require("child_process").execSync;
const DIR = "/Users/poshannessy/FB/code/react-clean";
const REF = "origin/master";
const AUTHOR = "Paul O’Shannessy";
const PERIOD_DAYS = 1;
@beala
beala / TreeRotation.idr
Created March 5, 2017 05:24
Proving some properties of binary trees and rotation in idris.
{-
In this file I:
- Define a binary tree.
- Define a type level predicate for right rotation of a tree. That is, this type
can only be instantiated for trees that can be right rotated.
- Prove that it's decidable if a tree can be right-rotated or not.
- Prove that right-rotating a tree preserves in-order traversal.
-}
-- A binary tree.
@DanielKeep
DanielKeep / rustup.ps1
Last active August 29, 2015 14:27
rustup for PowerShell
<#
.SYNOPSIS
Downloads Rust installers for Windows.
.DESCRIPTION
Tries to download the latest available release for a given version of the Rust compiler. It does this by checking the date the currently installed compiler was built against the timestamp of the remote installer. These do not always match up, so do not be surprised if this script keeps trying to re-download the same archive.
Once downloaded, provided you specified either 'exe' or 'msi', the script will run the installer for you.
@jsanders
jsanders / mod_exp.rs
Last active January 4, 2016 21:19
Rust extra::bigint mod_exp
// Modular exponentiation by squaring
fn mod_exp(base: &BigUint, exponent: &BigUint, modulus: &BigUint) -> BigUint {
let (zero, one): (BigUint, BigUint) = (Zero::zero(), One::one());
let mut result = one.clone();
let mut baseAcc = base.clone();
let mut exponentAcc = exponent.clone();
while exponentAcc > zero {
// Accumulate current base if current exponent bit is 1
if (exponent & one) == one {