Skip to content

Instantly share code, notes, and snippets.

View estensen's full-sized avatar
🐢
making things go brrr

Håvard Anda Estensen estensen

🐢
making things go brrr
  • reMarkable
  • Oslo
  • 03:11 (UTC +02:00)
View GitHub Profile
@estensen
estensen / git-leaderboard.sh
Created June 5, 2020 12:24
Printing a leaderboard of authors based on number of commits in a git repo
git log --format='%an' | sort | uniq -c | sort -nr
@estensen
estensen / visualize_ecc.py
Created June 3, 2019 10:58
Visualize point addition on elliptic curves
import numpy as np
import matplotlib.pyplot as plt
a = -1
b = 1
y, x = np.ogrid[-2:2:100j, -2:2:100j]
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

Keybase proof

I hereby claim:

  • I am estensen on github.
  • I am estensen (https://keybase.io/estensen) on keybase.
  • I have a public key ASCpe6FTHkFhQO2UGIgPKsMfbUepSZWRcICID0NcBQhTywo

To claim this, I am signing this object:

@estensen
estensen / gist:25564359ac7d4e89106671a78fac675f
Created November 14, 2018 10:48
Display top 20 shell commands
history | cut -c8- | cut -d' ' -f1 | sort | uniq -c | sort -nr | head -n20
@estensen
estensen / totient.py
Created April 13, 2018 17:24
Euler's totient function
import math
f = lambda n:sum(math.gcd(n,x)<2for x in range(n))
print(f(500)) # 200
@estensen
estensen / gist:c68277c22abad637e21eb622895269dd
Created October 27, 2017 03:36
Delete all local branches that are merged
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@estensen
estensen / shift_rotate_right.py
Last active October 17, 2017 01:06
Circular binary rotation for use in security class
def rotr(num, bits):
num &= (2 ** bits-1)
bit = num & 1
num >>= 1
if bit:
num |= (1 << (bits-1))
return num
numr = 1
@estensen
estensen / bw_thumbnail.py
Created October 13, 2017 17:28
Resize JPEG to 128x128 and apply B/W filter
import os, sys
from PIL import Image
new_size = (128, 128)
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + "_thumbnail.jpg"
if infile != outfile:
try:
image = Image.open(infile)