Skip to content

Instantly share code, notes, and snippets.

View ABalanuta's full-sized avatar
🎯
Focusing

Artur Balanuta ABalanuta

🎯
Focusing
View GitHub Profile
import sys
import xml.etree.ElementTree as ET
if len(sys.argv) < 2:
print "Usage \n\tpython "+ sys.argv[0]+ " file.xml"
exit()
else:
filename = sys.argv[1]
print "\nUsing file: "+filename+" \n"
@ABalanuta
ABalanuta / Force-MyEduroam5Ghz.sh
Created June 7, 2014 05:03
Force-MyEduroam5Ghz Forces Gnome NetworkManager to connect to the stronngest eduroam AP at 5Ghz
USER="myPcUser"
ID="ist1xxxxx@tecnico.ulisboa.pt"
INTERFACE="wifi0"
PC_MAC="12:34:56:78:90:AB"
CERT_PATH="/home/MY_CERT_PATH/.cacert.pem"
D="/etc/NetworkManager/system-connections/eduroam"
FPATH=$(echo "/tmp/"$(date | sha1sum | awk '{print $1}'))
iwlist $INTERFACE scan | grep '"eduroam"' -B5 | grep "Frequency:5" -A1 -B2 > $FPATH
@ABalanuta
ABalanuta / _etc_modprobe.d_hid_apple.conf
Last active August 29, 2015 14:25
UK International Mac Keyboard Config for ArchLinux
options hid_apple fnmode=2
rocommunity public
#Zpool Usage
extend .1.3.6.1.4.1.2021.88 zpool_name /bin/bash -c "sudo zpool list -H -o name"
extend .1.3.6.1.4.1.2021.88 zpool_snap /bin/bash -c "sudo zpool list -Ho name|for strzpool in `xargs`;do sudo zfs get -rHp -o value usedbysnapshots $strzpool|awk -F: '{sum+=$1} END{print sum}';done"
extend .1.3.6.1.4.1.2021.88 zpool_used /bin/bash -c "sudo zpool list -Ho name|xargs sudo zfs get -Hp -o value used"
extend .1.3.6.1.4.1.2021.88 zpool_data_used /bin/bash -c "sudo zpool list -Ho name|for strzpool in `xargs`;do snap=`sudo zfs get -rHp -o value usedbysnapshots $strzpool|awk -F: '{sum+=$1} END{print sum}'`;pool=`sudo zfs get -Hp -o value used $zpool`; echo $pool $snap|awk '{print (\$1-\$2);}';done"
extend .1.3.6.1.4.1.2021.88 zpool_available /bin/bash -c "sudo zpool list -Ho name|xargs sudo zfs get -Hp -o value available"
extend .1.3.6.1.4.1.2021.88 zpool_capacity /bin/bash -c "sudo zpool list -H -o capacity"
#ARC Usage
@ABalanuta
ABalanuta / ovpn.py
Created February 22, 2016 17:28
Super simple .ovpn file generator for OpenVPN servers without openvpn-as installed to generate it.
import sys, getopt
help = "ovpn.py --host <host> --ca <capath> --crt <certpath> --key <keypath> [--port <port>, --proto <proto>, --options <optionspath>]"
template = """
dev tun
port {{PORT}}
proto {{PROTO}}
remote {{HOST}}
@ABalanuta
ABalanuta / OpenWeatherDevice.py
Last active July 27, 2017 18:46
Fake OpenChirp Weather device
#!/usr/bin/env python2.7
"""Gets Temperature and Humidity values
from api.openweathermap.org using the api key"""
__author__ = "Artur Balanuta"
__version__ = "2.0.1"
__email__ = "arturb [at] andrew.cmu.edu"
import signal
#!/bin/bash
openssl req -new -x509 -keyout yourpemfile.pem -out yourpemfile.pem -days 3650 -nodes
@ABalanuta
ABalanuta / twisted-webserver-ssl-authentication.py
Last active August 29, 2017 02:45
Twisted SSL webserver with basic authentication using plain in-memory passwords. The first argument is the path of the folder to serve; if not provided then the current folder is used (".").
#!/usr/bin/env python3
"""
Twisted SSL webserver with basic authentication using plain in-memory passwords.
The first argument is the path of the directory to serve; if not provided then the current folder is used (".").
INSTALL DEPENDENCIES:
pip install twisted
pip install pyOpenSSL
pip install service_identity
@ABalanuta
ABalanuta / etc default lora-gateway-bridge
Last active November 6, 2017 20:03
lora-gateway-bridge configuration files for the MultiTech Conduit: https://github.com/OpenChirp/docs/wiki/Multitech-Conduit/
# ip:port to bind the UDP listener to (default: "0.0.0.0:1700")
UDP_BIND=127.0.0.1:1700
# mqtt server (e.g. scheme://host:port where scheme is tcp, ssl or ws) (default: "tcp://127.0.0.1:1883")
MQTT_SERVER=tls://openchirp.andrew.cmu.edu:1883
# mqtt prefix
MQTT_PREFIX="<your_openchirp_device_endpoint>"
# mqtt server username (optional)
for i in `ssh -Q cipher`; do dd if=/dev/zero bs=1M count=300 2> /dev/null | ssh -c $i $USER@localhost "(time -p cat) > /dev/null" 2>&1 | grep real | awk '{print "'$i': "300 / $2" MB/s" }'; done
# /etc/ssh/ssh_config (or ~/.ssh/config) and sshd_config
Ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com
#https://turecki.net/content/getting-most-out-ssh-hardware-acceleration-tuning-aes-ni