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
# Calculate the evaluation metric "AMS" of Higgs Boson competition at Kaggle | |
# https://www.kaggle.com/c/higgs-boson/details/evaluation | |
""" | |
__Author__ = "Aziz Alto" | |
""" | |
import numpy as np | |
import pandas as pd |
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
# execute a terminal command in python with passing arguments | |
# python command-line arguments | |
import os | |
arg1 = "first_argument" | |
arg2 = "second_argument" | |
terminal_command = "python test.py {0} {1}".format(arg1, arg2) | |
os.system(terminal_command) |
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/bash | |
# create a tree of current directory in an html page `readme.html` | |
# to use it: place treeme.sh somewhere and add it your path | |
# (add/remove any extension to EXECLUDE to be displayed/execluded) | |
TITLE="Tree of:" | |
PWD=$(pwd) | |
OUTPUT="readme.html" |
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 rep_chars(txt, *args): | |
"""recursively replace each char (substring) in *args from a given text""" | |
chars = [str(c) for c in args] | |
if len(chars) < 1: | |
return txt | |
else: | |
txt = txt.replace(chars.pop(), ' ' ) | |
return rep_chars( txt, *chars ) # repeat rep_chars() until *args is None | |
a = 'abcdefgh' |
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
# quick-and-dirty script to generate Pandoc docset for Dash.app | |
#---------------------------------- | |
# built-in packages | |
import sqlite3 | |
import os | |
import urllib | |
import plistlib | |
#---------------------------------- |
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
#---------------------------------- | |
# built-in packages | |
import sqlite3 | |
import os | |
import urllib | |
import plistlib | |
#---------------------------------- | |
# third party packages + httrack |
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 | |
for dpath, dnames, fnames in os.walk('/path/to/dir'): | |
for f in fnames: | |
os.chdir(dpath) | |
if f.endswith('.pdf'): | |
os.rename(f, f.replace(' ', '-')) |
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
# generate gensim docset | |
# http://radimrehurek.com/gensim/ | |
#---------------------------------- | |
# built-in packages | |
import sqlite3 | |
import os | |
import urllib | |
import plistlib |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
""" | |
Create a data structure that mimics Python's list. | |
IDEA: convert each element to a base representation with a fixed size (byte / binary / octal / hexadecimal ... etc) | |
then, concat elements as a string. | |
Based on meetup: https://www.meetup.com/Deep-Dive-into-Python-Know-Thy-Interpreter/events/238587475/ | |
""" | |
class List(object): |
OlderNewer