Skip to content

Instantly share code, notes, and snippets.

### https://www.arduino.cc/en/Reference/Map
### I find this useful
def remap(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
@mrizvic
mrizvic / auth.py
Last active March 10, 2023 12:44
Static password and OTP authentication for OpenVPN in with custom python scripts
#!/usr/bin/env python3
import os
import sys
import datetime
import pyotp
import hashlib
### TO ALLOW ACCSSS CALL sys.exit(0)
### TO DENY ACCESS CALL sys.exit(1)
ip link set up dev p1p1
ip link set up dev p1p2
ip netns add foo
ip netns add bar
ip link add veth0 type veth peer name veth1
ip link set veth1 netns foo
ip link add veth2 type veth peer name veth3
ip link set veth3 netns bar
brctl addbr br0
brctl addif br0 p1p1
@mrizvic
mrizvic / brif
Created February 20, 2016 15:14
Make more brief output of 'ip -o address list'
#!/usr/bin/env python
### Make script executable, copy it to your $PATH somewhere and run: ip -o a | brif
import sys
print '{0: >5} {1: >11} {2: <40}'.format('Index','Iface','IP address')
for line in sys.stdin:
a=line.split(' ')
@mrizvic
mrizvic / ifupscript
Last active February 10, 2016 11:17
he.net dynamic DNS update for IPv6 SLAAC - debian version shell script
#!/bin/sh
# Put this file into /etc/network/if-up.d/
HOSTNAME=my.example.com
PASSWD=keystring
logger -p local0.info -t ifupscript $CMD $IFACE $LOGICAL $ADDRFAM $METHOD $MODE $PHASE
if [ "$IFACE" = "eth0" ] || [ "$IFACE" = "wlan0" ]; then
volatile byte muxCount = 0;
volatile byte mask[16] = {113, 114, 116, 120, 177, 178, 180, 184, 209, 210, 212, 216, 225, 226, 228, 232};
volatile byte ledSegments1[16];
byte n=0;
void setup() {
cli();
DDRD = 255; // sets Arduino pins 0 to 7 as outputs
//timer setup
TCCR1A = 0;
byte muxCount = 0;
byte mask[16]={113,114,116,120,177,178,180,184,209,210,212,216,225,226,228,232};
byte ledSegments1[]={0,0,1,1,0,1,0,1,0,1,0,1,1,0,0,1};
void displayRing(byte input[]) {
if (input[muxCount]) { PORTD = mask[muxCount]; } else { PORTD = 0; }
muxCount = ++muxCount % 16;
}
byte muxCount = 0;
byte lookup[17]={0,1,2,4,8,1,2,4,8,1,2,4,8,1,2,4,8};
void displayRing(byte number) {
byte groupMin = (4 * muxCount) + 1;
byte groupMax = (4 * muxCount) + 4;
byte A = 0;
byte B = 0;
if (number > 0) {
if ( (number >= groupMin) && (number <= groupMax) ) {
@mrizvic
mrizvic / gist:d24233efc76dfdcb9433
Created July 13, 2015 06:34
iptables trick for client to send multiple tcp-syn to connect to service
iptables -N LEVEL1
iptables -N LEVEL2
iptables -N LEVEL3
iptables -N CHECKIN
iptables -N WELCOME
iptables -F LEVEL1
iptables -F LEVEL2
iptables -F LEVEL3
iptables -F CHECKIN
import socket
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class MyHandler(SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/ip':
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()