Skip to content

Instantly share code, notes, and snippets.

Tristram Oaten 0atman

View GitHub Profile
@0atman
0atman / stillalive.nim
Last active Jun 20, 2020
The code for my video cover of Jonathan Coulton's "Want You Gone" here https://youtu.be/k6giW_6_bFY
View stillalive.nim
import strutils
import terminal
import autotyperpkg/typer
const lyrics = """
1#
0#Forms FORM-29827201#
0#Test Assessment Report
This was a triumph.
I'm making a note here:
@0atman
0atman / wantyougone.nim
Last active Jun 6, 2020
The code from my music video, "Want You Gone", available here https://youtu.be/zvLGFe_8yWU
View wantyougone.nim
import strutils
import autotyperpkg/typer
const lyrics = """
Forms FORM-29827281-12-2:
Notice of Dismissal
Well here we are again
It's always such a pleasure
Remember when you tried
@0atman
0atman / side-effects.nim
Last active May 21, 2020
Example of how nim siloes side-effecting code
View side-effects.nim
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)
View bloglist.md

The Bloglist Manefesto

  • Anonymous and protected forever
  • Create account with just an email
  • Privacy protection baked in from the start
  • Hosted in a freedom-protecting country
  • Partner with EFF or similar
  • Back up forever
  • Profitable
View nim-windows.sh
$ 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
Simple sonic pi metronome
View metronome.rb
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
An install script for sonic-pi on ubuntu 20.04
View install-sonic-pi-ubuntu-20-04.sh
#!/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 Apr 20, 2020
Full-stack, pure Nim. Backend and JS using the same staticly-typed model.
View Makefile
app:
nim c app.nim
clean:
rm app
run:
./app
@0atman
0atman / fibber.nim
Last active Apr 12, 2020
IMO Nim is an advanced, complied superset of python
View fibber.nim
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 / set-gnome-shell-hotkeys.sh
Created Sep 29, 2014
i3 gnome-shell keyboard bindings
View set-gnome-shell-hotkeys.sh
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<alt>1']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<alt>2']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<alt>3']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<alt>4']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-1 "['<alt><shift>1']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-2 "['<alt><shift>2']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-3 "['<alt><shift>3']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-4 "['<alt><shift>4']"
You can’t perform that action at this time.