This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "{}" \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? :-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | | |
| + * = . | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def asyncsleep(t, callback=None): | |
ioloop.add_timeout( time.time() + t, callback ) | |
class NestedYieldAsync(tornado.web.RequestHandler): | |
@tornado.web.asynchronous | |
@tornado.gen.engine | |
def get(self): | |
yield gen.Task( self.lots_of_waits ) | |
yield gen.Task( self.lots_of_waits ) |