Skip to content

Instantly share code, notes, and snippets.

@hsuRush
hsuRush / main.py
Last active August 19, 2021 04:56
WS bonus calculator (Python 3.x)
# Start at L:31 | 從31行開始
import numpy as np
import random
def p2f(x):
return float(x.strip('%'))/100
def text_to_num(text, bad_data_val = 0, ws_price=75000000):
#text = np.array([ list(word) for word in text ])
d = {
@hsuRush
hsuRush / revLinkedList.py
Created April 11, 2021 09:01
a reverse LinkedList implementation in Python
class Node:
def __init__(self, data):
self.data = data
self.nextNode = None
def makeLinkedList():
head = Node(10)
node = head
for i in range(9,0,-1):
import numpy as np
import glob
import xml.etree.ElementTree as ET
import numpy as np
# the final result is in './k_means_anchor'
path_to_dataset = "/data1000G/steven/ML_PLATE/data/train/labels_voc/"
CLUSTERS = 9
HEIGHT = 240
@hsuRush
hsuRush / label_to_yolo.py
Last active June 1, 2020 13:49
for darknet
import xml.etree.ElementTree as ET
import os
from os import listdir
from os.path import join
import random
path_to_dataset = '/data1000G/steven/lpDataSet/AOLP/all_train_sets/'
# images are at path_to_dataset + '/images/'
# the voc labels are at path_to_dataset + '/labels_voc/'
# the filename of images and labels should be exactly same.
@hsuRush
hsuRush / transform.py
Created December 2, 2019 13:11
rotate and shear without cropping
def rotate_and_shear_image(im, angle=30, x_shear=.7, y_shear=.7):
"""
Rotates an image (angle in degrees) and expands image to avoid cropping
change from https://stackoverflow.com/a/51109152
"""
#print(im.shape)
height, width = im.shape[:2] # image shape has 3 dimensions
image_center = (width/2, height/2) # getRotationMatrix2D needs coordinates in reverse order (width, height) compared to shape
rotation_im = cv2.getRotationMatrix2D(image_center, angle, 1.)
@hsuRush
hsuRush / System Design.md
Created August 4, 2019 02:00 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@hsuRush
hsuRush / .bash_prompt
Created October 24, 2018 10:19
bash settings with conda and git support
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active conda and the enviroment
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@hsuRush
hsuRush / .bash_prompt
Last active July 2, 2021 03:02
bash settings with virtualenv
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@hsuRush
hsuRush / config_26-Jun-2018
Last active June 26, 2018 06:39
a chrome addon "bookmark-sidebar' settings
{"behaviour":{"animations":true,"blacklist":[],"closeTimeout":"1","contextmenu":true,"dirAccordion":false,"dirOpenDuration":"0.5","dndOpen":true,"linkAction":"current","newTab":"foreground","newTabPosition":"afterCurrent","openAction":"mousedown","openChildrenWarnLimit":"10","openDelay":"0","preventPageScroll":false,"preventWindowed":false,"rememberState":"openStatesAndPos","reopenSidebar":false,"scrollBarHide":"1.5","sidebarPosition":"left","toggleArea":{"height":"50","top":"25","width":"9","widthWindowed":"9"},"tooltipContent":"all","tooltipDelay":"1","visibility":"always","whitelist":[]},"appearance":{"darkMode":true,"highContrast":false,"showBookmarkIcons":true,"showDirectoryIcons":true,"showIndicator":true,"showIndicatorIcon":true,"styles":{"bookmarksDirColor":"#c8c8c8","bookmarksDirIcon":"dir-1","bookmarksDirIndentation":"25px","bookmarksFontSize":"14px","bookmarksHorizontalPadding":"16px","bookmarksIconSize":"16px","bookmarksLineHeight":"38px","colorScheme":"#1f4d80","directoriesIconSize":"16px","fontF
@hsuRush
hsuRush / load_opencv_yaml.py
Last active June 21, 2018 11:52
Load opencv matrix in python ! reference from https://gist.github.com/autosquid/66acc22b3798b36aea0a
"""
reference from https://gist.github.com/autosquid/66acc22b3798b36aea0a
example yaml file:
%YAML:1.0
---
camera_matrix: !!opencv-matrix
rows: 3
cols: 3