Skip to content

Instantly share code, notes, and snippets.

@se4u
se4u / touchpynb
Last active May 10, 2018 20:23
Create empty ipython notebook from the command line.
#!/usr/bin/env bash
cat <<EOF
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
EOF
@se4u
se4u / plot.py
Last active May 10, 2018 20:23
Wolframalpha replacement for automatic interactive plots from the terminal
#!/usr/bin/env python
import sys
from pdb import set_trace
import sympy as ss
from mpmath import *
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
import argparse
from sympy.abc import x,y
@se4u
se4u / .tmux.conf
Created March 13, 2018 01:48
My tmux conf file
# remap prefix from 'C-b' to 'C-o'
unbind C-b
set-option -g prefix C-o
bind-key C-o send-prefix
bind-key A rename-session
unbind ,
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
@se4u
se4u / lmc
Created March 10, 2018 03:52
Provide Notifications through the OSX notificationscenter when latexmk has an error
#!/usr/bin/env python3
import subprocess, os
import sys
ERR1 = 'Latexmk: Errors, so I did not complete making targets'
ERR2 = 'pdflatex: Command for \'pdflatex\' gave return code 256'
def main():
proc = subprocess.Popen(['latexmk', '-pvc'] + sys.argv[1:],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
-- Usecase for a script runner.
-- Author: Pushpendre Rastogi
-- Date: 8 July 2017
-- Multiple small changes in code are a norm when developing machine learning software
-- in dynamic languages, such as lua, python, because of a large number of hyper-parameters
-- in machine learning code, and large number of typos because of lack of compile time
-- type checking. For example, lua does not even enforce the number of arguments to a
-- function to be the same as its signature. Because of this ML code typically needs to be
-- run multiple times during development with small changes/fixes.
-- ML code also commonly has costly processing that must be done on a dataset.
@se4u
se4u / randn_dtype.patch
Last active January 1, 2017 18:25
Add support for float data type to numpy.random.randn call
diff --git a/mtrand/mtrand.pyx b/mtrand/mtrand.pyx
index 65c1954..79d0d70 100755
--- a/mtrand/mtrand.pyx
+++ b/mtrand/mtrand.pyx
@@ -71,6 +71,7 @@ cdef extern from "randomkit.h":
rk_error rk_altfill(void *buffer, size_t size, int strong,
rk_state *state) nogil
double rk_gauss(rk_state *state) nogil
+ float rk_gauss_32bit(rk_state *state) nogil
void rk_random_uint64(npy_uint64 off, npy_uint64 rng, npy_intp cnt,
@se4u
se4u / comcast_negotation
Created September 27, 2016 13:11
Comcast Customer Service Chat Log
COMCAST: Thank you for patiently waiting. I can certainly understand your
concern regarding the price increase in monthly statement. The promotional price
of service has ended and now you are paying regular charges for the current
services. I have checked that you are currently paying $49.99 + taxes.
_Customer_: Yes, that is correct
COMCAST: I have a wonderful deal for you where you will be getting 20 + cable
channels . Along with this , you will be getting 25 MBPS of internet speed along
with one cable box (at no monthly rental ). By bundling the deal you will get
@se4u
se4u / rank_metrics.py
Created February 22, 2016 05:31 — forked from bwhite/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
@se4u
se4u / adaptive_inference.py
Last active September 17, 2015 07:21
A skeletal implementation of Adaptive value of information which attempts to intelligently use features during inference.
# -*- coding: utf-8 -*-
'''
| Filename : adaptive_inference.py
| Description : Implementation of core concepts from "Learning Adaptive Value of Information for Structured Prediction"
| Author : Pushpendre Rastogi
| Created : Wed Sep 16 12:29:09 2015 (-0400)
| Last-Updated: Thu Sep 17 03:13:58 2015 (-0400)
| By: Pushpendre Rastogi
| Update #: 73
'''
@se4u
se4u / shift-reduce-ppda.py
Last active September 9, 2015 03:09
A shift reduce probabilistic PDA
'''
| Filename : shift-reduce-ppda.py
| Description : A shift Reduce PPDA generator
| Author : Pushpendre Rastogi
| Created : Tue Sep 8 20:42:22 2015 (-0400)
| Last-Updated: Tue Sep 8 23:09:28 2015 (-0400)
| By: Pushpendre Rastogi
| Update #: 33
The paper "Relating Probabilistic Grammar and Automata" compare PCFGs and PPDAs.
They also explain how a PPDA produces a sentence. This class implements a PPDA