Skip to content

Instantly share code, notes, and snippets.

View ceshine's full-sized avatar

CeShine Lee ceshine

View GitHub Profile
@dpseidel
dpseidel / default_aes.md
Last active February 12, 2021 17:08
Default ggplot2 aesthetics table

Default ggplot2 aesthetics by geom.

geom alpha angle colour family fill fontface height hjust lineheight linetype shape size stroke vjust weight width xmax xmin ymax ymin
GeomAbline NA black 1 0.5
GeomAnnotationMap NA NA grey20 1 0.5
GeomArea NA NA grey20 1 0.5
GeomBar NA NA grey35 1 0.
@ceshine
ceshine / bactrader_sample.py
Last active July 22, 2024 07:35
A Simple Strategy Trading Two Stocks (back trader)
"""A Simple Strategy Trading Two Stocks
Original code: https://blog.csdn.net/qq_26948675/article/details/80016633
Modified based on: https://www.backtrader.com/blog/posts/2018-04-22-improving-code/improving-code.html
Replaced the local CSV files with online data from IEX.
Unfortunately, this strategy is not profitable for the two stocks picked.
"""
@ceshine
ceshine / python_in_visual_studio_code.md
Last active August 5, 2019 09:30
How To Develop Python Programs in Visual Studio Code

How To Develop Python Programs in Visual Studio Code

Prerequisites

You have to already have these in your system:

@ceshine
ceshine / detector.py
Last active April 22, 2020 05:57
A Simple CJK Language Detector
import re
def cjk_detect(texts):
# korean
if re.search("[\uac00-\ud7a3]", texts):
return "ko"
# japanese
if re.search("[\u3040-\u30ff]", texts):
return "ja"
@ceshine
ceshine / spacy_sentencizer.ipynb
Created August 14, 2019 04:46
Customizing Spacy's Statistical Sentence Segmenter with Custom Rules
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tvst
tvst / SessionState.py
Last active September 30, 2024 07:47
DO NOT USE!!! Try st.session_state instead.
"""Hack to add per-session state to Streamlit.
Usage
-----
>>> import SessionState
>>>
>>> session_state = SessionState.get(user_name='', favorite_color='black')
>>> session_state.user_name
''
@moyix
moyix / tree.sh
Created December 16, 2019 23:45
A very silly script to make a Christmas tree with 224 cores in htop
# Upper
cpulimit -l 1 -- taskset -c 0 ./pct
cpulimit -l 18 -- taskset -c 1 ./pct
cpulimit -l 35 -- taskset -c 2 ./pct
cpulimit -l 52 -- taskset -c 3 ./pct
cpulimit -l 69 -- taskset -c 4 ./pct
cpulimit -l 86 -- taskset -c 5 ./pct
cpulimit -l 103 -- taskset -c 6 ./pct
cpulimit -l 1 -- taskset -c 63 ./pct
@mblondel
mblondel / check_convex.py
Last active January 3, 2025 12:42
A small script to get numerical evidence that a function is convex
# Authors: Mathieu Blondel, Vlad Niculae
# License: BSD 3 clause
import numpy as np
def _gen_pairs(gen, max_iter, max_inner, random_state, verbose):
rng = np.random.RandomState(random_state)
# if tuple, interpret as randn
@ceshine
ceshine / run_tf_glue.ipynb
Created December 26, 2019 06:55
Train huggingface/transformers BERT model on Cloud CPU with TF 2.1 (nightly build)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@IanColdwater
IanColdwater / twittermute.txt
Last active April 14, 2025 16:31
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet