This file contains hidden or 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
$('body').keypress( | |
function (e) { | |
console.log( | |
String.fromCharCode( e.which ) | |
); | |
} | |
); |
This file contains hidden or 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
rhc set-env VARIABLE1=VALUE1 VARIABLE2=VALUE2 -a app_name |
This file contains hidden or 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 csv | |
f = open(csv_file.csv) | |
# Read the CSV format, each row will become an array | |
rows = csv.reader(f) | |
for row in rows | |
variable_a = row[0] # The first column | |
variable_b = row[1] # The second column, etc. |
This file contains hidden or 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 csv | |
import codecs | |
import re | |
def load_dictionary(csv_file, idx, lbl): | |
d = {} | |
f = open(csv_file, encoding="utf-8") | |
s = csv.reader(f) | |
for r in s: | |
i = r[idx] # Read index |
This file contains hidden or 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 hashids import Hashids | |
hashids = Hashids(salt='vt', min_length=5, alphabet='abcdefghijkmnopqrstuvwxyz') | |
for i in range(12000,12100): | |
print (hashids.encrypt(i)) |
This file contains hidden or 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
oldText = $('.tag').html(); | |
newText = oldText.replace(/\{(.+?)\}/g, '<span class="x">$1</span>'); | |
$('.tag').replaceWith(newText); |
This file contains hidden or 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
# Enable tab completion | |
source ~/git-completion.bash | |
# colors! | |
# blue="\[\033[0;34m\]" | |
# purple="\[\033[0;35m\]" | |
# For background, add \[\033[48;5;256m\] | |
blue="\[\033[38;5;32m\]" | |
purple="\[\033[38;5;198m\]" | |
green="\[\033[0;32m\]" |
This file contains hidden or 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
soup.find_all('div', {'class': ['first', 'second']}) | |
soup.find_all(lambda tag: tag.name=="div" and | |
tag.get("id")=="examples_box" and | |
tag.get("class") == "term-subsec") |
This file contains hidden or 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
new_string = re.sub(r' +',' ',old_string) |
This file contains hidden or 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
>>> a=13.946 | |
>>> print(a) | |
13.946 | |
>>> print("%.2f" % a) # It seems just this will do. | |
13.95 | |
>>> round(a,2) | |
13.949999999999999 | |
>>> print("%.2f" % round(a,2)) | |
13.95 | |
>>> print("{0:.2f}".format(a)) |