Skip to content

Instantly share code, notes, and snippets.

View mmichaa's full-sized avatar

Michael Nowak mmichaa

  • Ventschau, Germany
  • 02:17 (UTC +02:00)
View GitHub Profile
@mmichaa
mmichaa / check_heartbeat.sh
Last active May 10, 2023 08:24
heartbeat.sh check for Icinga2
#!/bin/bash
# SEE: https://stackoverflow.com/a/29754866/888294
# More safety, by turning some bugs into errors.
# Without `errexit` you don’t need ! and can replace
# ${PIPESTATUS[0]} with a simple $?, but I prefer safety.
set -o errexit -o pipefail -o noclobber -o nounset
# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
@mmichaa
mmichaa / config-environments-test.rb
Created August 27, 2020 09:44
Hack: PostgreSQL unlogged tables with Rails v5.2
Rails.application.configure do
# …
# SEE: https://prathamesh.tech/2020/08/10/creating-unlogged-tables-in-rails/
# SEE: config/initializers/active_record_postgresql_create_unlogged_tables_patch.rb
config.to_prepare do
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = true
end
end
@mmichaa
mmichaa / spdns-client.py
Last active July 15, 2016 06:25
spdns-client.py -- spDNS update script written in python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Usage:
# spdns-client.py <hostname> <user> <passwd>
#
# With xargs and arguments-file:
# xargs -a spdns-client.args -n 3 spdns-client.py
#
# Copyright 2013 -- Michael Nowak
@mmichaa
mmichaa / DevEnvToggle.applescript
Created March 16, 2013 21:56
DevEnvToggle -- AppleScript for starting up and shutting down my Development Environment (Apache, MySQL, PostgreSQL) on Mac OS X.
script Service
property service_name : null
property service_state : null
on start_pre()
-- start pre-action here
end start_pre
on start_up()
tell me to start_pre()
@mmichaa
mmichaa / gemfile_helper.rb
Last active December 14, 2015 07:19
Paste this code snippet into your Gemfile. It let's you easily define gems for certain OSes.
=begin
Paste this code snippet into your Gemfile. It let's you easily define gems for certain OSes using gem_for_darwin, gem_for_linux or gem_for_windows as gem-statement, e. g.
# notifications for file changes
gem_for_osx 'rb-fsevent', :platforms => :ruby
gem_for_linux 'rb-inotify', :platforms => :ruby
gem_for_windows 'rb-fchange', :platforms => [:mswin, :mingw]
# console color for windows
gem_for_windows 'win32console', :platforms => [:mswin, :mingw]