Skip to content

Instantly share code, notes, and snippets.

View cartazio's full-sized avatar

Carter Tazio Schonwald cartazio

View GitHub Profile
$ for i in (seq 255); sudo ifconfig lo0 alias 127.0.0.$i ; end
Password:
16:00:16 ~/W/p/a/W/c/numerical (master|✚7…) $ nc -l 0:0:0:0:0:ffff:7f00:50 80
nc: Permission denied
16:00:29 ~/W/p/a/W/c/numerical (master|✚7…) $ nc -l 0:0:0:0:0:ffff:7f00:50 8080
^C⏎ 16:00:36 ~/W/p/a/W/c/numericalnc -l 0:0:0:0:0:ffff:7f00:40 8080
GET / HTTP/1.1
Host: [::ffff:7f00:40]:8080
Connection: keep-alive
Upgrade-Insecure-Requests: 1
@cartazio
cartazio / scribbles.agda
Created July 3, 2017 23:03
need to change to placate termination checker
{-# OPTIONS --experimental-irrelevance #-}
module TypeSpec where
open import Data.Fin
open import Function
open import Data.Unit
open import Data.Star as Star
open import Relation.Nullary as Decidable
open import Data.Nat as Nat
@cartazio
cartazio / Distributions.hs
Created April 18, 2017 17:14
how mwc samples
{-# LANGUAGE BangPatterns, CPP, GADTs, FlexibleContexts, ScopedTypeVariables #-}
-- |
-- Module : System.Random.MWC.Distributions
-- Copyright : (c) 2012 Bryan O'Sullivan
-- License : BSD3
--
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : portable
--
@cartazio
cartazio / fun.txt
Created April 6, 2017 00:03
how to do splices
$ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XQuasiQuotes
Prelude> :set -XTemplateHaskellQuotes
Prelude> [t| forall x . (x -> x) -> x |]
<interactive>:3:14: error:
Illegal symbol '.' in type
Perhaps you intended to use RankNTypes or a similar language
extension to enable explicit-forall syntax: forall <tvs>. <type>
@cartazio
cartazio / notes.txt
Last active February 11, 2017 18:37
> set -xl MACOSX_DEPLOYMENT_TARGET 10.9
> set -xl CC (which gcc-6)
> ./configure --with-nm=(xcrun --find nm-classic) ac_cv_func_clock_gettime=no
> cp mk/build.mk.sample mk/build.mk
# edit build.mk to add the following lines
```
# Uncomment the following to force `integer-gmp` to use the in-tree GMP 5.0.4
newtype RandomT m a = RandomT# { unRandomT# :: (SplitMix64 -> m (a , SplitMix64) ) }
instance Functor m => Functor (RandomT m) where
fmap = \ f (RandomT# mf) ->
RandomT# $ \ seed ->
fmap (\(a,s) -> (f a, s) ) $ mf seed
instance Applicative m => Applicative (RandomT m) where
pure = \ x -> RandomT# $ \ s -> pure ( x , s )
(<*>) = \ (RandomT# frmb) (RandomT# rma) -> RandomT# $ \ s ->
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
newtype RandomT m a = RandomT# { unRandomT# :: (SplitMix64 -> (# m a , SplitMix64 #)) }
instance Functor m => Functor (RandomT m) where
fmap = \ f (RandomT# mf) ->
RandomT# $ \ seed ->
let (# !ma , !s' #) = mf seed
!mb = fmap f ma
in (# mb , s' #)
instance Applicative m => Applicative (RandomT m) where
randomIvalInteger :: (RandomGen g, Num a) => (Integer, Integer) -> g -> (a, g)
randomIvalInteger (l,h) rng
| l > h = randomIvalInteger (h,l) rng
| otherwise = case (f 1 0 rng) of (v, rng') -> (fromInteger (l + v `mod` k), rng')
where
(genlo, genhi) = genRange rng
b = fromIntegral genhi - fromIntegral genlo + 1
-- Probabilities of the most likely and least likely result
-- will differ at most by a factor of (1 +- 1/q). Assuming the RandomGen
https://phabricator.haskell.org/D2929