Skip to content

Instantly share code, notes, and snippets.

@IshankGulati
IshankGulati / latency.txt
Created November 2, 2016 09:54 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@IshankGulati
IshankGulati / RVObserver.java
Last active December 2, 2020 07:54
Base Adapter and RecyclerView.ViewHolder implementation for delegating clicks to Fragment to which adapter is attached. This gist is inspired from https://gist.github.com/aurae/ebf8ec212e4296aebb24 .
/**
* Created by Ishank Gulati on 14/10/16.
* Observer as per Observer design pattern.
*/
public interface RVObserver {
void update(RecyclerViewItemClickListener listener);
}
@IshankGulati
IshankGulati / kalmanFilter.py
Created February 29, 2016 15:24
A multi-dimensional implementation of Kalman Filter in Python
# Multi dimensional Kalman filter
from math import *
class matrix:
# implements basic operations of a matrix class
def __init__(self, value):
self.value = value
@IshankGulati
IshankGulati / AnisotropicDiffusion.cpp
Created December 13, 2015 08:32
Anisotropic (Perona–Malik) Diffusion
/* Anisotropic (Perona–Malik) Diffusion
Author: Ishank Gulati <[email protected]>
Reference
---------
Scale-Space and Edge Detection using Anisotropic Diffusion
Pietro Perona and Jitendra Malik
IEEE Transactions on Pattern Analysis and Machine Intelligence, VOL. 12, NO. 7, JULY 1990
@IshankGulati
IshankGulati / GA_clustering.py
Last active January 18, 2023 07:37
Clustering using Genetic Algorithm
"""Clustering using Genetic Algorithm"""
# Author: Ishank Gulati <[email protected]>
from __future__ import print_function
from __future__ import division
import numpy as np
from scipy.spatial.distance import euclidean
import scipy.misc as spm
@IshankGulati
IshankGulati / kernel_kmeans.py
Created November 8, 2015 12:19 — forked from mblondel/kernel_kmeans.py
Kernel K-means.
"""Kernel K-means"""
# Author: Mathieu Blondel <[email protected]>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state
@IshankGulati
IshankGulati / KMeans.py
Last active December 19, 2015 16:33
Image Segmentation using K-means clustering
"""Image Segmentation using K-means Clustering"""
# Author: Ishank Gulati <[email protected]>
from __future__ import print_function
from __future__ import division
import numpy as np
from scipy.spatial.distance import euclidean
import scipy.misc as spm