Skip to content

Instantly share code, notes, and snippets.

@tom-code
tom-code / gist:08eca39cbdcf8cd5c15e05190bac7bc2
Created January 6, 2024 19:34
rust crosscompile to turris (from mac)
rustup target add armv7-unknown-linux-musleabihf
brew install arm-linux-gnueabihf-binutils
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-ld cargo build --target=armv7-unknown-linux-musleabihf
@tom-code
tom-code / gist:16b5dc37b356c35d44d17094fe06cf62
Created January 1, 2024 14:28
rust crosscompile mac->linux
brew install SergioBenitez/osxct/x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-gnu
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc cargo build --target=x86_64-unknown-linux-gnu
sudo qemu-system-aarch64 \
-kernel /Volumes/data/qemu/openwrt-23.05.05-armsr/openwrt-23.05.2-armsr-armv8-generic-initramfs-kernel.bin \
-drive file=/Volumes/data/qemu/openwrt-23.05.05-armsr/openwrt-23.05.2-armsr-armv8-generic-squashfs-rootfs.img.work,if=virtio,format=raw \
-append root=/dev/vda \
-cpu cortex-a57 -m 2048 -smp 2 -machine virt \
-nographic \
-device virtio-net-pci,netdev=net0 -netdev vmnet-host,id=net0,net-uuid=86d5e2de-594c-421e-be0d-8a3ac19dc207 \
-device virtio-net-pci,netdev=net1 -netdev vmnet-bridged,ifname=en0,id=net1
ssh -o ProxyCommand="corkscrew ng-dpx01.intinfra.com 3128 <home ip> 443" -o 'RemoteForward=localhost:23 localhost:22' root@localhost
connect bak:
ssh \
-o PermitLocalCommand=yes \
-o LocalCommand="ifconfig tun5 192.168.244.2 pointopoint 192.168.244.1 netmask 255.255.255.0" \
-o ServerAliveInterval=60 \
-w 5:5 root@localhost -p 23 \
'ifconfig tun5 192.168.244.1 pointopoint 192.168.244.2 netmask 255.255.255.0; echo tun0 ready'
@tom-code
tom-code / coro.h
Created January 10, 2023 20:58
c++20 coroutine minidemo
#include <concepts>
#include <experimental/coroutine>
#include <iostream>
#include <unistd.h>
#include <thread>
#include <vector>
struct awaitable {
@tom-code
tom-code / alpine-kind.sh
Last active December 24, 2022 09:35
install kind in alpine
echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
apk add docker
service docker start
service docker enable
apk add curl
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
chmod +x ./kind
mv ./kind /usr/local/bin/kind
qemu-system-aarch64 -M virt -m 1G -cpu cortex-a57 -smp 1 -cdrom alpine-virt-3.15.4-aarch64.iso -pflash "/usr/local/Cellar/qemu/6.2.0_1/share/qemu/edk2-aarch64-code.fd" -serial stdio -nodefaults -M virt,highmem=off -boot d
qemu-system-aarch64 -nographic -machine virt -m 4096 -cpu cortex-a57 -drive if=pflash,format=raw,readonly,file=/usr/local/Cellar/qemu/6.2.0_1/share/qemu/edk2-aarch64-code.fd -drive format=raw,readonly,file=alpine-virt-3.15.4-aarch64.iso
@tom-code
tom-code / gist:18f49a5b56ca53a21c012d2035dda650
Last active January 29, 2024 06:22
activesync autodiscover
curl --basic -X "POST" -u XXX@YYY -v https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml -H "Content-Type: text/xml" -d @a.txt
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006">
<Request>
<EMailAddress>XXXXXXXXX</EMailAddress>
<AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006</AcceptableResponseSchema>
</Request>
</Autodiscover>
@tom-code
tom-code / wrt.sh
Created December 22, 2019 23:01
openwrt ipv6 fun in vm
qemu-system-arm -M virt-2.9 -kernel openwrt-18.06.5-armvirt-32-zImage -no-reboot -nographic \
-device virtio-net-pci,mac=00:00:00:00:00:01,netdev=br0 -netdev bridge,br=br0,id=br0 \
-device virtio-net-pci,mac=00:00:00:00:00:02,netdev=br1 -netdev bridge,br=br1,id=br1 \
-m 128M \
-drive file=openwrt-18.06.5-armvirt-32-root.ext4,if=virtio,format=raw \
-append "root=/dev/vda"
network:
config interface 'loopback'
@tom-code
tom-code / raftsample.go
Last active December 17, 2019 21:41
raftlib use
package main
import (
"fmt"
"net"
"io"
"github.com/hashicorp/raft"
"time"
"os"
"flag"