Skip to content

Instantly share code, notes, and snippets.

View cieplak's full-sized avatar

Patrick Cieplak cieplak

  • Stripe
  • San Francisco, Oakland
View GitHub Profile
@cieplak
cieplak / xhyve-freebsd-tutorial-1.md
Created April 14, 2019 04:01 — forked from tanb/xhyve-freebsd-tutorial-1.md
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites

{-# LANGUAGE RankNTypes #-}
module Example where
import Data.Functor.Const
data Atom = Atom {_point :: !Point}
data Point = Point {_x :: !Int, _y :: !Int}
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
type Lens' s a = Lens s s a a
#!/bin/sh
nasm -f elf64 test.s && ld -s -o test test.o && ./test
@cieplak
cieplak / cursed_mandelbrot.c
Created November 14, 2018 01:03 — forked from DavidBuchanan314/cursed_mandelbrot.c
Compile-time mandelbrot in pure C. Outputs a PGM image file to stdout.
#include <stdio.h>
#define SQ(x) (x)*(x)
#define M0(x,y) SQ(x)+SQ(y)<4?0:0xe0
#define M1(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M0(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0)):0xc0
#define M2(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M1(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0xa0
#define M3(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M2(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x80
#define M4(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M3(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x60
#define M5(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M4(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x40
@cieplak
cieplak / Echo.hs
Last active August 24, 2018 00:26
{-# LANGUAGE OverloadedStrings #-}
--------------------------------------------------------------------------------
module Echo where
--------------------------------------------------------------------------------
import Blaze.ByteString.Builder.Char.Utf8 (fromString)
import Data.ByteString (ByteString)
import Network.Wai as Wai
import Network.Wai.Handler.Warp as Warp
import Network.HTTP.Types (status200)
import Network.HTTP.Types.Header (hContentType)
This file has been truncated, but you can view the full file.
* (()())
* ((()())())
* (((()())())())
(((()())())(()()))
* ((((()())())())())
((((()())())())(()()))
* ((((()())())(()()))())
((((()())())(()()))(()()))
((((()())())(()()))((()())()))
((((()())())(()()))(((()())())()))
* (()())
* ((()())())
* (((()())())())
(((()())())(()()))
* ((((()())())())())
((((()())())())(()()))
* ((((()())())(()()))())
((((()())())(()()))(()()))
((((()())())(()()))((()())()))
((((()())())(()()))(((()())())()))
@cieplak
cieplak / Prolog.hs
Created August 22, 2018 21:22 — forked from hodzanassredin/Prolog.hs
simple type level predicates in haskell
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}
module Prolog (Petja, Vasja, Serg, Father) where
data Petja = Petja
data Vasja = Vasja
data Serg = Serg
class Father a b where
isFather :: a -> b -> ()
isFather x y = ()
@cieplak
cieplak / NamedTuple.hs
Created July 22, 2018 00:28 — forked from PkmX/NamedTuple.hs
Using type-level symbols and overloaded labels to make named tuples
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
module SimpleThings where
import Control.Applicative ((<$>), (<*>))
import Control.Monad (mzero)
import Data.Aeson
import qualified Data.Aeson as A
-- | sum type containing all possible payloads