Skip to content

Instantly share code, notes, and snippets.

View SeanChao's full-sized avatar

Sean Chao SeanChao

  • Cambridge, UK
  • 18:51 (UTC +01:00)
View GitHub Profile
@SeanChao
SeanChao / iteration-function.py
Created November 4, 2019 03:25
Iteration Funtion Plot
import matplotlib.pyplot as plt
import numpy as np
x = 0
plotX = []
plotY = []
for k in np.arange(0, 2, 0.01):
for i in range(0, 600):
x = 1 - k * x ** 2
if (i > 500):
plotX.append(k)
@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 / bat
Created December 25, 2019 13:22
WSL2 Hyper-V
bcdedit /set hypervisorlaunchtype off
bcdedit /set hypervisorlaunchtype auto
@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 / 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 / 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}
@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 / .zshrc
Last active June 12, 2020 11:20
🌈 customized shell
# @deprecated WSL2 Setup
# export winip=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
export winip="sean.mshome.net"
# Environment Variable
export HTTP_PROXY_PORT=1081
export SOCKS_PROXY_PORT=1080
export DISPLAY=${winip}:0.0
export NIX_PATH=$HOME/.nix-defexpr/channels
export NIX_PROFILES='/nix/var/nix/profiles/default $HOME/.nix-profile'
@SeanChao
SeanChao / profiles.json
Last active June 13, 2020 06:02
Windows Terminal Profile
// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@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