Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / convert_vue_html_to_pug.rb
Created September 29, 2020 14:54
Automatically convert vue sfc with default html into pug using an API
#!/usr/bin/env ruby
require 'bundler/inline'
# Usage: just ruby with a recentish ruby (2.4+) and bundler inline should download necessary gems
# The conversion is done by https://html2pug.now.sh/convert
# - This script is a wrapper that walks a tree of *.vue files and converts the inner <template>
# - The script is interactive and ask before saving each file
#
# - Note: <UpperCase> custom components become upper-case() in pug
# - Note: the remote api seems to have problems with ternary inline code in html attributes
@zealot128
zealot128 / bootstrap-vue-import-statement-migration.sh
Created September 22, 2020 09:34
Bootstrap-vue import statement migration
# I am using sd, which has a more standard Regexp syntax than find/sed and works great
# This script changes all occurences from:
# import bFormGroup from 'bootstrap-vue/es/....
# import bModal from ....
#
# to ->
#
# import { BFormGroup, BModal } from 'bootstrap-vue'
#
# adjust the paths, this is a rails app, so everything is in app/javascript
@zealot128
zealot128 / gitlab_move_issues_to_new_milestone.rb
Created September 10, 2020 08:49
Gitlab: Move all issues on a (closed) milestone to a new one
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'gitlab'
gem 'pastel'
gem 'tty-prompt'
end
require 'tty-prompt'
require 'pastel'
@zealot128
zealot128 / gitlab_auto_close_mrs.rb
Created September 10, 2020 08:43
Gitlab: Auto-Close all empty stale Merge-Requests
# Auto-Close all open MR's that:
# - are created before 3 months
# - have NO changes (no commits pushed)
# - has a issue attached that is already closed
#
# Background: Gitlab makes it easy to create a MR for a issue via button.
# But sometimes that branch becomes stale and the issue will be moved/fixed differently
#
# Afterwards, also triggers a Remove Merged Branches Job
# DANGER: Use on your own discretion
@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 / elasticsearch_move_all_shards.sh
Last active November 23, 2021 14:39
Elasticsearch: migrate ALL shards from a master node to other nodes (e.g. mark all shards to move to other node before shutting down)
#!/bin/bash
# cluster
server="10.10.10.153:9200"
# new master node name
target="node123"
# fetch all index names
indices=`curl $server/_cat/indices?h=index`
@zealot128
zealot128 / Rails-application-generator-template.md
Last active January 17, 2020 20:08
Rails application template that I use - based on rails_composer
rails new -m https://gist.github.com/zealot128/b70b95c0d665e95647c210808b614a51/raw/ad5aba858c5a9da559b5717015e59392856614b2/composer.rb new_app_name
  • Less interaction than original composer script (no example templates)

Default choices that I use:

 prefs[:dev_webserver] = 'puma'
@zealot128
zealot128 / gist:736de424147789330575509354a53e97
Created December 2, 2019 12:35
Ubuntu 18.04 ttf-mscorefonts-installer fails with redirection forbidden
wget http://ftp.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.7_all.deb
dpkg -i ttf-mscorefonts-installer_3.7_all.deb
@zealot128
zealot128 / gitlab_migrate.sh
Last active December 29, 2023 21:59
Gitlab migrate omnibus installation to new server
#!/bin/bash
# ATTENTION: COPY&PASTE RUN EVERY LINE BY HAND AND VERIFY THE OUTPUT
# the old host, must have direct ssh access
# generate ssh-keygen on new host and copy over into authorized_keys
gitlab='root@1.2.3.4'
# Stopping everything on remote system
echo "$gitlab - Gitlab Stop"
ssh $gitlab "gitlab-ctl stop nginx"
@zealot128
zealot128 / vue_i18n_scanner.rb
Created September 24, 2019 07:19
Vue-i18n + ruby i18n-tasks unused scanner
require 'i18n/tasks/scanners/file_scanner'
# finds v-t="" and $t/$tc usages and prefixed that usages with the given prefix, e.g.
# so i18n-tasks unused / i18n-tasks missing will work and scan vue files correctly
# LIMITATIONS:
# - no advanced v-t="{ ... }" syntax supported
# - of course, no dynamic loading of $t(some_data_property) does not work
class VueI18nScanner < I18n::Tasks::Scanners::FileScanner
include I18n::Tasks::Scanners::OccurrenceFromPosition