Skip to content

Instantly share code, notes, and snippets.

@LadyNamedLaura
LadyNamedLaura / coloring.awk
Last active January 10, 2017 10:12
squid coloring
{c="1;1"}
/TCP_MISS/ { c="1" }
/TCP_MEM_HIT/ { c="2;1" }
/TCP_HIT/ { c="2" }
/_UNMODIFIED/ { c="4" }
/_ABORTED/ {c="4;1"}
{print "\033[3"c"m"$0 "\033[0m"}
@LadyNamedLaura
LadyNamedLaura / mm-connect.sh
Created February 22, 2016 07:25
connect (and reconnect) to an lte(mbim) connection and set the network using systemd-networkd
#!/bin/sh
MODEM="$(mmcli -L | grep -o '/org/freedesktop/ModemManager1/Modem/[0-9]*' | head -1)"
BEARER="$(mmcli -m $MODEM --list-bearers | grep -o '/org/freedesktop/ModemManager1/Bearer/[0-9]*' | head -1)"
connect() {
MODEM="$(mmcli -L | grep -o '/org/freedesktop/ModemManager1/Modem/[0-9]*' | head -1)"
mmcli -m $MODEM --simple-connect=apn=web.be,user=web,password=web
BEARER="$(mmcli -m $MODEM --list-bearers | grep -o '/org/freedesktop/ModemManager1/Bearer/[0-9]*' | head -1)"
@LadyNamedLaura
LadyNamedLaura / gitroot
Created February 18, 2016 10:57
gitroot, have git in your root.
#!/bin/sh
export GIT_WORK_TREE=/
if [[ "$1" == "autocommit" ]]
then
git status --porcelain | grep -v '^??' || exit 0
exec git commit -a -m 'autocommit'
fi
exec git $@
@LadyNamedLaura
LadyNamedLaura / get_interface_with.rb
Last active December 23, 2015 04:16
puppet get_interface_with.rb
Puppet::Functions.create_function(:get_interface_with) do
def get_interface_with(tests)
interfaces = closure_scope.lookupvar('networking')['interfaces']
interfaces.each do |ifname, info|
(info.fetch('bindings',[]) + info.fetch('bindings6',[])).each do | binding |
good = true
tests.each do |kind, value|
unless lookupval(info, binding, kind) == value
good = false
@LadyNamedLaura
LadyNamedLaura / Graph.java
Created July 25, 2013 17:48
basic graph implementation
import java.util.HashSet;
import java.util.Set;
public class Graph {
public class Node {
private final Set<Branch> branches = new HashSet<>();
public final String name;
@LadyNamedLaura
LadyNamedLaura / gist:5476637
Created April 28, 2013 11:35
script to monitor and respawn a server
#!/bin/bash
PROGNAME=$0
usage() {
cat <<EOF
usage: $PROGNAME [-n|--name SERVERNAME] [-d|--dir SERVERDIR] cmd [args]
-n, --name name under which the server is logged.
-d, --dir directory with server data
EOF
@LadyNamedLaura
LadyNamedLaura / plot.svg
Last active December 11, 2015 03:38
C implementation of systemd-analyze {time,blame,plot} plot.svg is an example plot produced by this tool (I have no idea why my system creates 134 tty's)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LadyNamedLaura
LadyNamedLaura / P99_THROW_CALL_NEG_ERRNO.patch
Created December 4, 2012 16:19
THROW_CALL macro for use with functions that return a negative errno-style error code
diff -uNr p99-2012-12-03/p99/p99_try.h p99/p99/p99_try.h
--- p99-2012-12-03/p99/p99_try.h 2012-12-03 13:40:29.000000000 +0100
+++ p99/p99/p99_try.h 2012-12-04 17:13:46.116666909 +0100
@@ -345,6 +345,20 @@
#define P00_THROW_CALL_NEG(F, E, ...) \
p00_throw_call_neg(F(__VA_ARGS__), E, p00_unwind_top, P99_STRINGIFY(__LINE__), __func__, #F ", neg return")
+p99_inline
+int p00_throw_call_neg_errno(int p00_neg_errno,
+ errno_t p00_def,
@LadyNamedLaura
LadyNamedLaura / aasprintf.h
Created September 4, 2012 17:07
aasprintf: alloca based asprintf
#include <alloca.h>
#include <stdio.h>
#pragma once
/*
* (v)aasprintf macro:
* alloca based asprintf
*
* usage:
@LadyNamedLaura
LadyNamedLaura / home.automount
Created August 2, 2012 19:11
automount example
# Automatically generated by systemd-fstab-generator
[Unit]
SourcePath=/etc/fstab
DefaultDependencies=no
Conflicts=umount.target
Before=umount.target local-fs.target
[Automount]
Where=/home