Skip to content

Instantly share code, notes, and snippets.

@Solonarv
Solonarv / README
Created July 17, 2014 20:05
Simple python script to scrape qntm.org/ra, dowloading every chapter. Requires curl or equivalent.
qntm.org/ra scraper
===================
Simple python script to scrape qntm.org/ra, dowloading every chapter. Requires curl or equivalent.
The `filtertoc` file does most of the heavy lifting. Usage:
$ curl http://qntm.org/ra | ./filtertoc | sh
This will download every chapter into a separate file, named '$chapter_number $chapter_slug.html' (the slug is the last part of the qntm.org URL)
@Solonarv
Solonarv / README.md
Created December 7, 2014 22:20
Simple Vector Calculus in Haskell

Vector Calculus in Haskell

Why is this a thing?

This module started out as an idle side project, mostly to learn Haskell but also because I'm too lazy to calculate grad/divg/curl etc myself

Soo why am I posting this now?

Suprisingly enough (to me at least), I was unable to find any module similar to this one anywhere.

@Solonarv
Solonarv / record.sh
Created January 8, 2015 00:09
The script I use for recording
#!/bin/bash
savedir=$1
# ffmpeg -f x11grab -s 1680x1050 -r 30 -i :0.0 -f alsa -i plug:looprec -b:v 2M -qmin 0 -qmax 15 "$savedir/video+loopback.mkv" &
ffmpeg -f x11grab -s 1680x1050 -r 30 -i :0.0 -f alsa -i plug:looprec -c:v libx264 -preset ultrafast -qp 0 -c:a libfaac "$savedir/video+loopback.mkv" &
ffmpeg -f alsa -i default -c:a libfaac "$savedir/audio-micro.aac" &
read -n1 -p'Press any key to stop recording'
# Send Ctrl-C to both ffmpeg instances
killall -SIGINT ffmpeg
@Solonarv
Solonarv / README.md
Created January 15, 2015 16:08
Wiki scraper to grab scroll lists for Mojang's Scrolls game.

Contains a list of each faction's scrolls, and a script to update them all.

The format used is a tab-separated table, columns are:

Card ID | Set | Name | Type | Subtype | Rarity | Cost | Attack | Countdown | Health | Trait(s) | Ability | Flavor

Run update in order to grab the latest (hopefully) scrolls data from the scrollsguide wiki.

You will need to have Python 2 as well as the python modules requests and beautiful soup installed.

def check(dpsstats):
dmg, AS = dpsstats
return {
"www": dmg * (AS + 3*wex),
"wwe": (dmg + exort) * (AS + 2*wex),
"wee": (dmg + 2*exort) * (AS + wex),
"eee": (dmg + 3*exort) * AS
}
skadi = (247, 254)
@Solonarv
Solonarv / Ducks.hs
Created June 1, 2015 19:01
literally ducks in haskell
class Quacks t where
quack :: t -> String
printQuack :: Quacks a => a -> IO ()
printQuack thing = putStrLn (quack thing)
-- Define your Duck type somewhere
data Duck = {- whatever -}
instance Quacks Duck where
@Solonarv
Solonarv / BlockNames.java
Last active December 21, 2015 17:28
Register all blocks that exist in vanilla minecraft to a custom list
// Next line is line 64 in source file
registerBlock("air", 0);
registerBlock("stone", Block.stone);
registerBlock("grass", Block.grass);
registerBlock("dirt", Block.dirt);
registerBlock("cobblestone", Block.cobblestone);
registerBlock("planks", Block.planks);
registerBlock("sapling", Block.sapling);
registerBlock("bedrock", Block.bedrock);
registerBlock("waterMoving", Block.waterMoving);
@Solonarv
Solonarv / BinOp.java
Last active December 21, 2015 18:38
A linked-list reimplementation in Java 8, with a functional interface.
@FunctionalInterface
public interface BinOp<T, U, V> {
abstract V op(T x, U y);
}
@Solonarv
Solonarv / macrons.ahk
Created December 22, 2015 23:24
A very simple script to type macrons, using AutoHotKey.
; Hotstrings for typing macrons
; If o is a vowel, i.e. one of (a, e, i, o, u, y), typing ~~o turns into ō pretty much anywhere.
; Typing ~~ followed by a space will produce a naked macron, i.e. ¯.
:*?:~~i::ī
:*?:~~ ::¯
:*?:~~e::ē
:*?:~~o::ō
:*?:~~a::ā
:*?:~~y::ȳ
-- formulate in standard style, as a mental crutch
tryUntilSuccess :: [a -> Either e b] -> a -> Either [e] b
tryUntilSuccess fs x = let ys = map ($ x) fs
in case dropWhile isLeft ys of
[] -> Left $ lefts $ takeWhile isLeft ys
(Right y):_ -> Right y
-- Formulate in simply polymorphic CPS next
-- This is the signature of the... thing... I'm trying to write
tryUntilSuccessCPS :: [a -> (Either f b -> c) -> c] -> ((a -> (Either [f] b -> e) -> e) -> d) -> d