Skip to content

Instantly share code, notes, and snippets.

View chessai's full-sized avatar

chessai chessai

View GitHub Profile

Programmer: Atlanta, GA, No Remote, Full-Time

Layer 3 Communications is a professional services organization and network systems integrator. We use Haskell to build network security applications that revolve around either analyzing network data or configuring networks.

Networking knowledge can be learned on the job, and thus is not required.

Our stack:

  • Backend: Haskell
  • Frontend: Small amounts of JavaScript
  • Database: Postgres
@chessai
chessai / regex.hs
Created November 8, 2019 02:24
regex
data Regex t
= RegexLiteral t t
--^ low and high, inclusive
| RegexEmpty
| RegexRejection
| RegexUnion (Regex t) (Regex t)
| RegexAppend (Regex t) (Regex t)
| RegexStar (Regex t)
instance Semiring (Regex t) where
/nix/store/yhlyxjn0s57g0y18gnmak9fj33ynff5h-ghc-8.6.5-with-packages/lib/ghc-8.6.5/package.conf.d
Cabal-2.4.0.1
HUnit-1.6.0.0
QuickCheck-2.12.6.1
RSA-2.3.1
SHA-1.6.4.4
StateVar-1.1.1.1
adjunctions-4.4
aeson-1.4.4.0
ansi-terminal-0.9.1
@chessai
chessai / conv.hs
Created October 4, 2019 13:48
bytearray <===> bytestring
-- | Like 'unsafeByteArrayToByteString', but might perform a copy
-- if the 'ByteArray' is not pinned.
byteArrayToByteString :: ByteArray -> ByteString
byteArrayToByteString b@(ByteArray b#)
| isTrue# (isByteArrayPinned# b#) = unsafeByteArrayToByteString b
| otherwise = runST $ do
let len = sizeofByteArray b
marr@(MutableByteArray marr#) <- newPinnedByteArray len
copyByteArray marr 0 b 0 len
xrandr --output eDP-1 --fb 1280x720 --mode 1920x1080 --scale-from 1280x720 --output HDMI-1 --scale 1x1 --mode 1280x720 --same-as eDP-1
#include <iostream>
#define yeet int
#define Yeet main
#define yEet std
#define yeEt cout
#define yeeT return
#define Yeeet (
#define yeeeT )
#define Yeeeet {
type Message = ([String],String)
parse :: Monad m
=> AB.Parser a
-> Stream (Of ByteString) m r
-> m (Either a Message, Stream (Of ByteString) m r)
parse parser bs = do
(e,rest) <- apply parser bs
pure (either Right Left e, rest)
Building build.rs (librocksdb-sys)
Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=1 --cfg feature="zstd" --cfg feature="zlib" --cfg feature="static" --cfg feature="snappy" --cfg feature="lz4" --cfg feature="default" --cfg feature="bzip2" --out-dir target/build/librocksdb-sys --emit=dep-info,link -L dependency=target/buildDeps --extern bindgen=/nix/store/ksq6msrj8lxn771j7q4wmnjfx58rcfy9-rust_bindgen-0.47.3/lib/libbindgen-257b470b9c.rlib --extern cc=/nix/store/2bihshk564grlwk8jllqb6niwyj58j6a-rust_cc-1.0.32/lib/libcc-d214a1c57c.rlib --extern glob=/nix/store/ffzh87sjai1hqj046g69gr99pdbsvbqy-rust_glob-0.2.11/lib/libglob-67202cca89.rlib --cap-lints allow -L native=/nix/store/vrzv48gkazkwkbn1v9x0fcxsyja3bdiw-rust_backtrace-sys-0.1.28/lib/backtrace-sys.out -L native=/nix/store/xv6f9l6sg5mfsam2ak78qysda66nf368-rust_libloading-0.5.0/lib/libloading.out -l dl -l static=backtrace -l static=global_static --color always
thread 'main' panicked at 'Unable to find libcl
@chessai
chessai / dict_py2hs.txt
Created March 18, 2019 16:46
python dict to haskell [(k,v)]
\(\d\+\): \(\d\+\)/(\1,\2)
@chessai
chessai / aesont.hs
Created February 26, 2019 18:36
derive json automatically for the way i usually write my record product types
data Settings = Settings
{ settingsFoo :: Int
, settingsBar :: String
, settingsBaz :: [Int]
}
deriving (stock) Generic
instance FromJSON Settings where
parseJSON = parseJSONFielded