Skip to content

Instantly share code, notes, and snippets.

Avatar

Charlee Li charlee

View GitHub Profile
@charlee
charlee / DrawOnGithubContribCalendar.js
Last active Jun 30, 2022
DrawOnGithubContribCalendar
View DrawOnGithubContribCalendar.js
/**
* 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 / types.ts
Created Jan 13, 2022
TypeScript Utility types
View types.ts
// Remove null or undefine from array items
type NonNullableArray<T> = T extends Array<infer Item> ? Array<NonNullable<Item>> : never;
@charlee
charlee / test1.tsx
Last active May 22, 2019
medium test
View test1.tsx
type TestType = {
key: string;
value: string;
}
export TestType;
@charlee
charlee / .Xmodmap
Last active Feb 9, 2019 — forked from timofurrer/.Xmodmap
Mint Linux on MacBook.
View .Xmodmap
! 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 / README.md
Created Sep 8, 2018 — forked from int128/README.md
Watching build mode on Create React App
View README.md

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 / Dockerfile
Created Sep 4, 2018
Docker file from alpine:3.8 to solve the x509 issue
View Dockerfile
FROM alpine:3.8
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
@charlee
charlee / reddit-scraper.py
Last active Jun 11, 2021
A script that scrape top news from Reddit and extract the content as Markdown.
View reddit-scraper.py
#!/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
View sequence.csv
R Python Note
seq(1,5) == 1,2,3,4,5 range(1,5) == [1,2,3,4] The 'stop' number is included in R while excluded in Python
seq(5,1) range(5,1,-1) The sign of 'step' is automatically determined in R while must be specified explicitly in Python
@charlee
charlee / Game-1.css
Last active May 4, 2018
Conway's Game of Life
View Game-1.css
.Board {
position: relative;
margin: 0 auto;
background-color: #000;
}
@charlee
charlee / traverse.py
Created Jan 16, 2018
traverse modules and objects in python
View traverse.py
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__)