Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am treferwynd on github.
  • I am treferwynd (https://keybase.io/treferwynd) on keybase.
  • I have a public key ASDdcdpDla2VJMgV4tvy4GywvB5wke2vGvv1-Wmkm2cmxwo

To claim this, I am signing this object:

@Treferwynd
Treferwynd / k_bijection.clj
Last active September 29, 2016 19:04
N->N^k
(ns k_bijection)
; Utils: triangolize number
(defn triangle [x]
(/ (* x (+ x 1)) 2))
(defn prev-pretriangle [n]
(int (/ (- (Math/sqrt (+ 1 (* 8 n))) 1) 2)))
; Bijection from N^2 to N via diagonalization, starting from 0
#!/bin/bash
## WHAT
# Update the resolution and turn on or off the monitors
IN="LVDS1"
EXT="HDMI1"
# udev stuff
export DISPLAY=:0
@Treferwynd
Treferwynd / runtime
Created January 27, 2016 23:48
Bash function to measure basic stats of a command's running times
# Run a function multiple times and output the average time
runtime() {
quiet=""
if [ $1 = "-q" ]; then
quiet="quiet"
shift
fi
number=$1
shift
tot=0
if [ -n "$album" ]; then
response="$(curl -fsSL --stderr - \
-F "title=$album" \
-F "sderm=orp"\
-H "Authorization: Bearer $access_token" \
https://api.imgur.com/3/album)"
if egrep -q '"success":\s*true' <<<"$response"; then # Album creation successful
echo "Album $album successfully created"
album_id="$(egrep -o '"id":\s*"[^"]+"' <<<"$response" | cut -d "\"" -f 4)"
del_id="$(egrep -o '"deletehash":\s*"[^"]+"' <<<"$response" | cut -d "\"" -f 4)"