Skip to content

Instantly share code, notes, and snippets.

View ceshine's full-sized avatar

CeShine Lee ceshine

View GitHub Profile
@tvst
tvst / SessionState.py
Last active December 27, 2025 20:51
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
''
@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.
@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 / 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 / bactrader_sample.py
Last active May 31, 2025 09:09
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.
"""
@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.
@deargle
deargle / tokenize.py
Last active April 22, 2021 12:32
Example of TfidfVectorizer with custom tokenizer that does basic stemming
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 24 16:30:42 2018
@author: deargle
"""
from sklearn.feature_extraction.text import TfidfVectorizer
from nltk.stem.porter import PorterStemmer
import nltk
@superMDguy
superMDguy / add_weather.py
Last active February 24, 2018 20:47
Adds weather data to dataset for kaggle "Recruit Restaurant Visitor Forecasting" competition
train.visit_date = pd.to_datetime(train.visit_date)
test.visit_date = pd.to_datetime(test.visit_date)
def add_weather(dataset):
print('Adding weather...')
air_nearest = pd.read_csv(
'../../data/raw/weather/air_store_info_with_nearest_active_station.csv')
unique_air_store_ids = list(dataset.air_store_id.unique())
weather_dir = '../../data/raw/weather/1-1-16_5-31-17_Weathe
@oseiskar
oseiskar / simdkalman-kaggle-example.ipynb
Last active February 17, 2023 19:54
simdkalman example: Kaggle Web Traffic Time Series Forecasting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primaryobjects
primaryobjects / react-confirm.js
Created November 1, 2017 19:03
A simple example of a confirm alert dialog in ReactJs / React.
<div className='delete-button' onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) this.onCancel(item) } } />