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
#!/usr/bin/env python | |
__author__ = 'Aziz' | |
""" | |
Convert all ipython notebook(s) in a given directory into the selected format and place output in a separate folder. | |
usages: python cipynb.py `directory` [-to FORMAT] | |
Using: ipython nbconvert and find command (Unix-like OS). |
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
#!/usr/bin/env python | |
""" | |
Usage: | |
$ git-file-size-growth <NUM_COMMIT> | |
note: | |
- Put `git-file-size-growth` somewhere in your PATH along with `git-file-size-diff` | |
# see `git-file-size-diff` at: http://stackoverflow.com/questions/10845051/git-show-total-file-size-difference-between-two-commits/10847242#10847242 | |
""" |
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
# -*- coding: utf-8 -*- | |
# calculating the Entropy and Information Gain for: Learning with Trees | |
# by: Aziz Alto | |
# see Information Gain: | |
# http://www.autonlab.org/tutorials/infogain.html | |
from __future__ import division |
OlderNewer