Skip to content

Instantly share code, notes, and snippets.

View fortable1999's full-sized avatar

Meng Zhao fortable1999

View GitHub Profile
@fortable1999
fortable1999 / ROI.py
Last active April 2, 2019 03:00
ROI simulator
####
# INPUT
####
# interest rate
IR = 0.029
# Durable life
# Wood: 22, light steel: 27, heave steel: 34, RC: 47
DL = 27
@fortable1999
fortable1999 / calculate.py
Created January 24, 2019 09:29
キャッシュフロー・金利計算
# -*- 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)
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
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]
@fortable1999
fortable1999 / demo.sh
Created October 22, 2018 11:32
democode
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
@fortable1999
fortable1999 / copyfile.sh
Created October 13, 2018 10:52
copyfile.sh
#!/bin/bash
##
# format
# <TAG>,<SRC_PATH>,<DST_PATH>,<FLAGS>
#
##
## const defination
PARAM_FILE="/Users/zhao/Workspace/playground/param"
### 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
@fortable1999
fortable1999 / cells_go.py
Created March 20, 2018 01:30
algorithm program
import copy
COUNT = 0
M = 4
N = 4
def print_current_jumps(mx):
for line in mx:
print(line)
print('=============')
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):
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: