Skip to content

Instantly share code, notes, and snippets.

@viksit
viksit / bootstrap.html
Created November 4, 2018 17:50 — forked from kolorobot/bootstrap.html
Complete Bootstrap Starter Template with pre-defined CDN paths
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content=""/>
<meta name="author" content=""/>
@viksit
viksit / startx.sh
Created April 20, 2018 21:15
Start screen session with custom script
viksit@gpu3-4-k80:~$ cat startx.sh
screen -AdmS viksit -t tab0 bash
screen -S viksit -X screen -t jup0 bash /home/viksit/j.sh
screen -S viksit -X screen -t tsb0 bash /home/viksit/t.sh
@viksit
viksit / integrate.html
Last active November 17, 2017 22:05
Myra Labs Widget Integration Snippet
<script>
(function() {
var w = window;
var mcs = w.MyraConciergeSettings;
var d = document;
function l() {
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//cdn-prod.myralabs.com/widget/v3/widget.CUSTOMER_ID.js';
@viksit
viksit / kullback_leibler.py
Created August 31, 2017 18:38 — forked from ognis1205/kullback_leibler.py
Calculate Kullback-Leibler Divergence of Given Corpus
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Caluculates symmetric Kullback-Leibler divergence.
@author Shingo OKAWA
"""
import numpy
import sys
import scipy.stats as stats
import matplotlib.pyplot as plotter
from gensim import corpora, models, similarities, matutils
@viksit
viksit / rank_metrics.py
Created August 20, 2017 23:57 — forked from shashankg7/rank_metrics.py
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
import tensorflow as tf
import numpy as np
class ConvolutionalAttentionNLI(object):
def __init__(self, embeddings_shape, target_classes=2, conv_filter_size=3, conv_projection_size=300, attention_output_size=200, comparison_output_size=100, learning_rate=0.05):
self._embeddings_shape = embeddings_shape
self._target_classes = target_classes
self._conv_filter_size = conv_filter_size
self._conv_projection_size = conv_projection_size
@viksit
viksit / AttentionWithContext.py
Created June 9, 2017 07:41 — forked from rmdort/AttentionWithContext.py
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
class AttentionWithContext(Layer):
"""
Attention operation, with a context/query vector, for temporal data.
Supports Masking.
Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf]
"Hierarchical Attention Networks for Document Classification"
by using a context vector to assist the attention
# Input shape
3D tensor with shape: `(samples, steps, features)`.
# Output shape
@viksit
viksit / transferring-props.md
Created March 15, 2017 21:53 — forked from sebmarkbage/transferring-props.md
Deprecating transferPropsTo

Deprecating transferPropsTo

It's a common pattern in React to wrap a component in an abstraction. The outer component exposes a simple property to do something that might have more complex implementation details.

We used to have a helper function called transferPropsTo. We no longer support this method. Instead you're expected to use a generic object helper to merge props.

render() {
 return Component(Object.assign({}, this.props, { more: 'values' }));
@viksit
viksit / json_required_demo.py
Created September 14, 2016 01:21 — forked from corbinbs/json_required_demo.py
Flask JSON required decorator
"""
Demo of json_required decorator for API input validation/error handling
"""
import inspect
import functools
import json
from traceback import format_exception
from flask import jsonify, request
import sys
@viksit
viksit / gist:b576fca3690327d519082167ef9f1f12
Created June 25, 2016 22:17 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote