Skip to content

Instantly share code, notes, and snippets.

View charlee's full-sized avatar

Charlee Li charlee

View GitHub Profile
@charlee
charlee / README.md
Created September 8, 2018 13:43 — forked from int128/README.md
Watching build mode on Create React App

Create React App does not provide watching build mode oficially (#1070).

This script provides watching build mode for an external tool such as Chrome Extensions or Firebase app.

How to Use

Create a React app.

Put the script into scripts/watch.js.

@charlee
charlee / .Xmodmap
Last active February 9, 2019 22:38 — forked from timofurrer/.Xmodmap
Mint Linux on MacBook.
! Swap Alt and Cmd keys.
keycode 37 = Control_L
keycode 133 = Alt_L Meta_L
keycode 64 = Super_L
keycode 108 = Super_R
keycode 134 = ISO_Level3_Shift Multi_key
keycode 105 = Control_R Multi_key
clear Shift
clear Lock
clear Control
@charlee
charlee / test1.tsx
Last active May 22, 2019 15:20
medium test
type TestType = {
key: string;
value: string;
}
export TestType;
@charlee
charlee / default.custom.yaml
Last active January 19, 2021 00:51
鼠须管颜文字配置文件
patch:
schema_list:
- schema: luna_pinyin_simp
- schema: emoji
@charlee
charlee / reddit-scraper.py
Last active June 11, 2021 02:15
A script that scrape top news from Reddit and extract the content as Markdown.
#!/usr/bin/env python
import os
import re
import praw
import requests
from datetime import datetime
from bs4 import BeautifulSoup
for sub in subs:
res = requests.get(sub.url)
if (res.status_code == 200 and 'content-type' in res.headers and
@charlee
charlee / types.ts
Created January 13, 2022 15:27
TypeScript Utility types
// Remove null or undefine from array items
type NonNullableArray<T> = T extends Array<infer Item> ? Array<NonNullable<Item>> : never;
@charlee
charlee / ffmpeg.sh
Last active January 19, 2022 15:05
ffmpeg tips
# losslessly concat mp4 files
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
# concat files with the same format
# 1. create a file list
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
@charlee
charlee / DrawOnGithubContribCalendar.js
Last active June 30, 2022 19:26
DrawOnGithubContribCalendar
/**
* Draw string in the github contribution calendar.
* Usage:
* 1. Create a "snippet" in the Chrome devtool -> Sources -> Snippets (in left sidebar).
* 2. Visit your github profile page.
* 3. Modify the string.
* 4. Run
*
* Credit:
* - 3x5 font data: https://github.com/fabiopiratininga/oled-font-3x5
@charlee
charlee / traverse.py
Created January 16, 2018 19:41
traverse modules and objects in python
import sys
import pkgutil
import importlib
from .base import BaseCommand, CommandExecutor
def discover_commands():
executor = CommandExecutor()
current_module = sys.modules[__name__]
__path__ = pkgutil.extend_path(current_module.__path__, __name__)
@charlee
charlee / read_from_tfrecords.py
Created October 24, 2017 05:16
Read example from TFRecord
def read_and_decode(filename_queue):
"""Read from tfrecords file and decode and normalize the image data."""
reader = tf.TFRecordReader()
_, serialized_exmaple = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_exmaple,
features={
'image': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64),