Skip to content

Instantly share code, notes, and snippets.

View mohitsethi's full-sized avatar
🎯
Focusing

Mohit Sethi mohitsethi

🎯
Focusing
View GitHub Profile
@mohitsethi
mohitsethi / backup.sh
Created June 23, 2018 17:33 — forked from nherment/backup.sh
Backup and restore an Elastic search index (shamelessly copied from http://tech.superhappykittymeow.com/?p=296)
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
@mohitsethi
mohitsethi / connect.ps1
Created May 24, 2018 07:59 — forked from jdforsythe/connect.ps1
Remote Desktop Auto Login Powershell Script
echo "Connecting to 192.168.1.100"
$Server="192.168.1.100"
$User="Administrator"
$Password="AdminPassword"
cmdkey /generic:TERMSRV/$Server /user:$User /pass:$Password
mstsc /v:$Server
@mohitsethi
mohitsethi / starttls_smtp_example.go
Created March 24, 2018 20:33 — forked from jim3ma/starttls_smtp_example.go
Golang StartTLS SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@mohitsethi
mohitsethi / camera.py
Created March 11, 2018 06:56 — forked from cbednarski/camera.py
Webcam capture for python - Pops up a preview from your webcam and snaps a picture when you press 'q'
import cv2
# Windows dependencies
# - Python 2.7.6: http://www.python.org/download/
# - OpenCV: http://opencv.org/
# - Numpy -- get numpy from here because the official builds don't support x64:
# http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
# Mac Dependencies
# - brew install python
@mohitsethi
mohitsethi / extract_emails_from_text.py
Created June 29, 2017 07:40 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
@mohitsethi
mohitsethi / Dockerfile
Created June 8, 2017 09:56 — forked from dmouse/Dockerfile
Run Firefox or Google Chrome into a Docker container | based on http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
FROM ubuntu:14.04
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer

TensorFlow Serving in 10 minutes!

TensorFlow SERVING is Googles' recommended way to deploy TensorFlow models. Without proper computer engineering background, it can be quite intimidating, even for people who feel comfortable with TensorFlow itself. Few things that I've found particularly hard were:

  • Tutorial examples have C++ code (which I don't know)
  • Tutorials have Kubernetes, gRPG, Bezel (some of which I saw for the first time)
  • It needs to be compiled. That process takes forever!

After all, it worked just fine. Here I present an easiest possible way to deploy your models with TensorFlow Serving. You will have your self-built model running inside TF-Serving by the end of this tutorial. It will be scalable, and you will be able to query it via REST.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os.path
import re
import sys
import tarfile
import numpy as np
@mohitsethi
mohitsethi / phantomjs-linkedin.js
Created April 1, 2017 09:10 — forked from pasiaj/phantomjs-linkedin.js
A phantomjs script to: a) Login to Linkedin.com b) Scrape all your contacts c) Visit all the contacts d) Automatically endorse all contacts' skills.
var auth = {
user: "USERNAME",
pass: "PASSWORD"
};
function ParallelRunner (list, func, runners) {
function createSlots(runners) {
var slots = [];
for (var i = 0; i < runners; i++) {
slots.push( objReturner() );
@mohitsethi
mohitsethi / xvfb
Created January 7, 2017 09:22 — forked from jterrace/xvfb
xvfb init script for Ubuntu
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)