Skip to content

Instantly share code, notes, and snippets.

View cadrev's full-sized avatar

Felan Carlo Garcia cadrev

View GitHub Profile
@cadrev
cadrev / heat_index.txt
Last active August 24, 2016 08:24
Excel Heat Index Formula for Spreadsheet Cells
A2 = Temperature in Celsius
B2 = Humidity
=IF((A2*9/5+32)<=80,A2,IF(AND(B2<13,((A2*9/5+32)>80),((A2*9/5+32)<112)),(((-42.379+2.04901523*(A2*9/5+32)+10.14333127*B2-0.22475541*(A2*9/5+32)*B2-0.00683783*(A2*9/5+32)*(A2*9/5+32)-0.05481717*B2*B2+0.00122874*(A2*9/5+32)*(A2*9/5+32)*B2+0.00085282*(A2*9/5+32)*B2*B2-0.00000199*(A2*9/5+32)*(A2*9/5+32)*B2*B2)-32)*5/9)-(((13-B2)/4)*SQRT((17-ABS((A2*9/5+32)-95))/17)),IF(AND(B2>85,((A2*9/5+32)>80),((A2*9/5+32)<87)),(((-42.379+2.04901523*(A2*9/5+32)+10.14333127*B2-0.22475541*(A2*9/5+32)*B2-0.00683783*(A2*9/5+32)*(A2*9/5+32)-0.05481717*B2*B2+0.00122874*(A2*9/5+32)*(A2*9/5+32)*B2+0.00085282*(A2*9/5+32)*B2*B2-0.00000199*(A2*9/5+32)*(A2*9/5+32)*B2*B2)-32)*5/9)+((B2-85)/10)*((87-(A2*9/5+32))/5),(((-42.379+2.04901523*(A2*9/5+32)+10.14333127*B2-0.22475541*(A2*9/5+32)*B2-0.00683783*(A2*9/5+32)*(A2*9/5+32)-0.05481717*B2*B2+0.00122874*(A2*9/5+32)*(A2*9/5+32)*B2+0.00085282*(A2*9/5+32)*B2*B2-0.00000199*(A2*9/5+32)*(A2*9/5+32)*B2*B2)-32)*5/9))))
@cadrev
cadrev / elastic_transform.py
Created July 11, 2016 07:58 — forked from fmder/elastic_transform.py
Elastic transformation of an image in Python
import numpy
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@cadrev
cadrev / k-fold CV.r
Created July 6, 2016 15:41 — forked from bhoung/k-fold CV.r
starter code for k fold cross validation using the iris dataset
# original example from Digg Data website (Takashi J. OZAKI, Ph. D.)
# http://diggdata.in/post/58333540883/k-fold-cross-validation-in-r
library(plyr)
library(randomForest)
data <- iris
# in this cross validation example, we use the iris data set to
@cadrev
cadrev / upgrade-postgres-9.3-to-9.5.md
Created June 9, 2016 06:58 — forked from johanndt/upgrade-postgres-9.3-to-9.5.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@cadrev
cadrev / contours.py
Created April 9, 2016 19:32 — forked from jsundram/contours.py
Convert matplotlib contours into valid (compressed) topojson.
import logging
import matplotlib.pyplot as plt
import numpy as np
import os
import scipy.stats as stats
import sys
def read_data(filename):
"""Reads a data file assumed to have at least 2 columns: 1) lat, 2) lng."""

Installing Flask

sudo apt-get install python-pip
sudo pip install flask

Basic Code

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is an implementation of adenoising autoencoder as
# described on the following paper:
# http://www.jmlr.org/papers/volume11/vincent10a/vincent10a.pdf
#
import numpy as np
import os
#
# Kayo nalang maglagay kung paano kukunin iyong
# data from the database tapos either gawin niyo sya
# na script running on the background or
# naka cron job per minute
#
data = "get from local database"

Putting wings on the Elephant

[operating-hadoop]

HBase is used widely at Facebook and one of the biggest usecase is Facebook Messages. With a billion users there are a lot of reliability and performance challenges on both HBase and HDFS. HDFS was originally designed for a batch processing system like MapReduce/Hive. A realtime usecase like Facebook Messages where the p99 latency can`t be more than a couple hundreds of milliseconds poses a lot of challenges for HDFS. In this talk we will share the work the HDFS team at Facebook has done to support a realtime usecase like Facebook Messages : (1) Using system calls to tune performance; (2) Inline checksums to reduce iops by 40%; (3) Reducing the p99 for read and write latencies by about 10x; (4) Tools used to determine root cause of outliers. We will discuss the details of each technique, the challenges we faced, lessons learned and results showing the impact of each improvement.

speaker: Pritam Damania

Real-Time Market Basket Analysis for Retail with

@cadrev
cadrev / 2.ipynb
Created December 16, 2015 14:24 — forked from karlnapf/2.ipynb
Machine learning assignment 2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.