Skip to content

Instantly share code, notes, and snippets.

View fortitudepub's full-sized avatar
💭
Working focused and make life balancing.

dyz fortitudepub

💭
Working focused and make life balancing.
View GitHub Profile
@fortitudepub
fortitudepub / reply-to-empty-udp.py
Created March 8, 2024 03:11 — forked from jcwarp/reply-to-empty-udp.py
Simple Python UDP echo server
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: David Manouchehri <manouchehri@protonmail.com>
# This script will always echo back data on the UDP port of your choice.
# Useful if you want nmap to report a UDP port as "open" instead of "open|filtered" on a standard scan.
# Works with both Python 2 & 3.
import socket
@fortitudepub
fortitudepub / gist:6d66c57cfaaa3fce933e473c55d5f68a
Created August 9, 2022 06:19
oneliner to dump ipset and sync to vpp
ipset list | tail -n +9 - | xargs -I X vppctl glx overlay route add table 1024 X/32 acc tunnel1 1
@fortitudepub
fortitudepub / gist:74c860329535ddfaf9a089c6bb107191
Created May 26, 2022 10:34
A simle dnsmasq status check and restart when needed because it might listen to tailscale IP.
#!/bin/bash
logger -t "dnsmasqlivecheck" "dnsmasq live check run"
if [[ ! -f /run/dnsmasq/dnsmasq.pid ]]; then
logger -t "dnsmasqlivecheck" "dnsmasq pid not present, restart"
systemctl restart dnsmasq
exit 1
fi
比如:
定义一个单链表,链表上一共有10个节点,每个节点是对应的数字编号(1到10),要求实现从链表尾部打印编号的程序,也即打出的结果是10到1。
要求:
rrdtool create latency_db.rrd \
--step 180 \
DS:pl:GAUGE:540:0:100 \
DS:rtt:GAUGE:540:0:10000000 \
RRA:MAX:0.5:1:500\
#!/bin/bash
#
### set the paths
command="/bin/ping -q -n -c 3"
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.13.1
restart: unless-stopped
hostname: NODE_NAME
ulimits:
memlock:
soft: -1
hard: -1
@fortitudepub
fortitudepub / gist:be8618f595dbfacc503e043a3887e181
Created September 9, 2016 07:58
ovs simple nat extracted from system-traffic.at
# ns0
ip netns del natns0
ip netns add natns0
ip netns exec natns0 ip link set lo up
ip link add natp0 type veth peer name natp0p
ip link set natp0 netns natns0
ip link set natp0p up
ip netns exec natns0 ip link set natp0 up
ip netns exec natns0 ip link set natp0 address 80:88:88:88:88:88
ip netns exec natns0 ip addr add 10.1.1.1/24 dev natp0
@fortitudepub
fortitudepub / shardcalc.py
Created June 24, 2021 11:47 — forked from colmmacc/shardcalc.py
Calculate the blast radius of a shuffle shard
import sys
# choose() is the same as computing the number of combinations. Normally this is
# equal to:
#
# factorial(N) / (factorial(m) * factorial(N - m))
#
# but this is very slow to run and requires a deep stack (without tail
# recursion).
#
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAyANWv5g2/AyV28I+l4Tfk5tnCVdCJt6RMTjMPo7CO3cymvTS
a4IClFR7+ArdpcWHLaNBSZYBn7dOmGKwCdOO8y7/i3P83h4mc+y67BMPsKm7+TKs
Klck/Ssy7cm8mCUs9Y5OuMiX7FDWEf0uzRzwN3OXbb2pU3/iMeD6j48PgTwwVlEu
lgr21GwjvLlBU00iKDH8fwq7NYxLJdhuXc0sbkTEZZcA6kRwfSwq4Q9iY5DGeMkJ
TT1L53XCAax0yUCsX0K3I5vP33RJ/M9GxpWBKYohk6lnHtf4n/Nst+EN7XkL8baf
7g1zTwXkt9FrqJgmyBmCQ1gTKBbjGPy0v2TniwIDAQABAoIBAGlUoM17SpGHyy+U
5sOCfP9N2oAnzLWNhibGw4C6S31nc2X5QgrNx6/3oeVpS3puQJb/H3WyIp7KuQA1
EIHMQL6+ZGM7LNKITDXGWFXUX/HoIQ7F6bbOd7M/ma1yDPiOs1OJotlbAe64T1Pf
4lKwR6zcGcX4GIDZmvQrh6gsbbzfV1v/sVkSUJAWUXs5O7NMTj8UqMDZGx0bv9DX
@fortitudepub
fortitudepub / ddns.sh
Last active March 17, 2020 16:53 — forked from lyoshenka/ddns.sh
Quick and dirty DDNS using Bash and Cloudflare (API v4 compatible)
#!/usr/bin/env bash
# Step 1: Fill in EMAIL, TOKEN, DOMAIN and SUBDOMAIN. Your API token is here: https://www.cloudflare.com/a/account/my-account
# Make sure the token is the Global token, or has these permissions: #zone:read, #dns_record:read, #dns_records:edit
# Step 2: Create an A record on Cloudflare with the subdomain you chose
# Step 3: Run "./ddns.sh -l" to get the zone_id and rec_id of the record you created.
# Fill in ZONE_ID and REC_ID below
# This step is optional, but will save you 2 requests every time you this script
# Step 4: Run "./ddns.sh". It should tell you that record was updated or that it didn't need updating.
# Step 5: Run it every hour with cron. Use the '-s' flag to silence normal output