Skip to content

Instantly share code, notes, and snippets.

@mondwan
mondwan / my_page_size.py
Last active June 24, 2018 06:09
page size resolution
from reportlab.lib.pagesizes import A5, landscape
# A5 = (210*mm,148*mm)
LANDSCAPE_A5 = landscape(A5)
PAGE_WIDTH = LANDSCAPE_A5[0]
PAGE_HEIGHT = LANDSCAPE_A5[1]
HORIZONTAL_MARGIN = PAGE_WIDTH / 32
VERTICAL_MARGIN = PAGE_HEIGHT / 16
@mondwan
mondwan / cp_scp_tar_symbolic_link.sh
Created July 23, 2017 13:41
cp and scp and tar and symbolic links
A = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B = [2, 4, 6, 8, 10]
setA = set(A)
setB = set(B)
# C = A ^ B
@mondwan
mondwan / React-basic-digest.md
Last active March 19, 2017 16:41
Knowledge digested from react-basic
@mondwan
mondwan / dfs.py
Created December 22, 2015 16:03
Demo how to use dfs in python
from treelib import Tree
tree = Tree()
# Create a tree for demo purpose
tree.create_node('A', 'a')
tree.create_node('B', 'b', parent='a')
tree.create_node('C', 'c', parent='a')
tree.create_node('D', 'd', parent='b')
tree.create_node('E', 'e', parent='b')
tree.create_node('F', 'f', parent='c')
@mondwan
mondwan / bfs.py
Last active December 22, 2015 16:03
How to do bfs in python
from treelib import Tree
tree = Tree()
# Create a tree for demo purpose
tree.create_node('A', 'a')
tree.create_node('B', 'b', parent='a')
tree.create_node('C', 'c', parent='a')
tree.create_node('D', 'd', parent='b')
tree.create_node('E', 'e', parent='b')
tree.create_node('F', 'f', parent='c')
@mondwan
mondwan / binary_search.py
Created December 22, 2015 15:53
How to do binary search in python
from bisect import bisect_left
# Source https://docs.python.org/2/library/bisect.html
def index(a, x):
'Locate the leftmost value exactly equal to x'
i = bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
raise ValueError
@mondwan
mondwan / about.md
Last active October 24, 2023 07:16
HTTP request with netcat or openssl

About

This is a document about how to test HTTP requests by running openssl or nc

example_post_req.txt

  • Edit payload, pathanme, ip etc

Openssl

@mondwan
mondwan / .eslintrc
Last active February 29, 2016 05:04
My .eslintrc
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"amd": true
},
"settings": {
"ecmascript": 6,
"jsx": true
@mondwan
mondwan / .gitconfig
Last active February 29, 2016 05:03 — forked from pksunkara/config
# [MUST] Define user information which will be recorded in any newly created commits
[user]
name = Mond Wan
email = mondwan.1015@gmail.com
# [OPTIONAL] Define personal working preferences
[core]
# for window, use true
# for linux, MacOS, use input
autocrlf = input
editor = vim