Skip to content

Instantly share code, notes, and snippets.

View mgao6767's full-sized avatar
😀

Adrian Gao mgao6767

😀
View GitHub Profile
data tmp;
merge anncomp(in=ina) some_ceo_year_events(in=inb);
by gvkey year execid;
flag = inb;
if ina;
run;
@mgao6767
mgao6767 / ffind.ado
Created February 25, 2018 18:16
STATA program to create Fama-French 48 Industries from SIC
/****************************************
* ffind.ado
* Creates variable containing Fama-French
* industry classification.
*
* Author: Judson Caskey, UCLA
* December 9, 2007
*
* Revised by Malcolm Wardlaw, Uiversity of Texas at Dallas (November 1, 2011)
****************************************/
@mgao6767
mgao6767 / wp-config.php
Last active October 7, 2018 09:14
To resolve infinite login loop
<?php
/* To resolve the login loop issue */
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
/* end */
/* That's all, stop editing! Happy blogging. */
@mgao6767
mgao6767 / bitnami.conf
Last active October 12, 2018 01:04
bitnami.conf for alice.com
<VirtualHost *:80>
ServerName alice.com
DocumentRoot "/opt/bitnami/apache2/htdocs"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
@mgao6767
mgao6767 / Install required packages and download AlgoVPN.sh
Last active January 9, 2019 05:29
Install required packages and download AlgoVPN
sudo apt-get update && sudo apt-get install \
git \
build-essential \
libssl-dev \
libffi-dev \
python-dev \
python-pip \
python-setuptools \
python-virtualenv -y
@mgao6767
mgao6767 / Install remaining dependencies.sh
Last active January 9, 2019 05:30
AlgoVPN: Install remaining dependencies
python -m virtualenv --python=`which python2` env &&
source env/bin/activate &&
python -m pip install -U pip virtualenv &&
python -m pip install -r requirements.txt
@mgao6767
mgao6767 / winsorize.sas
Last active January 25, 2019 10:42 — forked from JoostImpink/winsorize.sas
winsorize macro
/*****************************************
Author unknown - that is a pity because this macro is the best since sliced bread!
Trim or winsorize macro
* byvar = none for no byvar;
* type = delete/winsor (delete will trim, winsor will winsorize;
*dsetin = dataset to winsorize/trim;
*dsetout = dataset to output with winsorized/trimmed values;
*byvar = subsetting variables to winsorize/trim on;
@mgao6767
mgao6767 / Bitcoin Address Generator in Obfuscated Python.py
Created February 24, 2019 04:43
Bitcoin Address Generator in Obfuscated Python
_ =r"""A(W/2,*M(3*G
*G*V(2*J%P),G,J,G)+((M((J-T
)*V((G-S)%P),S,T,G)if(S@(G,J))if(
W%2@(S,T)))if(W@(S,T);H=2**256;import&h
ashlib&as&h,os,re,bi nascii&as&k;J$:int(
k.b2a_hex(W),16);C$:C (W/ 58)+[W%58]if(W@
[];X=h.new("rip em d160");Y$:h.sha25
6(W).digest();I$ d=32:I(W/256,d-1)+
chr(W%256)if(d>0@""; U$:J(k.a2b_base
64(W));f=J(os.urando m(64)) %(H-U("AUVRIxl
@mgao6767
mgao6767 / winsorize.sas
Created January 26, 2019 23:56
WRDS Macros: WINSORIZE
/* ********************************************************************************* */
/* ******************** W R D S R E S E A R C H M A C R O S ******************** */
/* ********************************************************************************* */
/* WRDS Macro: WINSORIZE */
/* Summary : Winsorizes or Trims Outliers */
/* Date : April 14, 2009 */
/* Author : Rabih Moussawi, WRDS */
/* Variables : - INSET and OUTSET are input and output datasets */
/* - SORTVAR: sort variable used in ranking */
/* - VARS: variables to trim and winsorize */
@mgao6767
mgao6767 / Computing Jackknifed Coefficient Estimates in SAS.md
Last active June 10, 2020 04:23
Computing Jackknifed Coefficient Estimates in SAS

Background

In certain scenarios, we want to estimate a model's parameters on the sample for each observation with itself excluded. This can be achieved by estimating the model repeatedly on the leave-one-out samples but is very inefficient. If we estimate the model on the full sample, however, the coefficient estimates will certainly be biased. Thankfully, we have the Jackknife method to correct for the bias, which produces the (Jackknifed) coefficient estimates for each observation.

Variable Definition

Let's start with some variable definitions to help with the explanation.

Variable Definition