Skip to content

Instantly share code, notes, and snippets.

View codehacken's full-sized avatar

Ashwinkumar Ganesan codehacken

View GitHub Profile
@codehacken
codehacken / gist:5e5c7028611d52909b516fbb716d1ad6
Created March 16, 2019 22:53
Replace part of all the names of files in a folder.
find . -type f -exec rename 's/<original string>/<string to be replaced with>/g' {} +
@codehacken
codehacken / hclustering.py
Created July 27, 2017 20:01
Agglomerative clustering using Scikit-Learn (with a custom distance metric)
"""
Hierarchial Clustering.
The goal of gist is to show to use scikit-learn to perform agglomerative clustering when:
1. There is a need for a custom distance metric (like levenshtein distance)
2. Use the distance in sklearn's API.
Adapted from: sklearn's FAQ.
http://scikit-learn.org/stable/faq.html
"""
@codehacken
codehacken / sliding_window.py
Last active October 16, 2021 03:29
Create a Sliding Window function using NumPy.
# Create a function to reshape a ndarray using a sliding window.
# NOTE: The function uses numpy's internat as_strided function because looping in python is slow in comparison.
# Adopted from http://www.rigtorp.se/2011/01/01/rolling-statistics-numpy.html
import numpy as np
# Reshape a numpy array 'a' of shape (n, x) to form shape((n - window_size), window_size, x))
def rolling_window(a, window, step_size):
shape = a.shape[:-1] + (a.shape[-1] - window + 1 - step_size + 1, window)
strides = a.strides + (a.strides[-1] * step_size,)
@codehacken
codehacken / readme.md
Created October 22, 2016 02:35 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@codehacken
codehacken / tmux-cheatsheet.markdown
Created September 1, 2016 01:57 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@codehacken
codehacken / py_pkg_update.sh
Last active January 7, 2016 23:02
Update all Python Packages in Ubuntu
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@codehacken
codehacken / list.sh
Last active December 28, 2015 03:19
Get the list of all the packages through the adb shell. The -f gives the apk that is associated with the package.
adb shell pm list packages -f