Skip to content

Instantly share code, notes, and snippets.

Avatar

Trey Keown jfktrey

View GitHub Profile
View maze.py
import random
import sys
import time
while True:
sys.stdout.write(random.choice([u'╱',u'╲']))
sys.stdout.flush()
time.sleep(0.01)
View gist:76154591dd63eae0b68a24ac3eec6dc1
### 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 / svg_html2canvas.js
Created Feb 26, 2014
Work around SVG drawing issues when capturing screenshot using html2canvas
View svg_html2canvas.js
// 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);
}
@jfktrey
jfktrey / getch.py
Last active Mar 9, 2020
Cross-platform getch() for Python without any fuss
View getch.py
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 / b3b7.js
Created Jan 24, 2014
Obfuscated base transform
View b3b7.js
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 / gist:6026314
Created Jul 18, 2013
Save the current directory listing to a file
View gist:6026314
DIR /B > list.txt
@jfktrey
jfktrey / gist:6026313
Created Jul 18, 2013
Start Chrome in application mode - menuless, no URL bar
View gist:6026313
chrome.exe --app="file:///%CD%/index.html"
You can’t perform that action at this time.