Skip to content

Instantly share code, notes, and snippets.

View ascjones's full-sized avatar

Andrew Jones ascjones

View GitHub Profile
/**
* @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.
@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)
@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
$ 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

@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"
@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 =
@dsyme
dsyme / gist:9b18608b78dccf92ba33
Last active November 1, 2022 18:11
Working self-contained getting-started sample for Suave Web Scripting
//==========================================
// Working fully self-contained getting-started example for Suave Web Server scripting
//
// Note you don't need to have _anything_ installed before starting with this script. Nothing
// but F# Interactive and this script.
//
// This script fetches the Paket.exe component which is referenced later in the script.
// Initially the #r "paket.exe" reference is shown as unresolved. Once it has been
// downloaded by the user (by executing the first part of the script) the reference
// shows as resolved and can be used.
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)
@akimboyko
akimboyko / 01_SayHello.fsx
Last active May 28, 2023 13:00
Samples from "Actor-based Concurrency with F# and Akka.NET" http://bit.ly/FSharpAkkaNET
#time "on"
#load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor