Skip to content

Instantly share code, notes, and snippets.

View coderfi's full-sized avatar

Fairiz 'Fi' Azizi coderfi

View GitHub Profile
@coderfi
coderfi / min-char-rnn.py
Created March 7, 2017 08:37 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@coderfi
coderfi / dump_redis_sorted_set_keys.py
Created March 10, 2017 07:16
dump redis sorted set keys
#!/usr/bin/env python
''' Dumps the location ids in a sorted set '''
import redis
import sys
def dump(key, redis_host, redis_port=6379):
rconn = redis.StrictRedis(redis_host, port=redis_port)
@coderfi
coderfi / automobile.ipynb
Created June 4, 2017 21:11 — forked from martinwicke/automobile.ipynb
Estimator demo using Automobile dataset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@coderfi
coderfi / prettyxml.py
Created December 3, 2017 06:14
Pretty prints an xml file
#!/usr/bin/env python
''' Pretty prints an xml file.
Usage:
python prettyxml.py [filename.xml]
or
cat filename.xml | python prettyxml.py
#! /usr/bin/env bash
#sudo apt-get install --yes autoconf
WORKING_DIR=`pwd`
LIBLBFGS_GIT=https://github.com/chokkan/liblbfgs.git
LIBLBFGS_SRC_DIR=./liblbfgs/
LIBLBFGS_INSTALL_DIR=$WORKING_DIR/local/lbfgs/
CRFSUITE_GIT=https://github.com/chokkan/crfsuite.git
CRFSUITE_SRC_DIR=./crfsuite/
@coderfi
coderfi / hive_spark_sql_md5_to_bigint.sql
Created March 23, 2018 18:16
HIVE/SPARK SQL convert md5 to bigint
-- takes the leftmost 16 hex-characters of the md5 hash of foo, converts it to base-10, and casts it to a 64-bit number
-- Note: this decreases the possible space of hashes!
SELECT CAST(conv(substring(md5("foo"), 0, 16), 16, 10) AS BIGINT)");
@coderfi
coderfi / gist:7e6c70e70187b225ec3a740e0aeff672
Created May 10, 2018 00:45
pyspark 2.3.0 Local Sensitivity Hashing
https://databricks.com/session/locality-sensitive-hashing-by-spark
https://databricks.com/blog/2017/05/09/detecting-abuse-scale-locality-sensitive-hashing-uber-engineering.html
https://github.com/apache/spark/blob/v2.3.0/examples/src/main/python/ml/min_hash_lsh_example.py
pip install -u pyspark
git clone https://github.com/apache/spark
cd spark
git checkout v2.3.0
spark-submit --master='local[*]' --driver-memory=4g examples/src/main/python/ml/min_hash_lsh_example.py
@coderfi
coderfi / sample_keras_multilabel.py
Created May 14, 2018 21:59
MultiLabel classifier example using Keras + Tensorflow
#!/usr/bin/env python
''' MultiLabel classifier example using Keras + Tensorflow.
Based on
* https://www.depends-on-the-definition.com/guide-to-multi-label-classification-with-neural-networks/
* https://www.depends-on-the-definition.com/classifying-genres-of-movies-by-looking-at-the-poster-a-neural-approach/
* https://keras.io/getting-started/sequential-model-guide/#examples
'''
@coderfi
coderfi / create-mint-sh
Created June 27, 2018 22:35 — forked from gildas/create-mint-sh
Create Linux Mint USB on Mac OS/X
#! /usr/bin/env bash
# Insert a USB key.
# if needed initialize it with MS/DOS FAT and MBR
# Download the Mint ISO image
# Convert the ISO -> IMG
hdiutil convert -format UDRW -o linuxmint-17.3-cinnamon-64bit linuxmint-17.3-cinnamon-64bit.iso
# Run a diskutil list to know the device for the USB key, e.g.: /dev/disk3
@coderfi
coderfi / docker_mint18.sh
Created June 28, 2018 05:20 — forked from mcmaur/docker_mint18.sh
Install Docker on Linux Mint 18 Sylvia
#remove old
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"