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 / plugin.js
Last active August 11, 2023 19:07
tom-select flexbox options plugin
/**
* tom-select plugin that wraps each select option in a flexbox to improve layout.
* made explicitly to use in combination with checkbox_options plugin.
*
* required css:
*
* .ts-option-wrapper {
* display: flex;
* align-items: center;
* }
@glaszig
glaszig / mkm3u.sh
Created June 29, 2022 04:47
generate m3u from directory
#!/usr/bin/env sh
# generates extended m3u for all media files in a directory.
#
# requirements: ffprobe (ffmpeg)
# usage: $0 path/to/media/files [playlist.m3u]
# author: mail@glasz.org
# license: wtfpl - http://www.wtfpl.net/txt/copying/
set -e
# 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"
@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:
@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 / 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 / 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 / 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 / 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
#!/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."