Skip to content

Instantly share code, notes, and snippets.

View arbal's full-sized avatar
👌
new Adaptor(this); // new Adaptor(_humans[].Behavior);

Arbal arbal

👌
new Adaptor(this); // new Adaptor(_humans[].Behavior);
  • Los Angeles, CA
  • 21:52 (UTC -07:00)
View GitHub Profile
@arbal
arbal / trim-string.sh
Created October 27, 2022 19:22 — forked from x3rAx/trim-string.sh
Trim whitespaces from a string with pure bash
trim_l() {
local str="$1"
if [[ $str =~ ^[[:space:]]*(|[^[:space:]].*)$ ]]; then
str="${BASH_REMATCH[1]}"
fi
echo "$str"
}
trim_r() {
local str="$1"
@arbal
arbal / check_for_dependencies.sh
Created August 26, 2022 16:46 — forked from montanaflynn/check_for_dependencies.sh
Checking for dependencies in a shell script
# Easy way to check for dependencies
checkfor () {
command -v $1 >/dev/null 2>&1 || {
echo >&2 "$1 required";
exit 1;
}
}
checkfor "ffmpeg"
@arbal
arbal / Dockerfile
Created June 8, 2022 08:02 — forked from joemiller/Dockerfile
convert RFC 3164 syslog messages to RFC 5424 for ingestion into Loki/promtail
FROM balabit/syslog-ng:3.35.1
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
@arbal
arbal / discover-chromecast.sh
Created June 1, 2022 17:55 — forked from ThomasRooney/discover-chromecast.sh
Discover Chromecast with devicename via mDNS
#! /bin/sh
if ! which dns-sd > /dev/null
then
echo "Requires dns-sd"
exit
fi
if (( $# < 1 )) ; then
echo "Requires devicename as an argument"
@arbal
arbal / gist:a409eb4d446c68a24d210ef3eb7450ee
Created May 12, 2022 09:31 — forked from crundberg/gist:a77b22de856e92a7e14c81f40e7a74bd
Setup deCONZ on unprivileged Proxmox container

Setup deCONZ on unprivileged Proxmox container

Preparation on host

First find your Conbee with lsusb and note the ID. The vendor is 1cf1 and the product is 0030.

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 1cf1:0030 Dresden Elektronik ZigBee gateway [ConBee II]
Bus 001 Device 003: ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Mistakes to Avoid: Docker Antipatterns

Whichever route you take to implementing containers, you’ll want to steer clear of common pitfalls that can undermine the efficiency of your Docker stack.

Don’t run too many processes inside a single container

The beauty of containers—and an advantage of containers over virtual machines—is that it is easy to make multiple containers interact with one another in order to compose a complete application. There is no need to run a full application inside a single container. Instead, break your application down as much as possible into discrete services, and distribute services across multiple containers. This maximizes flexibility and reliability.

Don’t install operating systems inside Docker containers

It is possible to install a complete Linux operating system inside a container. In most cases, however, this is not necessary. If your goal is to host just a single application or part of an application in the container, you need to install only the essential

@arbal
arbal / gist:acc8ca2c347635a7679badb59e8a572d
Created April 2, 2022 23:51 — forked from jinie/gist:7cbc7035508d32f00b52
Pushover.net notifications with MQTT
#!/usr/bin/env python3
import paho.mqtt.client as paho
import http.client, urllib
import argparse
import logging
import json
import sys
def parse_message(self, message):
@arbal
arbal / apropos.fish
Created March 16, 2022 20:34 — forked from folke/apropos.fish
Using `apropos` on macos rebuilds the whatis database every time. Fish shell uses apropos for command completion.
# Fixes extremely slow apropos command on macos
# Using `apropos` on macos rebuilds the whatis database every time.
# Fish shell uses apropos for command completion.
# Simply add the file below to `~/.config/fish/conf.d` to fix the issue
set db ~/.whatis.db
function apropos_update
echo "Updating apropos / whatis database at $db"
man --path | tr ":" " " | xargs /usr/libexec/makewhatis -o $db
@arbal
arbal / config.json
Created March 1, 2022 16:48 — forked from madic-creates/config.json
Alerta with traefik
{"endpoint": "http://172.18.10.60/alerta/api"}
@arbal
arbal / parse_query.sh
Created February 23, 2022 19:08 — forked from pablochacin/parse_query.sh
A one liner to parse a http query string in bash
#
# the following one liner creates a shell variable from every parameter in a
# the query string in the variable QUERY, of the form p1=v1&p2=v2,... and sets it to
# the corresponding value so that parameters can be accessed by its name $p1, $p2, ...
#
for p in ${QUERY//&/ };do kvp=( ${p/=/ } ); k=${kvp[0]};v=${kvp[1]};eval $k=$v;done