Skip to content

Instantly share code, notes, and snippets.

View hanglearning's full-sized avatar
🌐
⛓ Blockchain + IoT + AI🤖

Hang Chen hanglearning

🌐
⛓ Blockchain + IoT + AI🤖
View GitHub Profile
@hanglearning
hanglearning / stack_vertical_images.py
Last active December 12, 2021 02:56
Vertically stack two images
# ref https://stackoverflow.com/questions/53876007/how-to-vertically-merge-two-images/53882483
# usage
# $ python vertical_stack.py </path/to/top/figure> </path/to/bottom/figure> </directory/to/output/figure> <output_file_name_with_extension>
# <output_file_name_with_extension> is optional, default to vertical_stack.png
# example
# $ python stack_vertical_images.py /Users/foo/bar/top_figure.png /Users/foo/bar/button_figure.png /Users/output vertical_stack.png
# NOTE
@hanglearning
hanglearning / crop_white_space_around_figure.py
Last active December 12, 2021 02:42
Crop white space around figure
# references
# https://www.programmersought.com/article/8966116355/
# https://stackoverflow.com/questions/59758904/check-if-image-is-all-white-pixels-with-opencv
# figures in this paper were all cropped using this code snippet - https://arxiv.org/pdf/2101.03300.pdf
# usage - save this code snippet as a python file and use two arguments
# $ python this_program.py </path/to/original/figure> </path/to/output/directory>
# example
@hanglearning
hanglearning / edfinity_eval_expression.py
Last active July 28, 2020 11:13
2020 Summer 106 TA Writing test cases on Edfinity to evaluate Python expression
# assume expression is one line of code
# must have "# write your expression below" as a starting code
# thanks to Prof. Wassil and Dr. Bart's suggestion https://gist.github.com/acbart/32ecc194870eb98a452448b35c11378e
# Write an expression which will be True if and only if a previously-defined variable result is not equal to 100. Please wrap your expression in the provided print() function.
from sources import get_student_source, set_student_source
student_code = get_student_source()
class TestCase(EdfinityTestCase):
@hanglearning
hanglearning / sortings.py
Last active January 31, 2020 21:55
Some sorting algorithm coding practices in Python.
# bubble sort
def bubble_sort(arr):
arr_len = len(arr)
for i in range(arr_len - 1, 0, -1):
for j in range(i):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
a = [2,5,1,8,-2,0,9,2]
bubble_sort(a) # inplace sorting
@hanglearning
hanglearning / dabblet.css
Created January 4, 2016 15:57 — forked from AndyNovo/dabblet.css
An empty Dabblet
/**
* An empty Dabblet
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;