Skip to content

Instantly share code, notes, and snippets.

View tuanchauict's full-sized avatar
🐟
I am lazy

Tuan Chau tuanchauict

🐟
I am lazy
View GitHub Profile
{"type":"G","i":"01-AAJypSwDcDi=72dzyy5Gv0jhnAd","v":24735131,"ss":[{"type":"T","i":"01-AAWBiFQgS39glWHKZ8MZrC37vVr","v":-1076953303,"b":"27|19|28|3","t":"Loading","e":{"be":{"fe":false,"fu":"F1","be":true,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"01-AAC+tFQlj8Qn35RCwuY6KCt+wJ1","v":995948949,"b":"27|23|28|3","t":"Error(errorType)","e":{"be":{"fe":false,"fu":"F1","be":true,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"01-AA41zFQV5PmkL1thuzox28DZdCq","v":1171550411,"b":"27|27|28|3","t":"Content(content)","e":{"be":{"fe":false,"fu":"F1","be":true,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"01-AA=v=FQBDSwnNDCVYvWBRu8SvCI","v":1332844473,"b":"72|17|28|3","t":"RenderingAdvertisement","e":{"be":{"fe":false,"fu":"F1","be":true,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"01-AA91CGQkBz0RwMpCWUizmF3v5uM","v":-1306080998,"b":"72|21|28|3","t":"RenderingContent","e":{"be":{"fe":false,"fu":"F1","be":true,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"0
@tuanchauict
tuanchauict / README.md
Last active January 15, 2023 12:31
Safari ebooks reader improvement

A simple script for adding a jump key (N / B) with two guidelines to help reading on PC easier.

The progress is also more trackable with page and percent

@tuanchauict
tuanchauict / textformat.py
Last active July 28, 2022 05:26
A simple script for formatting text
import re
text_formats = ['b', 'i', 'u', 'f']
dark_colors = ["black", "red", "green", "yellow", "blue",
"magenta", "cyan", "gray"]
light_colors = ["brightblack", "brightred", "brightgreen", "brightyellow", "brightblue",
"brightmagenta", "brightcyan", "white"]
def code(number):
@tuanchauict
tuanchauict / monosketch-presentation.mono
Last active March 22, 2023 02:45
MonoSketch presentation. (Download monosketch-presentation.mono and open with https://app.monosketch.io/ for interaction version)
{"type":"G","i":"lineandroid-studysession","v":1946641214,"ss":[{"type":"T","i":"01-AAJMj5q9y5mOEplaxEp31p58LhV","v":1272397638,"b":"3|328|71|4","t":"","e":{"be":{"fe":true,"fu":"F3","be":false,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1},"te":false},{"type":"T","i":"01-AAqVafqKeFtLGk+a3q6VqqYcyTl","v":-2021500222,"b":"12|224|12|9","t":"","e":{"be":{"fe":true,"fu":"F4","be":false,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"01-AAUbUfqvPsIPnvpCC2MqZUlAVbo","v":1348027652,"b":"5|224|7|5","t":"","e":{"be":{"fe":true,"fu":"F4","be":false,"bu":"S1","du":"1|0|0"},"tha":1,"tva":1}},{"type":"T","i":"01-AALQp5q31iA3cKeveDqpD7ztPpZ","v":1026161957,"b":"56|331|18|16","t":"GitHub","e":{"be":{"fe":true,"fu":"F4","be":false,"bu":"S1","du":"1|0|0"},"tha":1,"tva":2}},{"type":"T","i":"01-AATm04oC=YtfjV8MM4J3+wq9Mfl","v":-449682756,"b":"3|41|41|5","t":"\n╦ ╦┬ ┬┬ ┬  ╦  ┌┬┐┌─┐┌┬┐┌─┐  ┌┬┐┬ ┬┬┌─┐┌─┐\n║║║├─┤└┬┘  ║  │││├─┤ ││├┤    │ ├─┤│└─┐ ┌┘\n╚╩╝┴ ┴ ┴   ╩  ┴ ┴┴ ┴─┴┘└─┘   ┴ ┴ ┴┴└─┘ o \n","e":{"be":{"fe":false,"fu":"F1","b
@tuanchauict
tuanchauict / README.md
Last active May 11, 2024 23:08
Attach a stopwatch to Leetcode

This script attaches a stopwatch into the toolbar of Leetcode's problem page.

image

The feature is simple:

  • Start/Stop the stopwatch
  • Auto start after 2 mins remaining on the problem
  • Restore unstopped stopwatch for the next visit on the problem

Use this script with any browser extension allowing attaching JS to the page. (I use User JavaScript and CSS)

@tuanchauict
tuanchauict / RangeIndexMinimumQuery.py
Last active November 11, 2021 00:51
This implements the code suggested by David Eisenstat (https://stackoverflow.com/a/31107004/1028772) for Range minimum query with implicit Segment tree
class RangeIndexMinimumQuery:
def __init__(self, nums):
self.nums = nums
self.n = len(nums)
self.tree = [-1] * (2 * self.n)
for i in range(len(nums)):
index = self.n + i
while index > 0:
if self.tree[index] < 0 or nums[i] < nums[self.tree[index]]:
@tuanchauict
tuanchauict / README.md
Last active March 31, 2022 03:08
Schedule today online meeting

Why

5-minute before an online meeting is the hard time because we need to separate our mind both for checking the clock and keeping working on what we are doing. This does not guaratee we won't miss 1, or 2, or sometimes 10 minutes.

This simple script is to help us early register online meeting, then it will open the link on time.

Usage

Let's assume that we set alias to the file as zoomin

alias zoomin="sh /path/to/zoomin.sh"
class ArgumentParser:
def __init__(self, args):
self.positioned_arguments = list(filter(lambda x: not x.startswith('--'), args))
self.named_argument_map = dict(map(lambda x: x.split("=", 1) if "=" in x else (x, None),
filter(lambda x: x.startswith('--'), args)))
def get(self, key_or_index):
if type(key_or_index) is int:
return self.positioned_arguments[key_or_index]
else:
@tuanchauict
tuanchauict / adb_all_backup.sh
Created October 3, 2020 01:55
Back up your app debug data and restore for avoid loosing data while testing
#!/bin/bash -e
# List all backups
device_path="zzzBackup"
package=<package_of_the_app> # <--- replace this with your app
adb shell "run-as $package ls $device_path"
def testcase(*testcases):
def build_format():
max_param_len = 0
max_result_len = 0
num_params = 0
for case in testcases:
num_params = len(case) - 1
for param in case[1:]:
str_param = str(param)
max_param_len = max(max_param_len, len(str_param))