Skip to content

Instantly share code, notes, and snippets.

glaszig

Block or report user

Report or block glaszig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@glaszig
glaszig / curl_action_mailbox.md
Last active Oct 15, 2019
rails' action mailbox without installing rails on your mail server
View curl_action_mailbox.md

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 Apr 2, 2019
FreeBSD Gitea backup to AWS S3
View gitea-backup-s3.sh
#!/usr/bin/env sh
#
# to decrypt the encrypted backup:
# openssl aes-256-cbc -in gitea-dump.zip.enc -out gitea-dump.zip -d -a -pass pass:your-password
#
# conifgure with a dotfile `.backuprc` in your $HOME:
# BUCKET="foobar"
# GITEA_CUSTOM=/usr/local/etc/gitea
# BACKUP_PASSWORD="your-password"
#
@glaszig
glaszig / setup.rb
Created Oct 31, 2018
quick and dirty dev setup for macos
View setup.rb
#!/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 Oct 21, 2018
Jinja plugin (for use with Ansible) to run re.escape against input
View regexp_escape.py
# (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 Oct 15, 2018
Method to set value of range input field with Capybara
View test_helper.rb
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
View git-jail-bootstrap.sh
#!/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 / mkp2pblocklist
Last active Jan 21, 2019
creates a blocklist for your p2p endeavors
View mkp2pblocklist
#!/usr/bin/env sh
# inspired by https://gist.github.com/johntyree/3331662#gistcomment-1968023
#
# usage:
# mkp2pblocklist > /tmp/blockp2p.list
# or
# mkp2pblocklist | gzip -9 > /tmp/blockp2p.list.gz
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH"
@glaszig
glaszig / if_.patch
Created Aug 2, 2016
munin 2.0.19 if plugin patch
View if_.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 / hex_benchmark.rb
Last active Jun 20, 2016
ruby hex encode algorithm performance comparison
View hex_benchmark.rb
require 'benchmark'
ITERATIONS=100_000
INPUT='https://www.example.com/path/to/image.png'.freeze
def interpolate
INPUT.to_enum(:each_byte).map{ |byte| "%02x" % byte }.join
end
def unpack
@glaszig
glaszig / rails-vendor-assets.patch
Created Jun 7, 2016
example of have a precompiled vendor asset
View rails-vendor-assets.patch
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 722b3a8..e32d6db 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -4,6 +4,7 @@
<title>AssetsDemo</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
+ <%= javascript_include_tag 'jquery.mousewheel', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
You can’t perform that action at this time.