Skip to content

Instantly share code, notes, and snippets.

View maesoser's full-sized avatar
:shipit:

Sergio maesoser

:shipit:
View GitHub Profile
@maesoser
maesoser / ntop.sh
Last active August 12, 2019 09:13
Net interfaces throughput top written in bash
#!/usr/bin/env bash
INTERVAL=5
NETPATH="/sys/class/net"
RX1_ARR=()
TX1_ARR=()
RX2_ARR=()
TX2_ARR=()
while true; do
package main
import (
"crypto/ecdsa"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"io/ioutil"
"math/big"
"net/http"
@maesoser
maesoser / tmux.conf
Created April 17, 2019 21:38
Tmux configuration
set -g history-limit 4096
setw -g monitor-activity on
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# THEME
set -g status-bg black
@maesoser
maesoser / config
Created April 9, 2019 21:17
I3 config files
set $mod Mod4
font pango:monospace 9
#font pango:DejaVu Sans Mono 8
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
@maesoser
maesoser / iperf-client.sh
Created April 5, 2019 14:15
Iperf scripts designed to perform throughput tests on ovs.
#!/bin/bash
# Run multiple parallel instances of iperf client
# Assumes iperf servers have been started, e.g.
# iperf -s -p PORT
# Examples:
# Run 5 clients for 60 seconds to server 1.1.1.1
# iperf-multiple-clients 1.1.1.1 5 60 report
# 5 files will be created, report-1.1.1.1-5001-60.txt, ...
#
# Run 7 clients for 20 seconds with UDP
@maesoser
maesoser / pscheck.sh
Created January 4, 2019 08:40
Quick and dirty process monitor, something like Monit
#!/usr/bin/env bash
FAIL='\033[0;31m'
OK='\033[0;32m'
END='\033[0m' # No Color
declare -a arr=("rsyslogd" "crond" "noelement")
## now loop through the above array
for i in "${arr[@]}"
@maesoser
maesoser / ssh_alias.sh
Last active May 27, 2019 14:29
Now it's recommended to use .ssh/config file instead of the old alias approach, but that does not mean that you've to loss the benefits of the aliases like autocompletion.
# copy this code to .bashrc
# This loop generates aliases for the hosts you've configured on ./ssh/config.
for x in $(grep '^Host' ~/.ssh/*config 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-); do
alias "$x"="ssh $x"
done
@maesoser
maesoser / doorwatch.go
Created November 10, 2018 01:09
Door sensor code, both server and client.
package main
import (
"encoding/json"
"fmt"
tb "gopkg.in/tucnak/telebot.v2"
"io/ioutil"
"log"
"math/rand"
"net"
@maesoser
maesoser / far-scp.fish
Created October 16, 2018 13:59
far-ssh and far-scp, when you need to access or copy files through a server acting as a proxy.
function far-scp
if count $argv > /dev/null
echo Connecting through $argv[1]
echo Source: $argv[2]
echo Dest: $argv[3]
scp -oProxyJump=$argv[1] $argv[2] $argv[3]
else
echo " usage: far-scp [proxy-addr] [src] [dst]"
end
end
@maesoser
maesoser / randomize-mac-addresses
Last active October 9, 2018 08:47
Configure every saved WiFi connection in NetworkManager with a spoofed MAC # address, seeded from the UUID of the connection and the date
#!/bin/sh
# /etc/NetworkManager/dispatcher.d/pre-up.d/randomize-mac-addresses
# Configure every saved WiFi connection in NetworkManager with a spoofed MAC
# address, seeded from the UUID of the connection and the date plus the hour eg:
# 'c31bbcc4-d6ad-11e7-9a5a-e7e1491a7e20-2017-11-20-09'
# This makes your MAC difficult to track across WiFi providers, and
# for one provider to track across days.