Skip to content

Instantly share code, notes, and snippets.

View coderfi's full-sized avatar

Fairiz 'Fi' Azizi coderfi

View GitHub Profile
@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 / 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 / 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 / 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)");
#! /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 / 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
@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 / 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 / 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 / git-selective-merge.md
Last active November 27, 2015 19:02 — forked from katylava/git-selective-merge.md
git selective merge

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git checkout -b temp