Skip to content

Instantly share code, notes, and snippets.

View tclh123's full-sized avatar
💭
Be an artist

Harry Lee tclh123

💭
Be an artist
View GitHub Profile
@tclh123
tclh123 / vpn.md
Created November 8, 2023 17:02 — forked from condorheroblog/vpn.md
https://www.v2aky.com/#/register?code=wFPA8fv7
Limited-A4
@tclh123
tclh123 / gist:990496876bd09663da52f1a19a7d5904
Created April 30, 2021 08:53
Change replica factor for kafka topics. You need to regenerate and assign all partitions after that if there're more than 1.
#!/bin/bash
topics=__consumer_offsets
new_servers=1,2
while read -r line; do lines+=("$line"); done <<<"$topics"
echo '{"version":1,
"partitions":[' > topic-expand-plan.json
for t in $topics; do
if [ "${t}" == "${lines[-1]}" ]; then
@tclh123
tclh123 / gist:3455441d0d2340cccaf2f81e327a3dd2
Created March 17, 2021 09:11 — forked from tjackowiak/gist:5058743
Moving Graphite database
1. Stop Apache
sudo /etc/init.d/apache2 stop
2. Stop Carbon
sudo su www-data
cd /opt/graphite/
./bin/carbon-cache.py stop
3. Move whisper directory to new location
@tclh123
tclh123 / migrate-pv-to-zone.sh
Created March 10, 2021 08:24
Migrate EBS Volume based PVs across AWS availability zones (ref. https://gist.github.com/caruccio/be825aa39d53535217494369cc793dbd)
#!/bin/bash
set -eu
NAMESPACE=$1
PVCNAME=$2
TARGETZONE=$3
# SNAPSHOTID is optional, if you did a snapshot already, you can pass it
SNAPSHOTID=${4:-}
@tclh123
tclh123 / README.md
Created November 10, 2020 09:22 — forked from bobrik/README.md
CFS hiccups
什么是交易策略?
交易策略是一系列规则的集合,包括进场和出场的条件,资金管理和风险控制等。策略有简单和复杂之分,简单的策略通常使用技术指标和价格行为,复杂的策略使用高阶数学和统计模型。通常情况下,我们会认为复杂的模型更优,但实证分析和学术研究表明,复杂的模型往往过度挖掘了历史数据,无法适应剧烈的市场变异,相反简单的模型在长期中更加稳定。
交易策略可划分为3个部分:指标(Indicator),信号(Signal)和规则(Rule)。
指标用于生成交易信号。计算指标的方法多种多样,可以是经济数据或估值指标(如PE和EBITDA),可以是技术指标(如MACD,RSI,MA),也可以是时间序列模型(ARIMA,GARCH)。技术指标在外汇交易中被广泛使用,它们是价格或成交量的函数,主要用于侦测趋势方向,衡量超买超卖状态,以及判断趋势反转。
价格和指标的相互作用形成信号。以均线穿越为例,当5日均线上穿10日均线时买入,当5日均线下穿10日均线时卖出。信号并不局限于买入和卖出,也包含筛子,主要作用是剔除噪音。在均线穿越中,交易员可以增加趋势筛子:只有当价格高于200日均线(上涨趋势),以及5日均线上穿10日均线才做多,如果价格低于200日均线,黄金交叉被视为虚假信号。著名的筛子有趋势筛子,时间筛子,成交量筛子和波动性筛子,它们是信号的重要组成部分。
@tclh123
tclh123 / snippet.sh
Created January 27, 2020 12:23
Upload gitlab snippets from cli. dependency: [python-gitlab](https://github.com/python-gitlab/python-gitlab)
#!/bin/bash
filepath=$1
if [[ -z $filepath ]]; then
echo "Usage: $0 <filepath>"
exit 1
fi
filename=$(basename $filepath)
random_title=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 14 | tr -d '\n'; echo)
@tclh123
tclh123 / iostream.rs
Created August 30, 2019 07:54 — forked from tamamu/iostream.rs
std::cout (C++) in Rust
use std::ops::Shl;
struct Rsout;
struct Endl;
impl<'a> Shl<&'a str> for Rsout {
type Output = Rsout;
fn shl(self, _rhs: &'a str) -> Rsout {
print!("{}", _rhs);
@tclh123
tclh123 / postgres-cheatsheet.md
Created February 28, 2019 16:06 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)