Skip to content

Instantly share code, notes, and snippets.

View SanCoder-Q's full-sized avatar
💭
I may be slow to respond.

JmQu SanCoder-Q

💭
I may be slow to respond.
View GitHub Profile
@SanCoder-Q
SanCoder-Q / permit.sh
Created August 13, 2019 02:00
Enable docker network throw mac firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /Library/PrivilegedHelperTools/com.docker.vmnetd
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /Library/PrivilegedHelperTools/com.docker.vmnetd
@SanCoder-Q
SanCoder-Q / permit.sh
Created August 13, 2019 02:00
Enable docker network throw mac firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /Library/PrivilegedHelperTools/com.docker.vmnetd
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /Library/PrivilegedHelperTools/com.docker.vmnetd
@SanCoder-Q
SanCoder-Q / gpg-file.sh
Last active December 19, 2018 03:42
Using gpg to transfer file in a secure way
# install GnuPG
brew install gpg
# generate gpg key pair
gpg --gen-key
# list keys
gpg --list-keys
# export public key
@SanCoder-Q
SanCoder-Q / tricks.git.api.sh
Created November 29, 2018 02:10
Tricks using github API
git_auth_token=''
git_domain=''
org_name=''
# Clone all
curl "https://api.${git_domain}/${org_name}/<>/repos" -H "Authorization: token ${git_auth_token}" |\
jq -r .[].subscription_url |\
xargs -n1 -Ix git clone x
# Watch all

Keybase proof

I hereby claim:

  • I am sancoder-q on github.
  • I am jianmingqu (https://keybase.io/jianmingqu) on keybase.
  • I have a public key ASCe98CA7WNuozg3o52bz01sT-GxaTchPqCRIDZGNjqingo

To claim this, I am signing this object:

@SanCoder-Q
SanCoder-Q / web-jsx-mode.el
Created January 3, 2018 05:09
Make emacs web-mode force to load as .jsx
(add-hook 'web-mode-hook
(lambda ()
;; short circuit js mode and just do everything in jsx-mode
(if (equal web-mode-content-type "javascript")
(web-mode-set-content-type "jsx")
(message "now set to: %s" web-mode-content-type))))
@SanCoder-Q
SanCoder-Q / enable.jffs.sh
Created January 2, 2018 13:21
Enable jffs on DD-WRT by SSH
nvram set enable_jffs2=1
nvram set jffs2_scripts=1
nvram commit
reboot
@SanCoder-Q
SanCoder-Q / synology.startup
Created December 25, 2017 14:29
Synology NAS - How to make a program run at startup
Synology NAS - How to make a program run at startup
The other day I created a little node.js project to keep track of some finances. Synology has a node.js package but that just installs the tools - it has no 'container' or any other support to drop files and have it run automagically. Maybe one day.
In the meantime, you can start your project when you SSH into the NAS. My project has a 'www' script which bootstraps my project, so to start I simply type 'node bin/www' from the project directory. But, it only runs while I'm logged in, and if I log out for any reason, the process dies. That's hardly useful when I'm away from home, or on a different PC. So I decided to have a look at starting my project as a Linux service.
After doing a lot of research into how Synology does services, and a few failed attempts at init scripts, I found that Synology DSM (since version 5 perhaps) bundles Upstart, which is a neat little tool to deal with services on Linux. It's most prevalent on Debian and derivatives (notably Ub
#清空所有链
iptables --flush
iptables --delete-chain
iptables --table mangle --flush
iptables --table mangle --delete-chain
#设定默认规则
iptables --policy INPUT DROP
iptables --policy OUTPUT ACCEPT
iptables --policy FORWARD DROP
#允许SSH
@SanCoder-Q
SanCoder-Q / file
Created November 13, 2017 16:00 — forked from liantian-cn/file
shadowsocks iptables规则
# 新建一个无密码,无法登陆,没home的系统用户,就叫shadowsocks
adduser --system --disabled-password --disabled-login --no-create-home shadowsocks
# 修改 /etc/default/shadowsocks-libev
USER=shadowsocks
GROUP=nogroup
# 使用setcap,允许非root用户无法监听低位端口
apt-get install libcap2-bin
setcap 'cap_net_bind_service=+ep' /usr/bin/ss-server