Skip to content

Instantly share code, notes, and snippets.

View iamaziz's full-sized avatar
🎲

Aziz Alto iamaziz

🎲
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / using_args_kwargs.py
Created November 15, 2018 17:44
How to use *args and **kwargs with a wrapper function
# how to use *args and **kwargs with wrapper
def main_function(a: int, b: int):
print(f'a: {a} + b: {b} = {a+b}')
def my_wrapper(*args, **kwargs):
print(f'wrapper recieved: {len(args)} args and {len(kwargs)} kwargs')
if 'a' not in kwargs: kwargs.update({'a': 6})
@iamaziz
iamaziz / explore_word2vec_in_Spark.ipynb
Created November 10, 2018 08:24
Exploring word2vec in PySpark
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import tensorflow as tf
import numpy as np
corpus_raw = 'He is the king . The king is royal . She is the royal queen '
# convert to lower case
corpus_raw = corpus_raw.lower()
words = []
for word in corpus_raw.split():
@iamaziz
iamaziz / read_csv_files_in_tar_gz_from_s3_bucket.py
Last active November 22, 2022 14:45
Read csv files from tar.gz in S3 into pandas dataframes without untar or download (using with S3FS, tarfile, io, and pandas)
# -- read csv files from tar.gz in S3 with S3FS and tarfile (https://s3fs.readthedocs.io/en/latest/)
bucket = 'mybucket'
key = 'mycompressed_csv_files.tar.gz'
import s3fs
import tarfile
import io
import pandas as pd
@iamaziz
iamaziz / ipynb2html.py
Created September 27, 2018 06:50
snippet: convert all Jupyter notebooks in current directory and its subdirectories "recursively"
from subprocess import check_output
from glob import glob
notebooks = glob('./**/*.ipynb', recursive=True)
for n in notebooks:
cmd = f'jupyter nbconvert --to html {n}'
check_output(cmd.split())
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / xor.ipynb
Created June 2, 2017 18:46
learning XOR
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / list.py
Last active July 16, 2017 02:48
naive implementation for list data structure (int type)
"""
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):