Skip to content

Instantly share code, notes, and snippets.

Benjamin Tan Wei Hao benjamintanweihao

Block or report user

Report or block benjamintanweihao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ABL.txt
; Ender 3 Custom Start G-code
M117 Getting the bed up to temp!
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
M117 Pre-heating the extruder!
M104 S160; start warming extruder to 160
G28 ; Home all axes
M117 Auto bed-level GO!
G29 ; Auto bed-level (BL-Touch)
G92 E0 ; Reset Extruder
import cv2
def equalize_histogram(path):
# Color
print('Processing (Color): {}'.format(path))
img = cv2.imread(path)
lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
lab_planes = cv2.split(lab)
benjamintanweihao /
Created Nov 1, 2018
This only works on DirectX 10!
# RenderDoc Python scripts, powered by IronPython
# The 'renderdoc' object is the Core class instance.
config = {}
config['py_lib_dir'] = 'C:\\Python27\\Lib\\'
config['save_dir'] = 'C:\\workspace\\playing-for-data\\data\\processed\\' # where we store extraction results
# creates a prefixes for files and directories from logfilename
config['dir_prefix'] = lambda logFilename: ''
config['file_prefix'] = lambda logFilename: basename(logFilename)[:-4] + '_'
benjamintanweihao /
Last active Oct 27, 2018
Getting instance and class segments from GTA V Gamehook
import numpy as np
import matplotlib.pyplot as plt
filename = 'C:\\Users\\Benjamin Tan\\Desktop\\00016351_object_id.raw'
vals = np.linspace(0,1,256)
cmap =
# Load the object_id.raw file and skip the first 4 bytes
import tensorflow as tf
import os
from tensorflow.python.keras import Input, Model
from tensorflow.python.keras.models import load_model
from darknet import darknet_base
from definitions import ROOT_DIR
from yolo_layer import YOLOLayer
benjamintanweihao / kaggle.yml
Created Jun 10, 2018
Conda environment for Kaggle
View kaggle.yml
name: kaggle
- defaults
- backcall=0.1.0=py36_0
- bleach=2.1.3=py36_0
- ca-certificates=2018.03.07=0
- certifi=2018.4.16=py36_0
- dbus=1.13.2=h714fa37_1
- decorator=4.3.0=py36_0
benjamintanweihao /
Last active May 20, 2018
Making an image transparent
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGBA)
image[np.all(image == [0, 0, 0, 255], axis=2)] = [0, 0, 0, 0]

Keybase proof

I hereby claim:

  • I am benjamintanweihao on github.
  • I am bentanweihao ( on keybase.
  • I have a public key ASAmpE_QvVG3NZzyRxlD0n5mQCg3vnApNkT3csQAKtXYQQo

To claim this, I am signing this object:

benjamintanweihao / environment.yml
Created Mar 4, 2018
conda env create -f environment.yml
View environment.yml
name: pyimagesearch
- conda-forge
- python==3.6
- numpy
- matplotlib
- jupyter
- opencv3
fn main() {
let s1 = "x=123, y = 345, rule = B21/S334";
let s2 = s1.replace(" ", "");
let s3 = s2.split(',').collect::<Vec<_>>();
let s4 = &s3[0..2];
let s5 = s4.iter()
.flat_map(|&x| x.split('=').collect::<Vec<_>>())
println!("x = {:?}", s5[1]);
println!("y = {:?}", s5[3]);
You can’t perform that action at this time.