Skip to content

Instantly share code, notes, and snippets.

View 0atman's full-sized avatar
🦀
Oxidising

Tristram Oaten 0atman

🦀
Oxidising
View GitHub Profile
@0atman
0atman / fibber.nim
Last active April 12, 2020 04:00
IMO Nim is an advanced, complied superset of python
import math, strformat, times
func fib(n: int): int =
if n <= 2:
return 1
else:
return fib(n - 1) + fib(n - 2)
when isMainModule:
let x = 47
@0atman
0atman / hw.hs
Created March 11, 2020 12:13
A starter stack script, with RIO, example command useage and sensible defaults
#!/usr/bin/env stack
{- stack
script
--resolver lts-15.1
--install-ghc
--ghc-options -Wall
--ghc-options -Werror
--package rio
--package process
-}
@0atman
0atman / scotty.hs
Last active February 27, 2020 16:36
main :: IO ()
main = (do
(putStrLn "Starting Server....")
(scotty 3000 (do
(get "/hello/:name" (do
name <- param "name"
text ("hello " <> name <> "!")))
(get "/users"
(json allUsers))
@0atman
0atman / Makefile
Last active February 27, 2020 08:51
Building static, compressed binaries with Haskell
hello:
ghc -static -optl-static -o hello hello.hs
upx --best --ultra-brute hello
install:
sudo apt install upx haskell-stack
stack upgrade --binary-only
stack setup
@0atman
0atman / Makefile
Last active February 19, 2020 13:43
my python sensible defaults
# In your python env, run `make install` to install required packages
# and then either `make` for a single test run
# or `make watch` for a continuous pipeline that reruns on changes.
#
# Comments and/or hate mail to o@tman.me
.SILENT: test install upgrade watch checks
test: checks
pytest
@0atman
0atman / pmap.py
Last active February 5, 2020 10:02
A process-based pmap with sensible defaults, ready to go
from multiprocessing import Pool
def pmap(f, collection, size=10):
"""
Applies `f` in parallel over `collection`.
Pool `size` has a sensible default of 10.
"""
with Pool(size) as p:
return p.map(f, collection)
@0atman
0atman / spacemacs.el
Created December 3, 2019 10:48
My spacemacs layers
(
go
lua
csv
sql
typescript
crystal
ruby
(clojure
:variables clojure-enable-fancify-symbols t
@0atman
0atman / departures.py
Last active April 7, 2019 12:04
A simple airport-style departures system. Hacked together in an hour
import os
import time
import datetime
from datetime import timedelta
from terminaltables import SingleTable
from colorclass import Color
FIVE_MINS = timedelta(minutes=5)
@0atman
0atman / some-clojure-test.clj
Last active November 8, 2018 13:04
test pattern with eftest
(comment "repl experiments"
(do ; run this block to repeatably run the test
(use 'your-ns :reload-all)
(require '[eftest.runner :refer [run-tests find-tests]])
(run-tests (find-tests 'your-ns.your-test)
{:report eftest.report.pretty/report})))
Key Action
cpp Evaluate the form under the cursor
K Look up the symbol under the cursor with (doc)
[ d Look up the symbol under the cursor with source
[ Ctrl+D Jumps to the definition of a symbol
gf "go to file" command, works on namespaces.