Skip to content

Instantly share code, notes, and snippets.

Kyle Graehl kzahel

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am kzahel on github.
  • I am kzahel (https://keybase.io/kzahel) on keybase.
  • I have a public key whose fingerprint is DA94 D8F4 2077 A469 1F1A EF8E 8DAF 10FD 6F6D BD3D

To claim this, I am signing this object:

View download-fonts.py
import json
import os
""" to get the following string, i went to https://google-webfonts-helper.herokuapp.com/fonts/abeezee?subsets=latin and opened devtools and typed
a=document.querySelectorAll('a.list-group-item')
for (var i=0; i<a.length ; i++) { ah.push(a[i].href) }
JSON.stringify(ah)
View lru.py
import collections
class LRUCache:
def __init__(self, capacity):
self.capacity = capacity
self.cache = collections.OrderedDict()
def get(self, key):
try:
value = self.cache.pop(key)
@kzahel
kzahel / delete-dsstore-etc.sh
Created Oct 9, 2016
delete .DS_Store and the other extended files ._*
View delete-dsstore-etc.sh
WHAT="rm"
#WHAT="echo" #uncomment this for dry run
echo "Going to remove mac extended files in $1"
read -p "press enter key to continue"
find $1 -type f -name "._*" -exec $WHAT "{}" \;
find $1 -type f -name ".DS_Store" -exec $WHAT "{}" \;
@kzahel
kzahel / replace.py
Created Sep 4, 2016
replace recursive text exclude .git directory
View replace.py
import os, fnmatch
def findReplace(directory, find, replace, filePattern):
for path, dirs, files in os.walk(os.path.abspath(directory), topdown=True):
dirs[:] = [d for d in dirs if d not in '.git']
for filename in fnmatch.filter(files, filePattern):
filepath = os.path.join(path, filename)
with open(filepath) as f:
s = f.read()
s = s.replace(find, replace)
with open(filepath, "w") as f:
View gist:6eb6ebaa7a495e7329bc0392305a2db3
function wait_for_devtools( callback, giveup_after ) {
giveup_after = giveup_after || 10
var start = Date.now()
var timeout
var triggered = false
var element = new Image();
element.__defineGetter__('id', done)
function done() {
if (triggered) return ''
View audiotest.html
<html>
<body>
<audio id="myaudio" preload="auto" src="data:audio/wav;base64,UklGRiZvAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YQJvAACAgoaJjIuJiIuNkZSXmZqdn52bnJ6hoqGhoqOko6CenqGkpaepq62uraqoqKmppqKfn52alpKQkZSTkIuKiYaDf318fX5+e3l4eHZzc3R3en+Afn6Ag4OCgoWHio2NjIuKiIWDhIeKjI2MiYWBf3x7foKEhYSCfn19fn+Ch4uNjYuIhYSDgYKEh4mJiYeFgoKBgIKEhYWEg4J/fn2AhIuPkI+NiYeFg4OFhoiGhIGAfn+Af4CDhYaEg4KAgYKBgYSHiYeGhYSDgoB/fXx7eHRwbm5ub3FydHV3dnV1eX2BhYmOkZWVlpeYmp2gpKipp6akoZ6bmJWVl5eWk5CLh4aEhIKDhISAenVvbGtoZGJjYmFcVlNSVFNQTlBRUU1HQkBCRUZGR0tOTkxGQ0ZKTU5OUVVXVE5LS09RUVBRVVdXUk1NUVVYWFldYmNfWlpeYWRmaWxxcnFubG5ydHV2d3h3dXFubnF0dHJyc3JycGxtcXl9gIGBg4WDf3x8gISFhoeJiYeCgH+Ei46NjYyLiYeEgYSJjo+PkJGRkI2MjpOWl5WVlZaVko+Qk5iYlJGQj42Jh4eKjYyHhIODhIF+fX+ChIJ8eHd2dHJxc3Z4eHZ0dnd4d3h6foKCgICAgH97eHd3dXNvbG1ub25qZ2lraGNfXV5hX11cXV5gXl1dYGNmZ2psb29uamhoamtqamlpZ2JcV1dYWlteYGRmZ2NfYGNmbHBydnd2cWtoam1wdXd4eXx5dnR0d3h7fH6AgoJ+eXR0c3N2e3+CgoB5dXR2d3p+hIiJiYaDgoSJkZifpqmqq6qoqKiprLC1uLi1r6mlpaanqq+ztLGro5uYlpeZmpydnJaOh4KCgYODhYiJiIR/fX1/
View auto indent
to get previous behavior:
(define-key global-map (kbd "RET") 'newline-and-indent)
now why would they go and change the default of enter key? :-)
@kzahel
kzahel / gist:1530ce5e00a7124bff60c8f91324eda8
Last active May 2, 2016
ChromeOS sshd openssh server
View gist:1530ce5e00a7124bff60c8f91324eda8
sudo su
apt-get install -y openssh-server iptables
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
mkdir -p -m0755 /var/run/sshd
/usr/sbin/sshd
#
View ssh check host fingerprint visually
ssh -o VisualHostKey=yes -o FingerprintHash=md5 {host}
The authenticity of host '{host} (ip)' can't be established.
ECDSA key fingerprint is MD5:f9:8d:d8:fc:93:7a:fb:1e:90:a2:4c:49:26:ef:cf:d1.
+---[ECDSA 256]---+
| |
| |
| . o |
| = o . |
| S . o |
| + * = . |
You can’t perform that action at this time.