Skip to content

Instantly share code, notes, and snippets.

View yangl1996's full-sized avatar

Lei Yang yangl1996

View GitHub Profile
@yangl1996
yangl1996 / NOTE
Last active October 30, 2023 16:13
Mullvad VPN on OpenBSD
Note that this config puts the wireguard interface at routing domain 1, which is nondefault. To run a program using that
routing domain, execute
route -T1 exec your command ...
The reverse, which is installing wireguard to routing domain 0 (default), is also possible. You will need to first move
the "normal" interfaces to routing domain 1, and then use the keyword
wgrtable 1
when configuring the wireguard interface. This keyword tells wireguard to use routing domain 1 for connecting to the server.
Then, remove the keyword
rdomain 1
@yangl1996
yangl1996 / reth
Last active October 30, 2023 01:59
FreeBSD rc.d script for Reth
#!/bin/sh
# PROVIDE: reth
# REQUIRE: FILESYSTEMS netif pflog pfsync routing
. /etc/rc.subr
name="reth"
rcvar=${name}_enable
pidfile="/var/run/${name}.pid"
@yangl1996
yangl1996 / index.html
Created August 22, 2019 15:25
Kindle Countdown Clock
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Countdown</title>
</head>
<body>
<div style="display: flex; align-items: center; justify-content: center; height: 100vh;">
<p style="text-align: center; font-family: sans-serif; font-size: 5vh;">
@yangl1996
yangl1996 / print-slides.sh
Created April 23, 2019 23:03
Print slides in 2-up format
#!/bin/bash
# requires pdfjam from MacTeX, install thru tlmgr
for filename in "$@"
do
echo "Laying out $(basename $filename)"
outpath="$(dirname $filename)/$(basename $filename .pdf)_layout.pdf"
pdfjam $filename --nup 1x2 --outfile $outpath &> /dev/null
echo "Output written to $outpath"
@yangl1996
yangl1996 / mininet.py
Last active May 7, 2021 03:42
Parking Lot Topology for Mininet
#!/usr/bin/python
"""
hl hr
7.100 8.100
| |
7.1 8.1
r1--9--r2--10-r3--11-r4--12-r5--13-r6
1.1 2.1 3.1 4.1 5.1 6.1
| | | | | |
@yangl1996
yangl1996 / packet-generator.cpp
Created December 25, 2017 02:01 — forked from jonhoo/packet-generator.cpp
Complete example code showing how to construct a UDP packet from scratch and inject it on a WiFi interface in Linux
/**
* Hello, and welcome to this brief, but hopefully complete, example file for
* wireless packet injection using pcap.
*
* Although there are various resources for this spread on the web, it is hard
* to find a single, cohesive piece that shows how everything fits together.
* This file aims to give such an example, constructing a fully valid UDP packet
* all the way from the 802.11 PHY header (through radiotap) to the data part of
* the packet and then injecting it on a wireless interface
*
@yangl1996
yangl1996 / cloud-example.py
Last active October 2, 2017 09:33
TCP Echoling
import python_bind
# first exec ./echo-server.sh
def tensorflow_run(dt):
print("processing", dt.decode())
python_bind.init_cloud()
data = python_bind.recv()
@yangl1996
yangl1996 / README
Last active December 24, 2017 10:12
802.11 CSI Tool Injecting Mode
Useage: ./setinj <device name> <channel> <bandwidth>
Example: ./setinj wlan1 3 HT20
@yangl1996
yangl1996 / com.yangl1996.sshtunnelforvnc.plist
Created June 2, 2017 16:42
On-demand SSH tunnel using launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.yangl1996.sshtunnelforvnc</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ssh</string>
<string>-q</string>
@yangl1996
yangl1996 / lightctl
Created May 14, 2017 17:11
lightctl - control USB power on/off on BeagleBone Black
#!/usr/bin/bash
function lighton {
until sudo devmem2 0x47401c60 b 0x01
do
echo "Trying again"
done
}
function lightoff {
until sudo devmem2 0x47401c60 b 0x00