Skip to content

Instantly share code, notes, and snippets.

@clyang
clyang / backup_venv.sh
Created May 15, 2023 16:02 — forked from ashwinvis/backup_venv.sh
Backup virtualenv before a Python 3.x upgrade and restore / recreate after the upgrade
#!/bin/bash
cd ~
pip freeze --user --exclude-editable > REQUIREMENTS.txt
cd $WORKON_HOME # or wherever you store your virtualenvs
for activate in ./*/bin/activate
do
source $activate
echo $VIRTUAL_ENV
invalid_mask = _mm256_cmp_ps(x, _mm256_setzero_ps(), _CMP_NGE_UQ); // not greater equal is true if x is NaN
iszero_mask = _mm256_cmp_ps(x, _mm256_setzero_ps(), _CMP_EQ_OQ);
return _mm256_or_ps(
_mm256_andnot_ps(iszero_mask, _mm256_or_ps(x, invalid_mask)),
_mm256_and_ps(iszero_mask, *(v8sf *)_ps256_minus_inf));
/* Compare */
#define _CMP_EQ_OQ 0x00 /* Equal (ordered, non-signaling) */
@clyang
clyang / gist:4f3e9f4098469cf53715ed64bede3932
Last active May 24, 2024 15:41
10GB以上的測速檔案 (IPv4及IPv6) - 10GB+ Speedtest file urls (IPv4 & IPv6)
http://download.xs4all.nl/test/10GB.bin
http://ftp.iinet.net.au/test500MB.dat
http://lg-tor.fdcservers.net/10GBtest.zip
http://lg.ams2-c.fdcservers.net/10GBtest.zip
http://lg.chi2-c.fdcservers.net/10GBtest.zip
http://lg.den2-c.fdcservers.net/10GBtest.zip
http://lg.fra2-c.fdcservers.net/10GBtest.zip
http://lg.la2-c.fdcservers.net/10GBtest.zip
http://lg.lon-c.fdcservers.net/10GBtest.zip
http://lg.mad-c.fdcservers.net/10GBtest.zip
@clyang
clyang / gist:9e2e04299d51cc11e29a010e2c430480
Created August 11, 2017 05:52
Edgerouter解決PPPoE重新連線後, IPv6無法使用的問題
(本操作需要有基本使用vi的能力)
1. ssh登入Edgerouter後, sudo vi /etc/ppp/ip-down.d/remove_invalidv6.sh 貼上下列內容
#!/bin/sh
/sbin/ifconfig switch0 | grep -ivE 'fe80' | grep 'inet6' | awk '{print $3}' | while read -r ipv6addr ; do
echo "Removing $ipv6addr from switch0" >> /tmp/ipv6_remove.log
/sbin/ip -6 addr del $ipv6addr dev switch0
done
/etc/init.d/radvd restart
@clyang
clyang / remove_invalidv6.sh
Last active August 20, 2023 01:21
EdgeOS - Clean up useless IPv6 addresses after PPPoE is down/reconnected (/etc/ppp/ip-down.d)
#!/bin/sh
/sbin/ifconfig switch0 | grep -ivE 'fe80' | grep 'inet6' | awk '{print $3}' | while read -r ipv6addr ; do
echo "Removing $ipv6addr from switch0" >> /tmp/ipv6_remove.log
/sbin/ip -6 addr del $ipv6addr dev switch0
done
/etc/init.d/radvd restart
@clyang
clyang / gist:9e4279aca6f8dc21b24fc33e68d1a95b
Created July 31, 2017 07:58
Edgerouter-X搭配Hinet IPv6 Dual Stack設定 (eth4串在光世代數據機當wan)
configure
edit firewall
edit ipv6-name WAN6_IN
set default-action drop
set rule 10 action accept
set rule 10 description "Allow established/related"
set rule 10 state established enable
set rule 10 state related enable
set rule 20 action drop
@clyang
clyang / gist:1a11fc914467a29240d9
Last active October 17, 2015 01:49
貼心小提醒, 強化ssh設定來避開Logjam攻擊
*** Nginx / Apache / IIS / Tomcat / Postfix / Sendmail / Dovecot / HAProxy使用者請參考 https://weakdh.org/sysadmin.html ***
*** 這邊有現成的tool可以掃 .. https://github.com/GDSSecurity/SSH-Weak-DH ***
這兩天很紅的weak DH的Logjam攻擊也是會影響到ssh key exchange的, 最簡單的解法就是強迫自己的client不用prime-field Diffie-Hellman的key exchange algorithm.
在 .ssh/config 中加上下面設定即可:
Host *
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256 # 如果你要連到很古老的機器, 那可以多加一個 diffie-hellman-group14-sha1
自己有server也可以在 /etc/ssh/config中加上 `KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256` 然後restart ssh server
@clyang
clyang / gist:f5bc3a267091d0ab8856
Created September 24, 2015 23:24
WEP in wpa_supplicant.conf
network={
ssid="MYWEAKLYENCRYPTEDWLAN"
key_mgmt=NONE
wep_key0="12345" # or 13 characters, or a hexkey starting with 0x
wep_tx_keyidx=0
}
auto eth0
iface eth0 inet static
address 198.51.100.87
netmask 255.255.255.0
gateway 198.51.100.1
post-up ip route add 198.51.100.0/24 dev eth0 table 1
post-up ip route add default via 198.51.100.1 table 1
post-up ip rule add from 198.51.100.87/32 table 1 priority 100
post-up ip route flush cache
pre-down ip rule del from 198.51.100.87/32 table 1 priority 100
@clyang
clyang / gist:3231e507d90a161010a2
Created September 22, 2015 02:57
Multipath TCP kernel on DigitalOcean droplet (Ubuntu 14.04)
(all instruction need root permission)
0. Create a droplet with Ubuntu 14.04 image
1. wget -q -O - http://multipath-tcp.org/mptcp.gpg.key | sudo apt-key add -
2. vim /etc/apt/sources.list.d/mptcp.list , add line:
deb http://multipath-tcp.org/repos/apt/debian trusty main
3. apt-get update && apt-get install linux-mptcp