Skip to content

Instantly share code, notes, and snippets.

@x2c3z4
x2c3z4 / shapping-https.sh
Created November 4, 2021 05:31 — forked from xarg/shapping-https.sh
Limiting traffic with tc
#!/bin/bash
#
# tc uses the following units when passed as a parameter.
# kbps: Kilobytes per second
# mbps: Megabytes per second
# kbit: Kilobits per second
# mbit: Megabits per second
# bps: Bytes per second
# Amounts of data can be specified in:
# kb or k: Kilobytes
@x2c3z4
x2c3z4 / read.go
Created August 12, 2021 15:56 — forked from pfreixes/read.go
Test for checking maximum throughput of random reads over a 40GB file stored in a SSD disk
package main
import (
"fmt"
"math/rand"
"os"
"sync"
"time"
)
@x2c3z4
x2c3z4 / qcamerasvr_wrapper.sh
Created March 19, 2021 10:44 — forked from peat-psuwit/qcamerasvr_wrapper.sh
How to run a daemon and collect ftrace from it. (The example is mm-qcamera-daemon)
#!/system/bin/sh
echo 'function_graph' >/sys/kernel/debug/tracing/current_tracer
echo 96000 > /d/tracing/buffer_size_kb
echo $$ > /sys/kernel/debug/tracing/set_ftrace_pid
echo 1 > /sys/kernel/debug/tracing/tracing_on
(
sleep 10 # stop tracing after this second.
@x2c3z4
x2c3z4 / tasks.json
Created December 25, 2020 06:01 — forked from deadalusai/tasks.json
VS Code tasks.json for Rust/Cargo
/*
Before using this tasks.json you may like to consider trying the VS Code extension, `rust-lang.rust`
Marketplace: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
Source: https://github.com/rust-lang/rls-vscode
*/
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
@x2c3z4
x2c3z4 / Makefile
Created October 17, 2020 03:28 — forked from kwilczynski/Makefile
Makefile for my Go projects (an example).
SHELL := /bin/bash
REV := $(shell git rev-parse HEAD)
CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || true)
TARGET := packer-provisioner-itamae-local
VERSION := $(shell cat VERSION)
OS := darwin freebsd linux openbsd
ARCH := 386 amd64
@x2c3z4
x2c3z4 / Makefile
Created September 17, 2020 07:02 — forked from basharam/Makefile
Makefile template for Static library.
# Makefile template for Static library.
# 1. Compile every *.cpp in the folder
# 2. All obj files under obj folder
# 3. static library .a at lib folder
# 4. run 'make dirmake' before calling 'make'
CC = g++
OUT_FILE_NAME = libNAME.a
add_user(){
echo -e "\033[37;41m给新用户起个名字,不能和已有用户重复\033[0m"
read -p "请输入用户名:" newname
cd /etc/wireguard/
cp client.conf $newname.conf
wg genkey | tee temprikey | wg pubkey > tempubkey
ipnum=$(grep Allowed /etc/wireguard/wg0.conf | tail -1 | awk -F '[ ./]' '{print $6}')
newnum=$((10#${ipnum}+1))
sed -i 's%^PrivateKey.*$%'"PrivateKey = $(cat temprikey)"'%' $newname.conf
sed -i 's%^Address.*$%'"Address = 10.0.0.$newnum\/24"'%' $newname.conf
@x2c3z4
x2c3z4 / README.md
Created December 8, 2018 07:37 — forked from miguelmota/README.md
Multiple accounts with Mutt E-Mail Client (gmail example)

How to set up multiple accounts with Mutt E-mail Client

Thanks to this article by Christoph Berg

Instructions

Directories and files

~/
@x2c3z4
x2c3z4 / delay.sh
Created May 24, 2018 09:40 — forked from digilist/delay.sh
Delaying network traffic to a specific IP
#!/bin/bash
interface=lo
ip=10.0.0.1
delay=100ms
tc qdisc add dev $interface root handle 1: prio
tc filter add dev $interface parent 1:0 protocol ip prio 1 u32 match ip dst $ip flowid 2:1
tc qdisc add dev $interface parent 1:1 handle 2: netem delay $delay
@x2c3z4
x2c3z4 / ss_att2.py
Created July 20, 2017 14:48
Shadowsocks attack
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''
Copyleft (c) 2015 breakwa11
https://github.com/breakwa11/shadowsocks-rss
'''
import logging
import socket