Skip to content

Instantly share code, notes, and snippets.

View vikjam's full-sized avatar
💭
👨🏾‍💻

vikjam

💭
👨🏾‍💻
View GitHub Profile
@vikjam
vikjam / quick_replace.py
Last active October 10, 2015 22:18
Quick replacement of colored pins by school attributes
#!/usr/local/bin/env python
"""
Assign colors to each school's pin
"""
from BeautifulSoup import BeautifulSoup
# Hash to store style values
styles = {}
@vikjam
vikjam / gSee.r
Last active August 29, 2015 14:22
Data viewer in R via gvisTable
library(googleVis)
gSee <- function(df) {
return(plot(gvisTable(df, options = list(showRowNumber = TRUE,
page = 'enable',
pageSize = 30))))
}
@vikjam
vikjam / memory-leaders.sh
Created June 29, 2015 14:19
Check top memory usage
ps -eo pmem,pcpu, vsize, user, pid, cmd | sort -k 1 -nr | head -15
import xlrd
import os
import gzip
workbook = xlrd.open_workbook("example.xlsx")
worksheet = workbook.sheet_by_index(0)
for row_num in range(0, worksheet.nrows):
row_values = [v.value for v in worksheet.row(row_num) if v.value]
@vikjam
vikjam / matplotlibrc
Created December 17, 2015 15:26
Matplotlib back end preferences
# Save file as matplotlibrc in folder ~/.matplotlib
backend: TkAgg
# Enable fonts
# See: http://matplotlib.org/1.3.1/users/usetex.html
font.family : serif
font.serif : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif : Helvetica, Avant Garde, Computer Modern Sans serif
font.cursive : Zapf Chancery
@vikjam
vikjam / histline.do
Last active March 3, 2016 16:29
Plotting histogram with line graph
webuse nlswork, clear
gen count_ln_wage = !missing(ln_wage)
collapse (sum) count_ln_wage (mean) ln_wage, by(grade year)
label var count_ln_wage "Number of individuals"
label var ln_wage "Average log(wage)"
levelsof year, local(years)
foreach yr of local years {
@vikjam
vikjam / fixed_bins.do
Last active March 3, 2016 21:45
Fixed bins for binscatter
webuse nlswork, clear
gen grade_bin = floor(grade/2) * 2 + 1
levelsof year, local(years)
foreach yr of local years {
binscatter ln_wage grade if year == `yr', linetype(connect) xq(grade_bin) msymbol(none) title("`yr'")
}
@vikjam
vikjam / probit.r
Last active June 30, 2017 11:47
Visualizing probit regressions in R
library(readxl)
library(ggplot2)
library(reshape2)
asq.data <- read_excel("ASQ.xlsx")
variables <- c("Interval" ,
"CommunicationResults" ,
"GrossMotorResults" ,
"FineMotorResults" ,
"ProblemSolvingResults",
@vikjam
vikjam / split_csv.sh
Created March 7, 2016 19:28
Split a CSV
cut -d , -f1-3 input.csv > output.csv
@vikjam
vikjam / rd_simulation.do
Last active March 24, 2016 01:35
Simulating an RD.
clear all
set obs 10000
capture program drop detect_rd
program define detect_rd, rclass
syntax varlist(numeric max=1) [if]
if "`if'" == "" {
local ifcond ""
}
else {