Skip to content

Instantly share code, notes, and snippets.

View sandys's full-sized avatar

Sandeep Srinivasa sandys

View GitHub Profile
@sandys
sandys / dockerfile_ruby_rbenv.sh
Last active May 27, 2021 15:21
Dockerfile for a ruby/rbenv setup on ubuntu/debian
# DOCKER-VERSION 1.0
# run with curl <gist path> | docker build -t sandys/rbenv -
#when exiting/stopping a container it remains in the filesystem
#every time we run docker run a new container is created
#https://github.com/dotcloud/docker/issues/3258
#stop all containers docker stop $(docker ps -a -q)
#rm all containers docker rm $(docker ps -a -q)
@sandys
sandys / hardware_token.md
Last active May 19, 2020 14:14
Registering a hardware token

OSX - https://github.com/OpenSC/OpenSC/releases/download/0.16.0/OpenSC-0.16.0.dmg

Fedora - sudo dnf install pcsc-tools opensc ccid

ubuntu - sudo dnf install pcsc-tools opensc libccid

Find out where OpenSC has installed the pkcs11 module.

For OS X with binary installation this is typically in /Library/OpenSC/lib/. Homebrew users can use export OPENSC_LIBS=$(brew --prefix opensc)/lib

@sandys
sandys / git_100mb_clean.md
Created April 28, 2020 14:13
how to clean your git repo of all blobs greater than 100M (github friendly)
  1. Download git-filter-repo script
  2. name the file as clean.py
  3. run python /tmp/clean.py --force --strip-blobs-bigger-than 100M --refs
@sandys
sandys / pg-docker.md
Created March 20, 2020 09:27
running postgresql on your laptop without installing it (using docker) . with connections to python

docker network create pg

docker run -it --rm -P -p 5432:5432 --name pg -e POSTGRES_PASSWORD=password -e POSTGRES_USER=postgres -e POSTGRES_DB=production -v pgdata:/var/lib/postgresql/data --network=pg postgres

pgdata is the name of the docker volume. You can check it using docker volume ls and docker volume inspect pgdata. You can delete the docker volume by docker volume rm pgdata and prune all volumes using docker volume prune docker volumes are created in your central docker directory (usually /var/lib/docker/overlay2 ). You generally dont need to care about this.

You can now access it in many ways:

@sandys
sandys / next.config.js
Created February 17, 2020 14:44
next.config.js for superprops
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')(['reusecore', 'common']);
const withOptimizedImages = require('next-optimized-images');
const withFonts = require('next-fonts');
const withCSS = require('@zeit/next-css');
const path = require("path");
module.exports = withPlugins(
[
@sandys
sandys / go-mtpfs.md
Created October 13, 2012 12:23
Mount the HTC One X on Linux (Ubuntu 12.04 Precise)
sudo apt-get install golang git mercurial
git clone https://github.com/hanwen/go-mtpfs.git
cd go-mtpfs
go build
sudo mv go-mtpfs /usr/local/sbin/go-mtpfs 
sudo chmod a+x /usr/local/sbin/go-mtpfs
sudo mkdir /media/mtp
sudo chmod 775 /media/mtp
sudo /usr/local/sbin/go-mtpfs -allow-other=true /media/mtp
@sandys
sandys / gridsearchcv.py
Created August 18, 2019 16:26
Gridsearchcv with k-fold cross validation and early stopping
#
... import xgboost.sklearn as xgb
... from sklearn.model_selection import GridSearchCV
... from sklearn.model_selection import TimeSeriesSplit
...
... cv = 2
...
... trainX= [[1], [2], [3], [4], [5]]
... trainY = [1, 2, 1, 2, 1]
@sandys
sandys / mailr_send.R
Last active October 10, 2018 21:08
R code to send email using Amazon SES
# first install mailR. It is a bit funky to install this because of the dependency on rJava
#First install java
### sudo add-apt-repository ppa:webupd8team/java
### sudo apt-get update
### sudo apt-get install oracle-java8-installer
#now you can install mailR. The assumption is that java is in /usr/lib/jvm/jdk1.8.0_66/. Check if a newer version has changed the directory
sudo JAVA_HOME=/usr/lib/jvm/jdk1.8.0_66/ R CMD javareconf
sudo JAVA_HOME=/usr/lib/jvm/jdk1.8.0_66/ Rscript -e 'install.packages(c("mailR"), .Library.site[1], repos="http://cran.us.r-project.org", dependencies=TRUE)'
@sandys
sandys / vscode-gatsby.conf
Created January 26, 2018 05:44
visual studio setup to debug gatsbyjs
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch (Production)",
"type": "node",
"request": "launch",
@sandys
sandys / damn-fast-ruby-setup.sh
Last active August 15, 2018 12:39
Set up a development environment for ruby in 30 minutes on ubuntu. This will use rbenv to take care of paths and will mimic how you would set up your production environment. A very clean separated setup conducive to integration with Puppet/chef (for installation of ruby versions) and Capistrano (for contained deployment). Allows for per-user own…
#pre-requisites
sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev git libpq-dev libmysqlclient-dev libpq-dev nodejs libcurl4-openssl-dev libffi-dev imagemagick libjpeg-progs pngcrush
############optional
sudo apt-get install sudo vim zsh
######### optional for jruby
sudo apt-get install openjdk-7-jdk