Skip to content

Instantly share code, notes, and snippets.

View apoorvalal's full-sized avatar

Apoorva Lal apoorvalal

View GitHub Profile
@apoorvalal
apoorvalal / cleaner.py
Last active June 4, 2017 02:45
Clears files with extension in exts matching pattern fn in directory (and subdirectories if subdir is set to true) in root
import os, glob
def clean_folder(exts,
root,
subdir=True,
fn='*.'):
"""
Clears files with extension in exts matching pattern fn in directory
(and subdirectories if subdir is set to true) in root
"""
if subdir == True:
import os, itertools
from subprocess import run
from multiprocessing.dummy import Pool
from functools import partial
def set_globs(stexec,scname):
global script_name, stata_exec
stata_exec = stexec
script_name = scname
import os, itertools
from subprocess import run
from multiprocessing.dummy import Pool
from functools import partial
def create_command_list(cli_program= " ", invocation=" ", script_name = " ", *args):
"""
Constructs a list of arguments to be passed to cli_program and/or script name with the invocation specified. to be passed to run_in_parallel below
example use:
@apoorvalal
apoorvalal / install-julia.sh
Last active June 16, 2018 16:46 — forked from adriantorrie/install-julia.sh
Ubuntu 14.04 - Install The Julia Language (julia-lang)
sudo add-apt-repository ppa:staticfloat/juliareleases
sudo apt-get update
sudo apt-cache show julia
sudo apt-get install julia julia-doc -y
julia -E 'Pkg.update()'
julia
@apoorvalal
apoorvalal / remaps.ahk
Created May 26, 2017 19:19
autohotkey_remap
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Capslock::Ctrl
RAlt::Esc
@apoorvalal
apoorvalal / initiateR.R
Last active June 12, 2018 17:12
R-setup-on-linux
rm(list=ls())
wants <- c('tidyverse','AER','devtools','lfe','glmnet',
'data.table','ff','foreach','parallel','stargazer')
has <- wants %in% rownames(installed.packages())
if(any(!has)) install.packages(wants[!has],dependencies=TRUE,
repos='http://cran.us.r-project.org')
sessionInfo()
@apoorvalal
apoorvalal / conda_installer.sh
Created June 3, 2017 18:41
download and install conda
CONTREPO=https://repo.continuum.io/archive/
# Stepwise filtering of the html at $CONTREPO
# Get the topmost line that matches our requirements, extract the file name.
ANACONDAURL=$(wget -q -O - $CONTREPO index.html | grep "Anaconda3-" | grep "Linux" | grep "86_64" | head -n 1 | cut -d \" -f 2)
wget -O ~/Downloads/anaconda.sh $CONTREPO$ANACONDAURL
bash ~/Downloads/anaconda.sh
@apoorvalal
apoorvalal / ahk_greek_math.ahk
Created June 11, 2017 18:14
ahk mappings for greek letters
; ############################ AHK Greek Letters.ahk >
; Uses (CTRL & ALT & SHIFT & alphabetic keyboard keys) to send lowercase Greek letters to your text editor
+^!a::Send {U+03B1} ; α - alpha
+^!b::Send {U+03B2} ; β - beta
+^!g::Send {U+03B3} ; γ - gamma
+^!c::Send {U+03B3} ; γ - gamma
+^!d::Send {U+03B4} ; δ - delta
+^!e::Send {U+03B5} ; ε - epislon
@apoorvalal
apoorvalal / count_total_project_code_lines_in_sublime
Last active June 20, 2017 18:29 — forked from Hexodus/count_total_project_code_lines_in_sublime
Count total code lines in project using Sublime texteditor
// find->find in files
// Switch on reg_ex button
// Find:
^(.*)$
// Where:
c:\your_folder\,*.py,*.r,*.sh,*.do,*.md, -*/folder_to_exclude/*
// Then click on the find button
// On the bottom line of your search result you'll find something like:
// 21342 matches in 124 files = your lines of code
@apoorvalal
apoorvalal / dl_youtube_mp3.ps1
Created June 26, 2017 14:18
youtube playlist to mp3
youtube-dl --download-archive downloaded.txt --no-post-overwrites -ciwx --audio-format mp3 -o "%(title)s.%(ext)s" youtube_playlist_here