Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / db.rake
Last active March 31, 2023 07:11
Rails Rake task for easy Postgres database dumping and cleanup of old dumps
# https://gist.github.com/amit/45e750edde94b70431f5d42caadee423
namespace :db do
DEFAULT_BACKUP_DIR = "#{Rails.root}/tmp/backups"
BACKUP_DIR = ENV['DB_BACKUP_DIR'].presence || DEFAULT_BACKUP_DIR
KEEP = ENV['DB_BACKUP_KEEP'].present? ? ENV['DB_BACKUP_KEEP'].to_i : 7
desc "Dumps the database to backups"
task dump: :environment do
cmd = nil
with_config do |_app, host, db, user, passw, port|
@zealot128
zealot128 / .dockerignore
Last active March 30, 2023 14:35
Mrsk Deployment example
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
# Ignore git directory.
/.git/
# Ignore bundler config.
/.bundle
# Ignore all default key files.
/config/master.key
@zealot128
zealot128 / run.rb
Created February 15, 2023 07:49
Gitlab label priority - fine tuning
# copy script content into ` sudo gitlab-rails console `:
# Gitlab FOSS does only give you the option to Prioritize Labels per project, and only On/Off, no value.
# IT is tiresome to iterate each project and set prioritzed labels, but in the database you can just set an arbitrary Priority Value
# Priority order: Lowest First.
should_be = {
"prio:0" => 5,
"type:bug" => 6,
"prio:1" => 8,
"prio:2" => 9,
@zealot128
zealot128 / FIX_EXIF_DATE.md
Last active February 2, 2023 15:48
Exif DateTimeOriginal Mass-Fix

Mass-Fix EXIF date of photo collection, especially scans, social media files received etc.

If you have your photos correctly sorted in a way:

*/2007-01-01/*.jpg

that script can loop through all and check if the exif DateTimeOriginal matches with the folder.

@zealot128
zealot128 / README.md
Last active January 6, 2023 20:08
Gitlab Autoscaling Infrastructure on Hcloud with internal caching

Order and provision a Hetzner Cloud based Gitlab-Runner Docker-machine autoscaling infrastructure

See my blog for more information.

  • Adjust settings in vars.auto.tfvars.
  • Run with terraform init && terraform apply

Content:

@zealot128
zealot128 / hcloud.rb
Created November 8, 2022 18:18
Obtain hetzner cloud in ansible compatible inventory (script plugin)
#!/usr/bin/env ruby
require 'json'
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
# gem 'pry'
# gem 'toml'
gem 'typhoeus'
end
@zealot128
zealot128 / README.md
Last active October 5, 2022 15:39
Papercut simple replacement = IMAP to print

Papercut replacement

  • imap to print
  • use case: on a Raspi oder Office server that hangs in the same LAN like the printer and can print via cups/system using "lp"
  • just uses lp under the hood
  • uses the awesome mail_room Gem under the hood to handle imap connection, which does most of the lifting

Send Mail as a authorized return-path (via regex matching) to your mailbox, it will print all pdf Attachments.

USAGE

@zealot128
zealot128 / baudit.rb
Last active July 22, 2022 09:15
Batch Bundler-audit a whole directory and bundle update all the affected Gems conservatively
require 'bundler/inline'
# TODO: Skip Auto udpate when not on master or main branch
gemfile do
source 'https://rubygems.org'
gem 'bundler-audit', "~> 0.9"
gem 'pry'
gem 'tty-prompt'
end
@zealot128
zealot128 / PageWithSelectableText.vue
Last active May 2, 2022 02:36
vue-pdf page with selectable text: Usage: <pdf-viewer :pdf-url="pdfUrl" />
<template lang="pug">
.pdf-page--wrapper(:class='{"text-selection": textSelectionEnabled }')
.row.mr-3
.col-sm-3
.col-sm-6.pdf-page--headline {{$t('js.attachment_viewer.page', { page: page })}}
.col-sm-3
.pdf-page--buttons
.btn-group.mr-1(v-if="printable")
button.btn.btn-secondary.btn-sm(type="button" @click="print" data-toggle="tooltip" data-placement="top" :title="$t('js.attachment_viewer.print')")
i.mdi.mdi-printer.mdi-fw
@zealot128
zealot128 / Dockerfile
Last active January 18, 2022 17:15
Basis Docker setup for Rails app (Postgres)
FROM ruby:2.7.1-alpine
ENV BUNDLER_VERSION=2.0.2
RUN apk add --update --no-cache \
binutils-gold \
build-base \
curl \
file \
g++ \