Skip to content

Instantly share code, notes, and snippets.

View jfktrey's full-sized avatar
Verified

Trey Keown jfktrey

Verified
View GitHub Profile
@jfktrey
jfktrey / b3b7.js
Created January 24, 2014 19:48
Obfuscated base transform
h = (n = prompt("in base-3: ")).length - 1;
b = +(o = []);
l = (m = Math).log;
for(i = h; i + 1; i--) b += m.pow(3,i) * n[h - i];
for(p = (b + "").length * l(10) / l(7) | 0; p+1;)
o.push(b / m.pow(7, p--) | 0),
b -= o[o.length - 1] * m.pow(7, p+1);
@jfktrey
jfktrey / getch.py
Last active May 11, 2023 09:42
Cross-platform getch() for Python without any fuss
import platform
if platform.system() == "Windows":
import msvcrt
def getch():
return msvcrt.getch()
else:
import tty, termios, sys
def getch():
fd = sys.stdin.fileno()
@jfktrey
jfktrey / svg_html2canvas.js
Created February 26, 2014 22:23
Work around SVG drawing issues when capturing screenshot using html2canvas
// Work around an annoying issue in Chrome where SVG images aren't drawn with respect to globalAlpha
window.CanvasRenderingContext2D.prototype.drawSvgImage = function(image, x, y, w, h) {
var canvas = document.createElement('canvas');
canvas.width = w;
canvas.height = h;
var context = canvas.getContext('2d');
context.drawImage(image, 0, 0, w, h);
this.drawImage(canvas, x, y, w, h);
}
### Keybase proof
I hereby claim:
* I am jfktrey on github.
* I am jfktrey (https://keybase.io/jfktrey) on keybase.
* I have a public key whose fingerprint is 9AD5 57DD C056 9938 865A 707A 5AC8 BC22 6974 F906
To claim this, I am signing this object:
@jfktrey
jfktrey / maze.py
Last active July 31, 2021 04:43
Maze
import random
import sys
import time
while True:
sys.stdout.write(random.choice([u'╱',u'╲']))
sys.stdout.flush()
time.sleep(0.01)