Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jainxy's full-sized avatar

Vishal Jain jainxy

  • Bengaluru, India
View GitHub Profile
@jainxy
jainxy / understanding-word-vectors.ipynb
Created June 7, 2020 17:44 — forked from aparrish/understanding-word-vectors.ipynb
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jainxy
jainxy / apache-1.txt
Created May 6, 2020 14:41
Web Hosting related gists
$ sudo mkdir -p /var/www/test.com/public_html
$ sudo mkdir -p /var/www/example.com/public_html
$ sudo chown -R $USER:$USER /var/www/example.com/public_html
$ sudo chown -R $USER:$USER /var/www/test.com/public_html
$ sudo chmod -R 755 /var/www
Create the virtual hosts configuration files for our two sites
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/test.com.conf
@jainxy
jainxy / graph_snipps.txt
Created April 16, 2020 09:40
Tensorflow snippets
## Save tf model under graph-model
saver = tf.train.Saver() # general saver object
#saves a model every 2 hours and maximum 4 latest models are saved.
saver = tf.train.Saver(max_to_keep=4, keep_checkpoint_every_n_hours=2)
saver = tf.train.Saver([w1,w2]) # save a list of variables
saver.save(sess, 'my-test-model') / saver.save(sess, 'my_test_model',global_step=1000)
saver.save(sess, 'my-model', global_step=step,write_meta_graph=False) # dont save the model graph
@jainxy
jainxy / code_snips_py.txt
Created March 19, 2020 08:59
Code snippets - Python
=======================
FLASK module ->
from flask import Flask, g, request, redirect, url_for
=======================
@jainxy
jainxy / crontab_tricks.txt
Last active March 1, 2020 18:23
Crontab tricks
=== Use conda environment to run a python script ===
SHELL=/bin/bash
CONDA_PREFIX=/home/code/packages/miniconda3
CONDA_INIT="/home/code/packages/miniconda3/etc/conda/activate.d/proj4-activate.sh"
PYTHON=/home/code/packages/miniconda3/bin/python
12 13 * * * . $CONDA_INIT ; $PYTHON <python file>
=== Use date utility for naming a log file ===
DATEVAR="date +%Y%m%d_%H%M"
17 * * * * echo "logs_$($DATEVAR).txt"
@jainxy
jainxy / bash_shell_scripting.md
Last active February 21, 2020 10:06
Bash shell scripting

References

Notes

Introduction

  • Bash (AKA Bourne Again Shell) is a type of interpreter that processes shell commands.
  • A shell interpreter takes commands in plain text format and calls Operating System services to do something.
  • Bash is the improved version of Sh (Bourne Shell).
  • A shell scripting is writing a program for the shell to execute and a shell script is a file or program that shell will execute.
  • Terminal is the interface to the shell interpreter.
  • A shell script is a fully-fledged programming language in itself. It can define variables, functions and we can do conditional execution of shell commands as well.
@jainxy
jainxy / min-char-rnn.py
Created February 14, 2020 11:35 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jainxy
jainxy / scikit_nb.txt
Created April 11, 2019 07:35
Naive Bayes - sklearn
# load the iris dataset
from sklearn.datasets import load_iris
iris = load_iris()
# store the feature matrix (X) and response vector (y)
X = iris.data
y = iris.target
# splitting X and y into training and testing sets
@jainxy
jainxy / io_colab.txt
Created April 10, 2019 10:33
Colab - IO
# Ref -> https://colab.research.google.com/notebooks/io.ipynb#scrollTo=BaCkyg5CV5jF
# ---------- UPLOAD FROM LOCAL FILE SYSTEM --------------------
# files.upload returns a dictionary of the files which were uploaded. The dictionary is keyed by the file name, the value is the data which was uploaded.
# files.download will invoke a browser download of the file to the user's local computer.