Skip to content

Instantly share code, notes, and snippets.

View dyllanwli's full-sized avatar
🎸
Focusing

DY-L dyllanwli

🎸
Focusing
View GitHub Profile
@dyllanwli
dyllanwli / chatgpt.py
Created May 7, 2023 04:53
Chatgpt commodity trading based on TQSDK
from datetime import date, datetime
from contextlib import closing
import openai
import time
import math
import typing
import numpy as np
import pandas as pd
from tqsdk import tafunc, TqAuth, TqApi, TqSim, TqBacktest, TqAccount, TargetPosTask, BacktestFinished
@dyllanwli
dyllanwli / colabcode.sh
Created November 30, 2020 22:27
Run VScode on colab
!curl -fsSL https://code-server.dev/install.sh | sh
!pip install -qqq pyngrok
from pyngrok import ngrok
url = ngrok.connect(port=9000)
print(url)
!nohup code-server --port 9000 --auth none &
@dyllanwli
dyllanwli / clear.sh
Created July 28, 2020 17:46
Clear local branch not exists in remote
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D
@dyllanwli
dyllanwli / reset.sh
Created June 4, 2020 15:09
Reset your iptables
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
# https://serverfault.com/questions/200635/best-way-to-clear-all-iptables-rules
# To answer your question succinctly, no: there would not be any "leftover" rules after flushing every table. In the interest of being thorough however, you may want to set the policy for the built-in INPUT and FORWARD chains to ACCEPT, as well
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
@dyllanwli
dyllanwli / .bashrc
Last active April 26, 2020 00:08
hprc .bashrc
alias activatejupyter='module load Anaconda/3-5.0.0.1 ; source activate jupyterlab_2.0.1'
alias rm='trash' # to avoid wrong delete
# use \rm -rf is you still want to delete all file
# make symbolic link to avoid disk file count usage
# ln -s <the short cut that you want to link (may not be exist)> <the real folder path(must exist)>
@dyllanwli
dyllanwli / setReplica.sh
Created December 23, 2019 05:52
Mongodb set replica set
# start mongodb with --replSet rs
# the rs means replica set name
# if MONGO_INITDB_ROOT_USERNAME was set, then use those init db root username and password
mongo -u <your user name> --authenticationDatabase admin -p <your passowrd>
rs.initiate()
@dyllanwli
dyllanwli / Pdf2JpegConverter.java
Created July 23, 2019 07:39
convert PDF to JPEG/multi-page tiff/image-pdf files
package org.doc2pdf.lambda;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
@dyllanwli
dyllanwli / s3.sh
Last active June 5, 2019 07:19
aws s3 command
aws --version
# aws-cli/1.15.30 Python/3.6.5 Darwin/17.6.0 botocore/1.10.30
# move or rename bucket
aws s3 mb s3://[new-bucket]
aws s3 mv s3://old-bucket s3://new-bucket --recursive
# or
aws s3 mb s3://[new-bucket]
aws s3 sync s3://[old-bucket] s3://[new-bucket]
@dyllanwli
dyllanwli / copyfile.sh
Created May 13, 2019 08:26
Some linux command
# linux command . Copy a file one hundred times
for n in {001..100}; do
cp file.jpg file-$n.jpg
done
@dyllanwli
dyllanwli / single_convert.sh
Created May 13, 2019 03:28
Libreoffice headless convert doc to pdf
echo "hello world" > a.txt
soffice --headless --invisible --nodefault --nofirststartwizard \
--nolockcheck --nologo --norestore --convert-to pdf --outdir $(pwd) a.txt
# to run multiple convert just use * as a selector