Skip to content

Instantly share code, notes, and snippets.

View iamaziz's full-sized avatar
🎲

Aziz Alto iamaziz

🎲
View GitHub Profile
@iamaziz
iamaziz / calculate_ams.py
Last active August 29, 2015 14:04
Calculate the evaluation metric "AMS" of Higgs Boson competition at Kaggle https://www.kaggle.com/c/higgs-boson/details/evaluation
# 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
@iamaziz
iamaziz / cmd_arg.py
Last active August 29, 2015 14:04
execute a terminal command in python with passing arguments
# 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)
@iamaziz
iamaziz / treeme.sh
Last active August 29, 2015 14:04
Script to create an html page as a tree of current directory, based on tree: http://mama.indstate.edu/users/ice/tree/
#!/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"
@iamaziz
iamaziz / replace_chars.py
Last active August 29, 2015 14:05
recursively replace each char (substring) in *args from a given text
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'
@iamaziz
iamaziz / Pandoc-to-dash.py
Last active August 29, 2015 14:14
Generate Dash docset for Pandoc
# quick-and-dirty script to generate Pandoc docset for Dash.app
#----------------------------------
# built-in packages
import sqlite3
import os
import urllib
import plistlib
#----------------------------------
@iamaziz
iamaziz / cipynb.py
Created February 16, 2015 01:01
Convert all ipython notebook(s) in a given directory into the selected format and place output in a separate folder. Using: ipython nbconvert and find command (Unix-like OS).
#!/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).
@iamaziz
iamaziz / Kivy-docset-to-dash.py
Created February 24, 2015 02:08
Generate Dash docset for Kivy
#----------------------------------
# built-in packages
import sqlite3
import os
import urllib
import plistlib
#----------------------------------
# third party packages + httrack
@iamaziz
iamaziz / change-file-names.py
Created March 8, 2015 21:18
Change file names in a directory and its sub-directories.
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(' ', '-'))
@iamaziz
iamaziz / git-file-size-growth
Last active February 15, 2020 01:46
See the total size growth between a number of consecutive commits in your git project. Based on http://stackoverflow.com/questions/10845051/git-show-total-file-size-difference-between-two-commits/10847242#10847242
#!/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
"""
@iamaziz
iamaziz / entropy_gain.py
Last active November 14, 2023 02:41
Calculate Entropy and Information Gain for Decision Tree Learning
# -*- 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