Skip to content

Instantly share code, notes, and snippets.

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:
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
@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 / 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:
@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
# command_for_r
# $r_exec --no-save --no-restore --verbose
# N:/.../script.R
# inp_file = 'input.dta'
# inp_dir - 'D:/input/'
# working = 'D:/working/'
# dep_var = 'tot_grouped_cost'
# rhs_vars = c('age ')
# cmd: 2>&1
@apoorvalal
apoorvalal / normalize_spaces.py
Last active December 14, 2017 18:08
Normalize spaces before importing as dataframes
#%%
import os
import re
os.chdir('data_directory')
raw_files = [x for x in os.listdir()]
for raw in raw_files:
inputfile = raw
outputfile = raw.split('.')[0]+'_clean.txt'
library(lfe)
library(stargazer)
set.seed(6152011)
# Number of cities
L <- 1000
# Number of industries
K <- 3