Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / update_hostkeys.sh
Last active February 23, 2024 09:31
Ansible: remove known hostkey from all hosts to fix mismatching host key after host recreation
# Needs jq
hosts=`ansible-inventory --list | awk -F': "' '/ansible_host/ {print $2}' | cut -d'"' -f1`
echo $hosts | xargs -I {} ssh-keygen -R {}
echo $hosts | xargs -I {} ssh-keyscan {} >> ~/.ssh/known_hosts
@zealot128
zealot128 / lspconfig-tailwind-rubyfiles.lua
Last active April 6, 2023 13:20
Neovim Tailwindcss with custom files (Ruby, ViewComponents, Phlex etc.)
local lspconfig = require('lspconfig')
-- https://github.com/tailwindlabs/tailwindcss-intellisense/issues/737
lspconfig.tailwindcss.setup {
--on_attach = on_attach,
--flags = lsp_flags,
filetypes = { "aspnetcorerazor", "astro", "astro-markdown", "blade", "clojure", "django-html", "htmldjango", "edge", "eelixir", "elixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte", "ruby" },
init_options = {
userLanguages = {
- Check out
- install modern terraform version
- ``terraform init``
- get a Hetzner key,
- set it before run: ``` export TF_VAR_hcloud_token=...```
- ``terraform plan``
- ``terraform apply``
@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 / 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 / simple_form.rb
Created August 13, 2022 14:50
Rails simple_form Tailwind Daisy UI config
# frozen_string_literal: true
#
# Uncomment this and change the path if necessary to include your own
# components.
# See https://github.com/heartcombo/simple_form#custom-components to know
# more about custom components.
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
#
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
@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