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
#!/usr/bin/env python | |
import csv | |
import sys | |
if 3 > len(sys.argv): | |
sys.exit("Usage: %s <csv_file> <column_to_print>" % sys.argv[0]) | |
fileparse = csv.reader(open(sys.argv[1])) | |
for f in fileparse: |
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
#!/usr/bin/env python | |
import sys | |
def main(): | |
for line in sys.stdin: | |
print("%s\n" % bytes.fromhex(line.replace(' ', '').strip()).decode('utf-8')) | |
if '__main__' == __name__: | |
main() |
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 static java.util.Arrays.deepToString; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.Queue; | |
class SecretSanta { | |
public String[][] go(String[] s) { |
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
text/html; w3m -I %{charset} -T text/html; copiousoutput; |
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
#!/usr/bin/env python | |
""" | |
Example of how you can test if strings are anagrams | |
""" | |
def is_anagram(str1, str2): | |
""" | |
Check if str1 is an anagram of str2 |
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
#!/usr/bin/env python | |
""" | |
Here is a simple example of how you can | |
use a generator to fetch a row from a database | |
""" | |
import MySQLdb |
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
""" | |
There are multiple ways to append to a string in Python | |
""" | |
str0 = "This is my string" | |
# Use the + operator |
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
>>> round(0.5) | |
1.0 | |
>>> round(2.5) | |
3.0 | |
>>> round(0.4) | |
0.0 | |
>>> round(2.6) | |
3.0 |
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
# This is the main meat and potatoes of what I really want | |
grep -E DEBUG 2015-10-09.err | grep -E '(anonymous_id|high_scores:)'| sed -e 's/anonymous_id//g' |cut -d ' ' -f 2-| python -c "import fileinput; l0=[int(x.split(' ')[-1].strip()) for x in fileinput.input()];print('searches:{}\thigh_scoring:{}\tratio:{}'.format(l0[0],l0[1],l0[1]/float(l0[0])))" | |
# This is just a bonus to loop through a date range of my log files | |
for d in {0..15}; do today=`date -d "2015-10-09 + $d days" +'%Y-%m-%d'`; echo -n "${today} "; grep -E DEBUG ${today}.err|grep -E '(anonymous_id|high_scores:)'| sed -e 's/anonymous_id//g' |cut -d ' ' -f 2-| python -c "import fileinput; l0=[int(x.split(' ')[-1].strip()) for x in fileinput.input()];print('searches:{}\thigh_scoring:{}\tratio:{}'.format(l0[0],l0[1],l0[1]/float(l0[0])))"; done |
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
SELECT | |
variance, | |
standard_deviation, | |
input | |
FROM (standardDeviation( | |
SELECT | |
'[' + GROUP_CONCAT_UNQUOTED(STRING(score)) + ']' AS json_array_input | |
FROM ( | |
SELECT | |
score |
OlderNewer