This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from datetime import datetime | |
TODAY = f'{datetime.today()}'.replace(':', '.') | |
# logger set up | |
logger = logging.getLogger(__name__) | |
logger.setLevel('DEBUG') | |
formatter = logging.Formatter( | |
'{asctime} - {levelname} - {message}', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified what's in: https://github.com/davidbmitchell/Baseball-PostgreSQL | |
# install the necessary tool | |
brew install chadwick | |
# create folders | |
mkdir -p /path/to/retrosheet/{unparsed,parsed} | |
cd /path/to/retrosheet/unparsed | |
# you can set startDecade to whichever decade you like |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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. | |
; Switch alt and ctrl | |
LAlt::LCtrl | |
LCtrl::LAlt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run SQL server 2022 image | |
# user name == sa | |
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Yuki1031" -p 1433:1433 --name mssql --hostname mssql -d mcr.microsoft.com/mssql/server:2022-latest | |
# Copy data into a docker file for restoring backup | |
docker cp /YOURPATHTOFILE/Contoso.10k.bak mssql:/var/opt/mssql/data | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def requests_retry_sesssion( | |
retries=5, | |
backoff_factor=1, | |
status_forcelist=(500, 502, 503, 504), | |
raise_on_redirect=True, | |
raise_on_status=True | |
): | |
''' | |
Retry logic with requests package | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source website | |
// https://stackoverflow.com/questions/64007239/hi-how-do-we-define-select-statement-as-a-variable-in-dbt | |
{%- call statement('my_statement', fetch_result=True) -%} | |
SELECT my_field FROM my_table | |
{%- endcall -%} | |
{%- set my_var = load_result('my_statement')['data'][0][0] -%} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws configure list-profiles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import readline | |
import os # don't necessarily need | |
filePath = os.path.expanduser('~/Downloads/my_history.py') # don't necessarily need | |
readline.write_history_file(filePath) # don't necessarily need | |
# or you can simply do | |
readline.write_history_file('your_file.py') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype plugin indent on | |
" show existing tab with 4 spaces width | |
set tabstop=4 | |
" when indenting with '>', use 4 spaces width | |
set shiftwidth=4 | |
" On pressing tab, insert 4 spaces | |
set expandtab | |
" Add line numbers | |
set number | |
" syntax enabled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pandasql import sqldf | |
from pandasql import load_meat, load_births # import data | |
mysql = lambda q: sqldf(q, globals()) | |
meat = load_meat() | |
birth = load_births() | |
# start sql queries in pandas | |
mysql('select * from meat limit 5') |
NewerOlder