Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / crontab.cron
Created October 18, 2016 20:42
Omnibus Gitlab backup cronjob
# Crontab
# once per week backup, move to "/backup" gzip it, delete everything but the latest 5 files
0 4 * * 1 /opt/gitlab/bin/gitlab-ci-rake gitlab:backup:create CRON=1 && mv /var/opt/gitlab/backups/* /backup/ && cd /backup && gzip *.tar && rm `ls -t | awk 'NR>5'`
@zealot128
zealot128 / run.rb
Created April 6, 2017 09:44
gitlab stats
# RAILS_ENV=production bundle exec rails r run.rb
puts "All Time:"
puts "-------------------"
puts "Number of successful deploys into production:"
puts Ci::Pipeline.where(ref: 'master').where(status: 'success').count
puts "Number of commits over all projects (no forks)"
puts Project.all.reject{|p| p.forked? }.map{|i| i.statistics.commit_count }.sum
puts "Number of issues"
@zealot128
zealot128 / filter.js
Created May 9, 2017 14:19
Vue2 filter thousand seperator / rounded (german comma)
Vue.filter('formatNumber', function (value) {
const rounded = Math.round(value * 100) / 100
return rounded.toString().replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, ".");
});
@zealot128
zealot128 / ldap.sh
Created July 14, 2017 12:52
Change LDAP/Samba account information from command line
# Use ldapmodify and copy carefully
# 1. Unblock user - set expiration to never:
$ ldapmodify -H 'ldaps://pdc.mycompany.com:636' -D 'cn=Administrator,cn=Users,dc=pdc,dc=pludoni,dc=com' -x -W
Enter LDAP Password:
dn: CN=Firstname Lastname,CN=Users,DC=pdc,DC=pludoni,DC=com
changetype: modify
replace: accountExpires
accountExpires: 9223372036854775807
<Ctrl+D>
@zealot128
zealot128 / README.md
Created October 8, 2017 20:14
ffmpeg cut of from start and back - ruby convert script

Cut of from start/back of file

Useful for postprocessing various youtube videos with jingles/ad "follow us" stuff at the end.

ffmpeg has an easy way to cut off from beginning, but not to say "cut of 20s from the end". So one has to use to do arithmetics with duration. Here, using ruby script.

USAGE

@zealot128
zealot128 / fix.sh
Created April 3, 2018 09:46
Fix out of space problem after unattended upgrades clogged up boot with linux kernel images
sudo apt-get autoremove;sudo apt-get autoclean;sudo apt-get clean
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
sudo apt-get update && sudo apt-get upgrade
# source: https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1357093/comments/111
@zealot128
zealot128 / README.md
Created June 2, 2018 15:21
Strava personal heatmap
@zealot128
zealot128 / rails_5.2-fixes.md
Last active June 4, 2018 10:25
Rails 5.2. be_success -> be_successful

Rails 5.2. be_success -> be_successful

using ag or fgrep

sed -i 's/be_success$/be_successful/g' `ag be_success$ spec -l`

image_tag resolver

@zealot128
zealot128 / vimrc.vim
Last active June 19, 2018 11:43
VIM replace ruby 1.9 Hash literals to 2+
command! ReplaceRuby19Hash :%s/:\([a-z_]\+\) *=> */\1: /
@zealot128
zealot128 / README.md
Last active June 21, 2018 08:30
Ruby: check for domain name certificate expirations (supports starttls smtp and tls/https)

Check

check for domain tls certificate expirations.

Pass any number of domain:port pairs to the program, it will try to fetch all and present a little table with the soonest to expire on top.

On port 25 it will use Starttls for validation, otherwise SNI TLS.

ruby check.rb my.domain.de www.domain.de mail.domain.de:25 pop.domain.de:995