Skip to content

Instantly share code, notes, and snippets.

View ChengLuFred's full-sized avatar

Cheng ChengLuFred

  • Stevens Institute of Technology
  • Hoboken
View GitHub Profile
@ChengLuFred
ChengLuFred / windows_configure.md
Last active September 14, 2021 09:24
[Windows] #Windows

Screen shot autosave

windows + PrintScreen

This command autosaves the current screen shot into C:\Users\cheng\Pictures\Screenshots

@ChengLuFred
ChengLuFred / Moment.md
Last active July 11, 2020 21:51
[Math Note] #Math

Moment for Gaussian distributed variable $X \sim \mathcal{N}\left(0, \sigma^{2}\right)$ $$E\left[X^{2 n}\right]=(2 n-1) ! ! \sigma^{2 n}$$

@ChengLuFred
ChengLuFred / quantmod.md
Last active April 3, 2020 21:18
[Quantmod] #R

Download Data

Download stock prices from yahoo finance

getSymbols.yahoo(Symbols = "MSFT",
                 env = globalenv(),
                 index.class  = 'Date',
                 from = "1980-01-01",
                 to = "2019-12-31",
                 periodicity = "daily")
@ChengLuFred
ChengLuFred / path.md
Last active June 25, 2020 19:59
[Path Management] #Python

check path validation

if not os.path.exists(OUTPUT_FILE_PATH):
            os.makedirs(OUTPUT_FILE_PATH)
            if verbose:
                print('Path: {0} created'.format(OUTPUT_FILE_PATH))
  • path containing number need double slash \\ before number
@ChengLuFred
ChengLuFred / read_data_r.md
Created April 15, 2020 01:38
[Read Data in R] read .csv etc. tables into R #R

row.names argument also can be number denoting which column to be used as index

data <- read.csv('homework05.csv', header = TRUE, row.names = c('DATE'))
@ChengLuFred
ChengLuFred / file_manage_python.md
Last active December 1, 2020 19:54
[File Management in Python]file combine, zip extract, etc. #Python

1. Quick way to read file using pandas

file_name = 'file_name.csv'
tickers_info = pd.read_csv(file_name,
                           sep = ",",			 # ',' for csv file and '\t' for text file
						   header = 0,			 # row number used as head
                           usecols=[1, 2], 		 # column index to be included
                           index_col = [0], 	 # column index which apdated above
 engine='c') # c engine is faster than python
@ChengLuFred
ChengLuFred / cheat sheet.md
Last active June 21, 2020 02:30
[Math Syntax in Latex] #Latex
<object data="http://yoursite.com/the.pdf" type="application/pdf" width="700px" height="700px">
    <embed src="http://yoursite.com/the.pdf">
        <p>This browser does not support PDFs. Please download the PDF to view it: <a href="http://yoursite.com/the.pdf">Download PDF</a>.</p>
    </embed>
@ChengLuFred
ChengLuFred / **kwarg.md
Last active June 21, 2020 03:22
[Pass variable number of parameters] #Python

*args pass a list of values or variables

**kwarg(key words arguments) pass a dictionary

def test_args_kwargs(arg1, arg2, arg3):
    print("arg1:", arg1)
    print("arg2:", arg2)
    print("arg3:", arg3)

# test *args
@ChengLuFred
ChengLuFred / cheat sheet.md
Last active January 14, 2024 05:42
[Markdown Cheat Sheet] #Markdown
  1. Markdown markdown

  2. R markdown rmarkdown

@ChengLuFred
ChengLuFred / cheat_sheet.md
Last active June 23, 2020 17:30
[Cheat Sheet for WSL] often used option #cmd
  • switch between WSL(Ubuntu) and CMD(Windows)
$ cmd.exe # to change to windows cmd
$ wsl.exe # to change to wsl ubuntu terminal