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
#### | |
# INPUT | |
#### | |
# interest rate | |
IR = 0.029 | |
# Durable life | |
# Wood: 22, light steel: 27, heave steel: 34, RC: 47 | |
DL = 27 |
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
# -*- coding: utf-8 -*- | |
def cashflow(yield_rate, interest, load_rate, yield_correct=0.01,loan_years=25): | |
f = lambda r: 12 * (r * ((1 + r)** 300)) / ((1+r)**300 - 1) | |
i_rate = f(interest / 12.) | |
return 1.0 * (yield_rate - yield_correct) - load_rate * i_rate | |
def ccr(yield_rate, interest, load_rate, yield_correct=0.01,loan_years=25): | |
cf = cashflow(yield_rate, interest, load_rate, yield_correct=0.01,loan_years=25) | |
return cf / (1.0 - load_rate) |
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
class Point: | |
def __init__(self, a=0, b=0): | |
self.x = a | |
self.y = b | |
def point_equals(p1, p2): | |
return abs(p1[0] - p2[0]) < 0.0000001 and abs(p1[1] - p2[1]) < 0.0000001 |
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
class Solution: | |
def build_trie(self, words): | |
root = {} | |
count = 0 | |
for word in words: | |
parent = root | |
for ch in word: | |
count += 1 | |
if ch in parent: | |
parent = parent[ch] |
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
UMOUNT_RETRIES=3 | |
while [ $UMOUNT_RETRIES -gt 0 ] | |
do | |
umount ${DIR_NAME}; RC=$? | |
if [ ${RC} -ne 0 ] | |
then | |
UMOUNT_RETRIES=$((UMOUNT_RETRIES-1)) | |
continue | |
fi | |
break |
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
#!/bin/bash | |
## | |
# format | |
# <TAG>,<SRC_PATH>,<DST_PATH>,<FLAGS> | |
# | |
## | |
## const defination | |
PARAM_FILE="/Users/zhao/Workspace/playground/param" |
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
### Send file | |
## On the receiving end running, | |
nc -l -p 1234 > out.file | |
## On the sending end running, | |
nc -w 3 [destination] 1234 < out.file | |
### Proxying | |
nc -l 12345 | nc www.google.com 80 |
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 copy | |
COUNT = 0 | |
M = 4 | |
N = 4 | |
def print_current_jumps(mx): | |
for line in mx: | |
print(line) | |
print('=============') |
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 time | |
import zipfile | |
from itertools import product | |
PASSWORD_MAX_LENGTH = 8 | |
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)] | |
def open_dict_file(filename): |
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
A_ORD = ord('a') | |
E_ORD = ord('e') | |
Z_ORD = ord('z') | |
def count_char(text): | |
res = {} | |
for c in text.lower(): | |
if ord(c) not in range(A_ORD, Z_ORD+1): | |
continue | |
if c in res: |
NewerOlder