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 / xvfb
Created June 15, 2016 02:27 — forked from dloman/xvfb
### BEGIN INIT INFO
# Provides: Xvfb
# Required-Start: $local_fs $remote_fs
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Loads X Virtual Frame Buffer
### END INIT INFO
@ahlusar1989
ahlusar1989 / setup_selenium.sh
Created June 15, 2016 11:24 — forked from curtismcmullan/setup_selenium.sh
Setup Selenium Server on Ubuntu 14.04
#!/bin/bash
# Following the guide found at this page
# http://programmingarehard.com/2014/03/17/behat-and-selenium-in-vagrant.html
echo "\r\nUpdating system ...\r\n"
sudo apt-get update
# Create folder to place selenium in
#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04) trying on ubuntu server 14.04
# Add Google Chrome's repo to sources.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
# Install Google's public key used for signing packages (e.g. Chrome)
# (Source: http://www.google.com/linuxrepositories/)
@ahlusar1989
ahlusar1989 / install_chrome_driver
Created June 15, 2016 18:20 — forked from thotmx/install_chrome_driver
Install chromedriver in Ubuntu (14.04)
$ sudo apt-get install chromium-chromedriver
$ sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
@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'
@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
}
import { graphql } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import {
change,
getFormSubmitErrors,
getFormValues,
reduxForm,
stopAsyncValidation,
@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;
}
@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 / 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