Skip to content

Instantly share code, notes, and snippets.

View glaszig's full-sized avatar

glaszig

  • available for hire. contact me.
  • remote
View GitHub Profile
@glaszig
glaszig / if_.patch
Created August 2, 2016 22:11
munin 2.0.19 if plugin patch
--- if_.orig 2016-08-02 23:52:05.691224811 +0200
+++ if_ 2016-08-02 23:52:49.563223127 +0200
@@ -91,7 +91,7 @@
# iwlist first)
if [[ -r /sys/class/net/$INTERFACE/speed ]]; then
SPEED=$(cat /sys/class/net/$INTERFACE/speed 2>/dev/null)
- if [[ -n "$SPEED" ]]; then
+ if [ -n "$SPEED" -a "$SPEED" -gt "0" ]; then
echo $SPEED
return
@glaszig
glaszig / mkp2pblocklist
Last active January 30, 2022 00:30
creates a blocklist for your p2p endeavors
#!/usr/bin/env sh
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2020 glaszig <glaszig@gmail.com>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#!/usr/bin/env sh
set -e
HOME_DIR="/home/git"
WWW_DIR="/usr/local/www/gitweb"
REPOS_PATH="$HOME_DIR/repositories"
GITWEB_CONF="/etc/gitweb.conf"
GITWEB_PATH="/usr/local/share/examples/git/gitweb"
BANNER="# created by bootstrap script. manual changes might get lost."
@glaszig
glaszig / test_helper.rb
Created October 15, 2018 19:43
Method to set value of range input field with Capybara
class ActionDispatch::IntegrationTest
# usage: set_range "My Range Field", to: 42
# this also triggers the input's change and/or input events
# as opposed to find_field("My Range Field").set 42
def set_range(locator = nil, to:, **find_options)
find_field(locator, find_options).execute_script %Q(this.value = "#{to}")
end
end
@glaszig
glaszig / regexp_escape.py
Created October 21, 2018 01:17
Jinja plugin (for use with Ansible) to run re.escape against input
# (c) 2018, glaszig@gmail.com
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the MIT license.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MIT License for more details.
#
@glaszig
glaszig / setup.rb
Created October 31, 2018 00:47
quick and dirty dev setup for macos
#!/usr/bin/env ruby
require 'open3'
ENV["HOMEBREW_NO_AUTO_UPDATE"] = "1"
ENV["HOMEBREW_INSTALL_URL"] ||= "https://raw.githubusercontent.com/Homebrew/install/master/install"
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
@glaszig
glaszig / gitea-backup-s3.sh
Last active January 24, 2020 15:23
FreeBSD Gitea backup to AWS S3
#!/usr/bin/env sh
#
# requires openssl >= 1.1.1 due to usage of -pbkdf2 option
#
# to decrypt the encrypted backup:
# openssl aes-256-cbc -d -a -salt -pbkdf2 -in gitea-dump.zip.enc -out gitea-dump.zip -pass pass:your-password
#
# conifgure with a dotfile `.backuprc` in your $HOME:
# BUCKET="foobar"
# GITEA_CUSTOM=/usr/local/etc/gitea
@glaszig
glaszig / curl_action_mailbox.md
Last active June 27, 2023 08:53
rails' action mailbox without installing rails on your mail server

forward email to action mailbox without installing rails

rails provides [rake tasks][rake] to forward mails to [action mailbox][actionmailbox]'s [relay ingress][postfix]. that's fine unless you have your mail server(s) on another system and don't want to install rails (and all dependencies, i.e. the ruby runtime).
since the rake tasks basically just [upload stdin to your rails app via http][relayer] you can do everything with curl.

action-mailbox-relayer.sh

#!/usr/bin/env sh
curl -sS -u "actionmailbox:$INGRESS_PASSWORD" \
@glaszig
glaszig / fswatch-scp.sh
Last active August 17, 2023 11:13
use fswatch to scp changed files to remote host
#!/usr/bin/env sh
# Copyright 2020 glaszig
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "activerecord", "6.1.0"