Skip to content

Instantly share code, notes, and snippets.

View tlylt's full-sized avatar
🐱
On vacation

Liu Yongliang tlylt

🐱
On vacation
View GitHub Profile
@tlylt
tlylt / memo
Last active May 16, 2020 08:37
tips on memo
#first
#- write recursive solution
coins = [50, 20, 10, 5, 1]
count =0
count2 = 0
def cc(a,d):
global count
count+=1
if a <0 or d == 0:
return 0
Use % 100 to get the last two digits of a number
--- 430 % 100 => 30
Use // 100 to get the first digit of a number
--- 430 //100 => 4
Use % 10 to get the last digit of a number
--- 430 % 10 => 0
Conclusion
- Use //10 to get from the left
//10, remove 1 digit from right
//100, remove 2 digits from right
# Number of Combinations = 2**(length of input set)
# Makes use of binary
def PowerSet(input):
ans = []
numOfComb = 2 ** len(input)
for combidx in range(numOfComb): # 0 -> numOfComb
temp = []
for setidx in range(len(input)): # 0 -> len(input)
if combidx & 1 << setidx: # bitwise operation e.g. 0 & 1 << 0 =>0
temp.append(input[setidx])
@tlylt
tlylt / Fixing 413 Request Entity Too Large (Nginx)
Last active May 19, 2020 13:09
Fixing 413 Request Entity Too Large (Nginx)
# You probably need to set a size that is way larger than expected file size,
# if not you still may receive this 413 Request entity too large error
server {
client_max_body_size 100M;
...
}
def read_csv(filename): # provided
with open(filename, 'r') as f:
lines = csv.reader(f, delimiter=',')
return tuple(lines)
def make_datetime(string): # provided
string = string.split(' ')
date_str = string[0].split('/')
time_str = string[1].split(':')
date_int = [int(x) for x in date_str]
time_int = [int(x) for x in time_str]
return datetime.datetime(date_int[2], date_int[1], date_int[0], time_int[0], time_int[1])
# create virtual environment in this folder called env
python -m venv env
# activate it
env\Scripts\activate.bat
https://serverfault.com/questions/110154/whats-the-default-superuser-username-password-for-postgres-after-a-new-install
In Windows, do the following (IMPORTANT: Use a Windows administrator account):
After installation, open <PostgreSQL PATH>\data\pg_hba.conf.
Modify these two lines, and change "md5" to "trust":
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
# remove local branch
git branch -d branchname
https://www.makeareadme.com/
# Foobar
Foobar is a Python library for dealing with word pluralization.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.
```bash