Skip to content

Instantly share code, notes, and snippets.

View SeanChao's full-sized avatar

Sean Chao SeanChao

  • Cambridge, UK
  • 10:47 (UTC +01:00)
View GitHub Profile
@SeanChao
SeanChao / README.md
Last active June 8, 2021 13:08
Preliminary Plan for go-storage-ipfs

技术方案

背景

go-storage 是用 Golang 实现的抽象存储模块,支持各种存储服务。本方案的目的是为实现 go-storage 对 IPFS 的适配。go-storage 已经支持了较多的存储服务,例如 azblob, cos, dropbox 等。

go-service-example 是扩展 go-storage 的模板仓库,可以在此基础上进行修改以适配 IPFS。

go-ipfs 是 IPFS 的官方 Go 实现,可以作为依赖库集成到其它 Go 项目中。

@SeanChao
SeanChao / smart_pointer.cc
Created March 21, 2021 09:57
A simple smart pointer implementation
template <typename T>
class shared {
public:
shared(T* ptr) : ptr(ptr) {
ref_cnt = new size_t(1);
};
shared& operator=(const shared& rhs) {
if (*(this->ref_cnt) == 1) {
delete ref_cnt;
@SeanChao
SeanChao / .stignore
Created January 18, 2021 15:04
Syncthing ignore list
/node_modules
/.build
// Android
app/build
app/libs
target
build
// permission error
qaq-docker/mongo-data/journal
@SeanChao
SeanChao / irm.sh
Created November 11, 2020 05:41
rm by mv
rand_str() {
echo $(date +"%Y%m%d%H%M%S")_$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
}
for file in "$@"
do
file_basename=$(basename "$file")
target="/tmp/${file_basename}_$(rand_str)"
mv $file $target
if [[ $? -ne 0 ]]; then
@SeanChao
SeanChao / index.js
Created February 17, 2020 13:25
📚 Generate timetable with Google calendar API
/**
* Please refer to https://developers.google.com/calendar/quickstart/nodejs for full documentation
*/
const fs = require('fs');
const readline = require('readline');
const { google } = require('googleapis');
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/calendar'];
// The file token.json stores the user's access and refresh tokens, and is
@SeanChao
SeanChao / ydl.py
Created January 30, 2020 09:30
youtube-dl extension
from __future__ import unicode_literals
import subprocess
import os
import re
import sys
import youtube_dl
# Configuration Here
ydl_opts = {
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best',
@SeanChao
SeanChao / chaos.zsh-theme
Last active June 4, 2020 14:29
🖌 My customized ZSH theme~
ZSH_THEME_GIT_PROMPT_PREFIX="<%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}>"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
PROMPT="%(?..%{$fg[red]%}❌%? %{$reset_color%})💻 %{$fg[cyan]%}%n%{$reset_color%}@%{$fg[blue]%}%m%{$reset_color%} \
💡 %{$fg[yellow]%}%~%{$reset_color%} "'$(git_prompt_info)'"
> "
RPROMPT="%{$fg[white]%}⏳%*"
@SeanChao
SeanChao / bat
Created December 25, 2019 13:22
WSL2 Hyper-V
bcdedit /set hypervisorlaunchtype off
bcdedit /set hypervisorlaunchtype auto
@SeanChao
SeanChao / sh-snippet.sh
Created December 4, 2019 12:46
Shell Scripting
##########################
# Shell Snippet #
##########################
# input
read flag
if [ "$flag" = "n" ]; then
echo NO
exit
fi
@SeanChao
SeanChao / Latex-SSnippet.tex
Last active May 18, 2020 11:06
Super snippet for LaTex
% 多图并排
\begin{figure}[htbp]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width=.95\textwidth]{path-to-pic}
\caption{}
\label{}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}