Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / download_zonefile.rb
Last active August 24, 2019 20:39
Mailinabox Ruby API - Zonefile Generation. Downloads all DNS record from your MAIB instance and write valid zonefiles for easy C&P and Version controlling
require 'bundler/inline'
IGNORE_RECORD_TYPES = ['SSHFP', 'TLSA']
BOX = 'box.yourserver.com'
ADMIN_EMAIL = 'admin@yourserver.com'
gemfile do
source 'https://rubygems.org'
gem 'http'
gem 'tty-prompt', require: 'tty/prompt'
@zealot128
zealot128 / ActiveStorageDocxPreviewer.md
Last active September 18, 2023 11:18
Activestorage Docx Previewer

Docx (and other Office doc) previewer support for ActiveStorage

Converts all document formats using LibreOffice first to PDF and then to an image, using build-in pdf previwer of ActiveStorage

  • needs: unoconv, a command line tool which uses libreoffice, e.g. apt install unoconv
  • needs a PDF converter, because libreoffice will make a pdf from the office document, Mupdf oder Poppler are already integrated into ActiveStorage, and poppler is free to use, e.g. apt install poppler-utils
@zealot128
zealot128 / Bootstrap4migration.md
Last active April 16, 2021 09:01
Bootstrap 3 -> 4 simplistic migration script (Rails based paths and file types)
  1. Run against code base to make the most labor intensive work
  2. Totally redo navigation from scratch
  3. maybe add -xs stuff, like col-xs- or btn-xs, thats missing from BS4
@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 / README.md
Last active July 25, 2023 19:54
Gitlab runner with docker by cloud init on Hetzner Cloud

Quick Terraform script to deploy Gitlab runner with docker onto Hetzner Cloud (Hcloud)

  1. Create other terraform stuff
  • tf-backend,
  • creds.auto.tfvars with hcloud_token
  • ssh key: mkdir keys; ssh-keygen -f id_rsa
  1. modify cloudinit.yml:
  • change gitlab url
  • ADD_YOUR_REGISTRY_TOKEN -> Set to the Gitlab Runner Registration Token
  • Add more allowed images/services, if using gitlab registry, like that: registry.myinstance.com/administrators/docker-images/*, change base image etc.
@zealot128
zealot128 / run.sh
Created December 20, 2018 22:20
pngquant - optimize all png inplace in a folder
find -type f -name '*.png' | xargs -I@ pngquant -f -o '@' '@'
@zealot128
zealot128 / README.md
Last active April 6, 2023 12:14
ActiveStorage migration guide and caveats from Carrierwave (similar starting point for Paperclip)

Migrate Carrierwave to ActiveStorage

Migrate, e.g. organisation.logo (Carrierwave "LogoUploader") to organisation.logo2 (ActiveStorage)

require 'migrate_attachment'
migrate_attachment!(
  klass: Organisation, 
  attachment_attribute: :logo, 
  carrierwave_uploader: LogoUploader, 
<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
@dragover.prevent='dragover'
@dragenter.prevent='dragover'
@drop.prevent.stop='onDrop'
@dragleave.prevent='dragleave')
div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser')
slot
i {{label}}
input(type='file' :multiple='multiple' ref='input' style='display: none')
@zealot128
zealot128 / vornamen.rb
Last active September 24, 2018 09:53
Vornamen finder - Populaere Vornamen (Berliner OpenData) greppen nach Namensbestandteilen, z.B. `ruby vornamen.rb m scha` alle Namen mit scha im Namen.
require 'csv'
unless ARGV.count == 2
puts "USAGE: #{__FILE__} [GENDER: m|f] SEARCH"
end
gender = ARGV[0]
require 'open-uri'
all = []
[
<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
@dragover.prevent='dragover'
@dragenter.prevent='dragover'
@drop.prevent.stop='onDrop'
@dragleave.prevent='dragleave')
div(:class='{ hidden: uploadInProgress }')
slot(ref='slot')
.list-group