Skip to content

Instantly share code, notes, and snippets.

@Loriowar
Loriowar / sidekiq@.service
Last active May 14, 2023 13:02
Systemd unit for multiprocess sidekiq. Based on example unit from official sidekiq page on GitHub.
# https://github.com/mperham/sidekiq/blob/master/examples/systemd/sidekiq.service
#
# systemd unit file for CentOS 7, Ubuntu 15.04
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
# - systemctl enable sidekiq
# - systemctl {start,stop,restart} sidekiq
#
@Loriowar
Loriowar / recursive_tmutil.sh
Last active February 25, 2019 14:22
Recursively find directories excluded from Time Machine backup
#!/bin/sh
#NOTE pass a path as a first argument, i.e. `./recursive_tmutil.sh ~/`
find $1 -type directory -exec tmutil isexcluded {} + \
| grep -F "[Excluded]" \
| sed -E 's/^\[Excluded\][[:space:]]*//' \
| awk '{ print length, $0 }' \
| sort -n -s \
| cut -d" " -f2- \
| awk ' { if(length(res) == 0) { res[$0] }; mark=0; for(r in res) { if(match($0, r)== 1){ mark=1; break } }; if(mark==0) res[$0] } END { for (i in res) print i } ' \
@Loriowar
Loriowar / wtf_rails_date.rb
Last active February 1, 2019 10:56
Horrible Rails Date
# Rails 5.0.2
# Ruby 2.4.0p0
> Date.current
=> Fri, 01 Feb 2019
> date = 1.day.ago
=> Thu, 31 Jan 2019 10:13:59 UTC +00:00
> date + 1.month
=> Thu, 28 Feb 2019 10:13:59 UTC +00:00
@Loriowar
Loriowar / dante-fails.conf
Last active August 13, 2018 14:32
Fail2Ban filter for Dante
# Fail2Ban filter for dante
# This filter is for sockd.log, NOT for errors log
#
# Prevent a bruteforce of a login/password combination and some other strange actions.
[INCLUDES]
# Read syslog common prefixes
before = common.conf
[Definition]