Skip to content

Instantly share code, notes, and snippets.

View ascjones's full-sized avatar

Andrew Jones ascjones

View GitHub Profile
data First : Nat -> Type where
MkFirst : (n : Fin 10) -> First (finToNat n)
data Second : Nat -> Type where
MkSecond : (f : First m) -> (n : Fin m) -> Second (finToNat n)
MkNoSecond : (f : First 9) -> Second 0
hit8 : Second 1
hit8 = MkSecond (MkFirst 8) (FS FZ)
@CarstenKoenig
CarstenKoenig / EventPlayback.fs
Created February 12, 2015 18:15
playing back events with FUN
namespace Events
type Projection<'ev, 'state, 'out> =
{ foldState : 'ev -> 'state -> 'state
; projection : 'state -> 'out
; emptyState : 'state
}
module Projections =
@ptrelford
ptrelford / randomArt.go
Created September 5, 2015 12:09
Random Art
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"math/rand"
"os"
$ git clone http://code.hledger.org hledger
$ cd hledger
$ stack build hledger
$ stack ghc extra/hledger-rewrite.hs
$ mv extra/hledger-rewrite ~/.local/bin
$ cd ..
$ hledger-rewrite --help
hledger-rewrite [OPTIONS] [PATTERNS] --add-posting "ACCT AMTEXPR" ...
print all journal entries, with custom postings added to the matched ones
@txus
txus / README.md
Last active July 30, 2018 20:54
Memory as a dependently-typed effect (scroll down for examples!)

Memory as an effect

What if we treated memory as a side-effect?

Idris lets us track lots of things in the type system, in order to get errors at compile-time rather than at runtime. One of the tools that lets us do this in Idris is called Effects, and they're used to keep track of state, to manage file handlers, and lots more.

In barely 40 lines of Idris (which could be less if I had any idea what I'm

/**
* @dev OpcodeChecker processes contract code to generate a bitmap of used opcodes.
*
* DO NOT USE: See the vulnerability identified by Recmo below. A patch will be provided soon.
*
* The generated bitmap can be used to enforce whitelisting and blacklisting on contract code.
* Bit n of the bitmap is set iff opcode n is used. For instance, the presence of the STOP opcode
* will result in bit 0 of the bitmap being set.
*
* A best-effort attempt is made to skip over unreachable data, but there may be false positives.
@balupton
balupton / README.md
Last active April 29, 2019 11:57
DocPad: Use DocPad, GitHub & Prose as a Wiki

Use DocPad, GitHub and Prose as a Wiki

This guide will walk you through how you can use a GitHub repository to house your wiki content, have DocPad render it, and automatically update on changes. It's also really nice as we get to benefit from the github project workflow for our wiki, that is issues, pull requests, etc.

We use this workflow heavily by linking the DocPad Website and the DocPad Documentation repositories allowing us to have users edit and submit pull requests for improvements to our documentation, and once merged, the website regenerates automatically.

1. Create a new repository for your Wiki Content

@RobBlackwell
RobBlackwell / configuration.nix
Last active July 19, 2021 06:27
NixOS on Dell XPS 13
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@i-am-tom
i-am-tom / ZipRecord.purs
Created August 31, 2017 20:00
ZipRecord for PureScript. More notes from RowToList studies.
module Main (main, zip, zipRecord, class ZipRowList) where
-- | After Tuesday's experiments, let's move onto a slightly more
-- | interesting example. Last time, I confess, I cheated a bit to
-- | avoid getting too deep into RowToList stuff. Today, I'm not
-- | going to cheat, and get riiiight into it. When we're thirty lines
-- | in, don't say you weren't warned!
import Prelude (($), discard, Unit)
import Control.Monad.Eff (Eff)
@ovatsus
ovatsus / Setup.fsx
Created March 17, 2012 17:07
Script to setup F# Interactive session, loading everything in the current solution
#r "System.Xml.Linq"
open System
open System.IO
open System.Xml.Linq
let script = seq {
//TODO: this currently loads fsproj's in alphabeticall order, we should instead
//build the dependencies graph of the fsproj's and load them in topological sort order