Skip to content

Instantly share code, notes, and snippets.

View rjkat's full-sized avatar
💭
🦄

Rowan rjkat

💭
🦄
View GitHub Profile
@rjkat
rjkat / dedup.jl
Created November 30, 2019 02:32
remove duplicate pages from a PDF
# dedup.jl
# wrapper around Apache PDFBox (https://pdfbox.apache.org/)
# for removing duplicate pages from a PDF
# only tested on macOS
JAR = "pdfbox-app-2.0.17.jar"
pdfbox(args...) = run(`java -jar $JAR $args`)
numpages(pdf) = parse(Int, read(
import Data.Maybe
import Data.Char
import Data.List
layout :: [(Char, String)]
layout = [ ('Q', "WAS"), ('W', "QASE"), ('E', "WSDR"), ('R', "EDFT"), ('T', "RFGY"), ('Y', "TGHU")
,('U', "YHJI"), ('I', "UJKO"), ('O', "IKLP"), ('P', "OL"), ('A', "QWSZ"), ('S', "AZWEDCX")
,('D', "ERFCXS"), ('F', "RTGVCD"), ('G', "TYHBVF"), ('H', "YUJNBG"), ('J', "HUIKMN")
,('K', "JIOL"), ('L', "KOP"), ('Z', "ASX"), ('X', "ZSDC"), ('C', "XDFV"), ('V', "CFGB")
,('B', "VGHN"), ('N', "BHJM"), ('M', "NJK")]
# wallpaper.py
# Sets the desktop background to the album art of the current track the user is listening to on lastfm.
import json
import urllib
import urllib2
import subprocess
import re
import time
import cv2
if (player == PLAYER_ONE) {
player = PLAYER_ONE;
} else if (player == PLAYER_TWO) {
player = PLAYER_TWO;
} else {
player = PLAYER_THREE;
}
@rjkat
rjkat / Cycle.hs
Created June 3, 2012 15:04
Uses Brent's Algorithm to compute the cycle length and offset of a function
import Data.List
alphaWrap :: Char -> Char
alphaWrap c
| c == 'z' = 'a'
| 'a' <= c && c < 'z' = succ c
| otherwise = '?'
cycleLength :: Eq a => (a -> a) -> a -> Int
cycleLength f x = last $ 1 : unfoldr (cycleLength' f) (1, 1, x, f x)
@rjkat
rjkat / DivisibilityGraph.hs
Last active October 4, 2015 13:18
Divisibility Graph
{-
DivisibilityGraph.hs
Uses Graphviz http://www.graphviz.org/ and the haskell library http://projects.haskell.org/graphviz/
to draw divisibility graphs for numbers.
To install the haskell package just use
$ cabal install graphviz
@rjkat
rjkat / FFT.hs
Created April 9, 2012 05:56
Haskell Fast Fourier Transform
import Data.Complex
import Control.Arrow
import Control.Monad
fft :: [Complex Double] -> [Complex Double]
fft = fft' . pad
-- perform a fast fourier transform
fft' :: [Complex Double] -> [Complex Double]
fft' [x] = [x]