Skip to content

Instantly share code, notes, and snippets.

View ahlusar1989's full-sized avatar
🏀
Let's Go!

Saran Ahluwalia ahlusar1989

🏀
Let's Go!
View GitHub Profile
@ahlusar1989
ahlusar1989 / snr-periodic.py
Created December 12, 2020 22:28 — forked from mbejger/snr-periodic.py
Matched filter and signal-to-noise for a periodic template
"""
Plot white noise with added sinusoidal signal
"""
import numpy as np
import matplotlib.pyplot as plt
import sys
import h5py
fs = 4096 # sampling rate [Hz]
T = 4 # duration [s]
@ahlusar1989
ahlusar1989 / YeoJohnson.py
Created June 13, 2019 23:08 — forked from mesgarpour/YeoJohnson.py
Yeo-Johnson Transformation
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import warnings
import numpy as np
import pandas as pd
import sys
__author__ = "Mohsen Mesgarpour"
__copyright__ = "Copyright 2016, https://github.com/mesgarpour"
__credits__ = ["Mohsen Mesgarpour"]
@ahlusar1989
ahlusar1989 / GibbsLDA.py
Created March 23, 2018 21:16 — forked from ChangUk/GibbsLDA.py
Collapsed Gibbs sampler for Latent Dirichlet Allocation
#-*- coding: utf-8 -*-
"""
GIBBS SAMPLING IMPLEMENTATION FOR LATENT DIRICHLET ALLOCATION (2003)
IMPLEMENTED BY CHANG-UK, PARK
DATA FORMAT: "DocID\t WordID\t FREQUENCY\n"
"""
import sys
import random
@ahlusar1989
ahlusar1989 / jupyter-google-cloud.md
Last active January 4, 2018 15:13 — forked from valentina-s/jupyter-google-cloud.md
Jupyter Notebook on Google Cloud Compute Instance

On Instance:

pip install jupyter[notebook]

jupyter notebook --generate-config

# nano .jupyter/jupyter_notebook_config.py

echo "c = get_config()
c.NotebookApp.ip = '*'
@ahlusar1989
ahlusar1989 / pytorch_keras_gcloud.txt
Created January 2, 2018 16:24 — forked from motiur/pytorch_keras_gcloud.txt
Keras and Pytorch in Google Cloud VM
# This script is designed to work with ubuntu 16.04 LTS
# with keras 1.2.2 and the latest Pytorch with CUDA 8 support
##########################################################################
#This is used to install CUDA 8 driver for Tesla K80
##########################################################################
#!/bin/bash
echo "Checking for CUDA and installing."
# Check for CUDA and try to install.
if ! dpkg-query -W cuda-8-0; then
@ahlusar1989
ahlusar1989 / middlewares.py
Created October 11, 2017 19:47 — forked from seagatesoft/middlewares.py
An example of RotateUserAgentMiddleware
from random import choice
from scrapy import signals
from scrapy.exceptions import NotConfigured
class RotateUserAgentMiddleware(object):
"""Rotate user-agent for each request."""
def __init__(self, user_agents):
self.enabled = False
self.user_agents = user_agents
@ahlusar1989
ahlusar1989 / LRUCache.js
Created June 8, 2017 17:30 — forked from tpae/LRUCache.js
super simple JavaScript Implementation of LRUCache
// LRUCache.js - super simple JavaScript Implementation
// LRU stands for "Least Recently Used"
// https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
// -----------------------------------------
function LRUNode(key) {
this.key = key;
this.next = this.prev = null;
}
import { graphql } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import {
change,
getFormSubmitErrors,
getFormValues,
reduxForm,
stopAsyncValidation,
@ahlusar1989
ahlusar1989 / int_additions.scala
Created September 4, 2016 14:22 — forked from herval/int_additions.scala
Manipulating maps with Monoids
object MindBlown extends App {
trait Monoid[A] {
def op(a1: A, a2: A): A
def zero: A
}
val intAddition = new Monoid[Int] {
override def op(a1: Int, a2: Int) = a1 + a2
override def zero = 0
}
@ahlusar1989
ahlusar1989 / rds_to_docker.md
Created September 4, 2016 14:21 — forked from rtorino/rds_to_docker.md
Moving a Postgres db from RDS to a Docker container

Make a backup from RDS

pg_dump -h <rds host> -p 5432 -F c -O -U <rds user> <db name> > db.dump

Restore the backup into a Docker container

docker run --rm --interactive --link <postgres container id>:postgres --volume $PWD/:/tmp/ postgres:latest /bin/bash -c 'pg_restore --verbose --clean --no-acl --no-owner -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -d <db name> /tmp/db.dump'