Skip to content

Instantly share code, notes, and snippets.

View miestasmia's full-sized avatar

Mia Nordentoft miestasmia

View GitHub Profile
@miestasmia
miestasmia / hashcollision.js
Created March 27, 2019 12:28
Determines the probability of a hash collision occuring and compares it to the probability of being killed by a shark or a meteor
#!/usr/bin/env node
/* https://preshing.com/20110504/hash-collision-probabilities/
*
* Question: "Given k randomly generated values, where each value is a
* non-negative integer less than N, what is the probability that at least two
* of them are equal?"
*
* In other words, what's the probability of a hash collision?
*

Keybase proof

I hereby claim:

  • I am miestasmia on github.
  • I am miestasmia (https://keybase.io/miestasmia) on keybase.
  • I have a public key whose fingerprint is E49B 469D E69C E408 BB19 26A0 C599 C3EB C2FA 3C8E

To claim this, I am signing this object:

@miestasmia
miestasmia / pastenoformat.py
Last active May 14, 2016 11:10
Pastes clipboard without formatting. Assign to a hotkey. GNU/Linux only
#!/usr/bin/env python2
import pyperclip, subprocess
copy = pyperclip.paste().decode('utf-8') # Automatically removes formatting
for char in copy:
n = hex(ord(char))[2:]
subprocess.call(["xdotool", "key", "U" + n])