Skip to content

Instantly share code, notes, and snippets.

View RishiSadhir's full-sized avatar

Rishi Sadhir RishiSadhir

  • Wayfair
  • Boston, MA
View GitHub Profile
View theme.py
# Plot theme
COLOR = "#2A0933"
plt.rcParams['text.color'] = COLOR
plt.rcParams['text.hinting_factor'] = 8
plt.rcParams['axes.labelcolor'] = COLOR
plt.rcParams['axes.facecolor'] = "eeeeee"
plt.rcParams['axes.edgecolor'] = "bcbcbc"
plt.rcParams['axes.grid'] = True
plt.rcParams['axes.titlesize'] = "x-large"
plt.rcParams['axes.labelsize'] = "large"
@RishiSadhir
RishiSadhir / ols.py
Last active March 15, 2020 15:32
OLS from scratch
View ols.py
import numpy as np
# Core functions
def ols(X, y):
ret = np.dot(np.dot(np.linalg.inv(np.dot(X.transpose(), X)), X.transpose()), y)
return ret.tolist()
def se(arr):
return np.std(arr) / arr.size
@RishiSadhir
RishiSadhir / myggtheme.r
Last active January 8, 2018 16:42
My own personal ggplot2 theme
View myggtheme.r
theme_Publication <- function(base_size=14, base_family="helvetica") {
library(grid)
library(ggthemes)
(theme_foundation(base_size=base_size, base_family=base_family)
+ theme(plot.title = element_text(face = "bold",
size = rel(1.2), hjust = 0.5),
text = element_text(),
panel.background = element_rect(colour = NA),
plot.background = element_rect(colour = NA),
panel.border = element_rect(colour = NA),
@RishiSadhir
RishiSadhir / insertify-csv.clj
Last active February 25, 2016 15:54
Turn a CSV in to SQL Insert Statements
View insertify-csv.clj
(ns
^{:doc "Convert a CSV in to Oracle insert statements.
This program takes as input
1. A CSV. Some care is taken to remove whitespace and quotes from
elements of the CSV.
2. A tablename. The tablename is used to both name
the table we are inserting the csv in to as well as
the name of the sql file that is generated.
Returns a tablename.sql file full of insert statements."
:author "Rishi Sadhir"}
@RishiSadhir
RishiSadhir / copy-line.el
Last active January 8, 2018 16:44
Quick emacs function to copy the current line.
View copy-line.el
(defun copy-line (arg)
"Copy lines (as many as prefix argument) in the kill ring"
(interactive "p")
(kill-ring-save (line-beginning-position)
(line-beginning-position (+ 1 arg)))
(message "%d line%s copied" arg (if (= 1 arg) "" "s")))
;; optional key binding
(global-set-key "\C-c\C-k" 'copy-line)
@RishiSadhir
RishiSadhir / Logger.clj
Last active January 8, 2018 16:45
Primitive Logging System in Clojure.
View Logger.clj
(defn print-logger
[writer]
#(binding [*out* writer]
(println %)))
(defn file-logger
[file]
#(with-open [f (clojure.java.io/writer file :append true)]
((print-logger f) %)))
;; Usage