Skip to content

Instantly share code, notes, and snippets.

View 0atman's full-sized avatar
🦀
Oxidising

Tristram Oaten 0atman

🦀
Oxidising
View GitHub Profile
$ cat hello.nim
echo "hello world"
$ nim c -d:mingw hello.nim
Hint: used config file '/home/oatman/.choosenim/toolchains/nim-1.2.0/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: hello [Processing]
Hint: [Link]
@0atman
0atman / metronome.rb
Created May 5, 2020 07:06
Simple sonic pi metronome
live_loop :metronome do
cue tick
128.times do
t = tick
bar = ((t - 1) / 4) + 1
beat = (t - 4 * bar) + 4
cue String(bar) + "/" + String(beat)
sleep 1
end
end
@0atman
0atman / install-sonic-pi-ubuntu-20-04.sh
Created May 2, 2020 11:58
An install script for sonic-pi on ubuntu 20.04
#!/usr/bin/env bash
echo "Sonic-pi will be installed into ./sonic-pi. Press enter to continue, ctrl-c to abort."
read input
sudo apt-get install ruby erlang-base libscsynth1 sc3-plugins libjack-jackd2-0 qt5-default libffi7 git cmake build-essential ruby-dev libqt5svg5-dev qttools5-dev qttools5-dev-tools qtdeclarative5-dev libqt5webkit5-dev qtpositioning5-dev libqt5sensors5-dev libqt5opengl5-dev qtmultimedia5-dev libffi-dev libjack-jackd2-dev libxt-dev libudev-dev libboost-dev libasound2-dev libavahi-client-dev libicu-dev libreadline6-dev libfftw3-dev libaubio5
git clone https://github.com/samaaron/sonic-pi.git
cd sonic-pi/app/gui/qt
./unix-prebuild.sh --build-aubio
./unix-config.sh
@0atman
0atman / Makefile
Last active February 27, 2023 19:41
Full-stack, pure Nim. Backend and JS using the same staticly-typed model.
app:
nim c app.nim
clean:
rm app
run:
./app
@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 / side-effects.nim
Last active May 21, 2020 08:40
Example of how nim siloes side-effecting code
import httpClient
import strutils
func protocol(url: string): bool = ## ok, pure function
return "http://" in url
func get(url: string): string = ## side-effects.nim(7, 6) Error: 'get' can have side effects
if protocol url:
return newHttpClient().getContent(url)
@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