Skip to content

Instantly share code, notes, and snippets.

View haarcuba's full-sized avatar
🎯
Focusing

Yoav Kleinberger, PhD haarcuba

🎯
Focusing
View GitHub Profile
_reset_audio() {
systemctl --user restart pipewire-pulse.service
systemctl --user restart pipewire.service
}
@haarcuba
haarcuba / shell
Created February 3, 2023 15:15
yaml utils
function yaml_validate {
python -c 'import sys, yaml, json; yaml.safe_load(sys.stdin.read())'
}
function yaml2json {
python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read())))'
}
function yaml2json_pretty {
python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read()), indent=2, sort_keys=False))'
class Route:
def __init__(self, cidr):
self._address, mask_bits = cidr.split('/')
mask_bits = int(mask_bits)
self._mask = 0xffffffff & (0xffffffff << (32 - mask_bits))
self._mask_bits = mask_bits
self._address_number = self.number(self._address)
self._hex_address = self._hex4(self._address_number)
def __repr__(self):
@haarcuba
haarcuba / reverse-proxy-nginx.conf
Created December 30, 2016 00:38
nginx reverse proxy
include mime.types;
upstream NAME_OF_SERVICE {
server localhost:1905;
}
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
@haarcuba
haarcuba / java8_on_ubuntu14_04.sh
Created July 25, 2016 13:04
install java 8 on ubuntu 14.04
#!/bin/bash
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
java -version
@haarcuba
haarcuba / lxd.py
Created June 5, 2016 14:37
ansible inventory module that lists lxd containers
#!/usr/bin/env python3
import sys
import subprocess
import re
def containers():
lxcOutput = subprocess.check_output( ['lxc', 'list' ] )
ips = re.compile( '\d+\.\d+\.\d+\.\d+' ).findall( str( lxcOutput ) )
nodes = dict( hosts = ips, vars = { "ansible_user": "root" } )
inventory = dict( nodes = nodes )
@haarcuba
haarcuba / collectd.conf
Created March 23, 2016 23:06
Collectd null write plugin - a write outlet that does nothing (prevents collectd from complaining that is has no write channels)
<LoadPlugin python>
Globals true
</LoadPlugin>
<Plugin python>
ModulePath "/path/to/write_null" # write_null is a folder with an __init__.py inside
LogTraces true
Import "write_null"