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
// Originally taken from https://github.com/mgtitimoli/await-mutex | |
class Mutex { | |
constructor() { | |
this._locking = Promise.resolve(); | |
this._locked = false; | |
} | |
isLocked() { | |
return this._locked; |
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($){ | |
// Bind to an input field. Provide chars, a string of characters. | |
// Now only those characters can be typed in. | |
$.fn.whitelist = function(chars){ | |
var $this = $(this), chars = chars.split(''); | |
$this.keypress(function(e){ | |
if (chars.indexOf(String.fromCharCode(e.which)) == -1){ return false; }}); | |
return $this; | |
}; | |
}(jQuery)); |
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
# Installing Phantomjs 2.0 can be kind of a pain. Their website claims they don't have | |
# any Linux binaries to share because of an unresolved dependency issue. | |
# However, someone going by eugene1g shared some binaries that he build that seem | |
# to work given a small amount of apt-get setup. https://github.com/eugene1g/phantomjs | |
sudo su | |
apt-get update | |
apt-get install unzip libfontconfig libjpeg-turbo8 | |
cd /tmp |
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
# for tmux status bar | |
info = `pmset -g batt`.split("\n") | |
perc = info[1].split(" ")[1].gsub(";","") | |
charging = info[0].include? "AC Power" | |
as_f = perc.to_f | |
if as_f > 75 | |
status = "green" | |
bars = 4 | |
elsif as_f > 50 | |
status = "yellow" |
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
package btce | |
import ( | |
"bytes" | |
"net/http" | |
"net/url" | |
"time" | |
"crypto/sha512" | |
"crypto/hmac" | |
"strconv" |
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
from subprocess import Popen, PIPE | |
import sys | |
import re | |
import os | |
APP_DIR = '/Users/artur/Work/Codecademy-dev/Codecademy/app/' | |
VIEWS = ['erb', 'mustache', 'haml'] | |
def search(query, filetypes=[]): | |
args = ['grep', '-r', '-I', '--exclude=".git"'] |
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
# POSTs your confirmation key, first name, and last name | |
# to Southwest.com check-in endpoint over and over | |
# until it doesn't see the 24-hour error. | |
# In testing I never got rate-limited or blocked | |
# but I didn't let it run for very long at a time | |
# so use at your own risk. :) | |
# Six-character SW confirmation token here | |
CONF=AB1234 |
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
. $HOME/.bash_profile | |
cd $HOME/Codecademy/app | |
check_usage () { | |
while read data | |
do | |
PARTIAL_NAME=$(echo $data | sed 's/views\///g' | sed 's/\/\_/\//g' | sed 's/\..*//g') | |
PARTIAL_LOCAL_NAME=$(echo $PARTIAL_NAME | sed 's/.*\///g') |
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
for own ind, char of as | |
# Iterate over the characters in a-split | |
if matching | |
# So far we have only found matching chars... | |
if bs[ind] == char | |
# If they're still matching then great | |
continue | |
else | |
# Uh-oh! We've found the first mistmatch! | |
matching = false |
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
#!/bin/sh | |
# Remove all .sedbak files (sed backup files) | |
find . -name "*.sedbak" -print0 | xargs -0 rm |
NewerOlder