This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
interface=ipsec_bridge | |
target_ip="192.168.2.100" | |
cidr_ip=$(ip addr show "$interface" | grep 'inet ' | awk '{print $2}') | |
network=$(ipcalc "$cidr_ip" | grep "Network:" | awk '{print $2}') | |
function add_masquerade { | |
iptables -t nat -C POSTROUTING -s "$network" -j SNAT --to "$target_ip" || { | |
iptables -t nat -I POSTROUTING 1 -s "$network" -j SNAT --to "$target_ip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
allow_ips=("211.75.165.175") | |
function handle_connect { | |
ip=$trusted_ip | |
echo "Current IP: ${ip}" | |
for allow_ip in ${allow_ips[@]}; do | |
if [[ $allow_ip == $ip ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
def main(): | |
img = cv2.imread("./demo.jpeg", cv2.IMREAD_COLOR) | |
sobel_kernel = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], dtype=np.int32) | |
# NOTE: filter2D is actually computing correlation so we flip the kernel here | |
# See: https://docs.opencv.org/4.5.0/d4/d86/group__imgproc__filter.html#ga27c049795ce870216ddfb366086b5a04 | |
# for more information | |
img_grad_x = cv2.filter2D(img, -1, sobel_kernel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
def main(): | |
img = cv2.imread("./demo.jpeg", cv2.IMREAD_COLOR) | |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
edges = cv2.Canny(img, 100, 200) | |
cv2.imwrite("edge.jpeg", edges) | |
if __name__ == "__main__": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <iostream> | |
#include <random> | |
#include <bitset> | |
#include <assert.h> | |
#define MAXN 100 | |
// P = R * 2^K + 1, G is its primitive root | |
#define P 1004535809LL | |
#define G 3 | |
#define R 479 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while : | |
do | |
echo "Sleep awhile" | |
sleep 10m | |
# Check if there is python process | |
if [[ $(ps -ef | grep -c 'python train.py') == 1 ]]; then | |
sudo shutdown now | |
fi | |
done |