Skip to content

Instantly share code, notes, and snippets.

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

vikjam

💭
👨🏾‍💻
View GitHub Profile
@vikjam
vikjam / wav2mp3.sh
Last active May 4, 2016 18:39
.wav to .mp3 with album art.
# VBR (with loop)
for f in *.wav; do lame --ti "path/to/file/album_art.jpg" --vbr-new -V 3 "$f" "${f%.wav}.mp3"; done
# Non-VBR (no loop)
lame --ti "path/to/file/album_art.jpg" -h -b "wavfile.wav" "mp3file.mp3"
painting color_1 color_2 color_3 color_4 color_5
Adobe (Variant): Luminous Day by Josef Albers #D77186 #61A2DA #6CB7DA #b5b5b3 #D75725
Homage to the Square (La Tehuana) by Josef Albers #C00559 #DE1F6C #F3A20D #F07A13 #DE6716
Rainbow by Billy Apple #F24D98 #813B7C #59D044 #F3A002 #F2F44D
Spar by Per Arnoldi #C2151B #2021A0 #3547B3 #E2C43F #E0DCDD
Bicycle Rider By The Loire by Milton Avery #F3C937 #7B533E #BFA588 #604847 #552723
Cello Player by Milton Avery #E2CACD #2E7CA8 #F1C061 #DA7338 #741D13
The Swan by Hilma af Klint #D6CFC4 #466CA6 #D1AE45 #87240E #040204
Untitled (Black King Catch Scorpio) by Jean-Michel Basquiat #8CABD9 #F6A7B8 #F1EC7A #1D4D9F #F08838
DUSTHEADS by Jean-Michel Basquiat #C11432 #009ADA #66A64F #FDD10A #070707
@vikjam
vikjam / xtfill.r
Created April 30, 2016 00:37
Pads an imbalanced panel data set with missing values.
# via http://www.enoriver.net/2015/02/09/r-version-of-tsfill-and-xfill-combined/
xtill <- function(x) {
dt <- copy(x)
xtkeys <- c('zip.cd','cal.dt')
clkeys <- c('zip.cd','dma.cd')
xtfull <- CJ(unique(x[,zip.cd]),unique(x[,cal.dt]))
clfull <- unique(subset(x,select=c(zip.cd,dma.cd)))
setnames(xtfull,c('V1','V2'),xtkeys)
setkeyv(xtfull,xtkeys)
@vikjam
vikjam / get.clip.r
Last active April 16, 2016 19:59
Get data from clipboard in R
get.clip <- function(header = TRUE, stringsAsFactors = FALSE, ...) {
read.table(pipe("pbpaste"), sep = "\t", header = header, stringsAsFactors = stringsAsFactors, ...)
}
@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 {
@vikjam
vikjam / split_csv.sh
Created March 7, 2016 19:28
Split a CSV
cut -d , -f1-3 input.csv > output.csv
@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 / 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 / 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 / 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