Skip to content

Instantly share code, notes, and snippets.

View derhofbauer's full-sized avatar

Alexander Hofbauer derhofbauer

  • Vienna, Austria
View GitHub Profile
@derhofbauer
derhofbauer / monitoring-monitoring.sh
Created May 29, 2020 08:02
Script to monitor your monitoring tool.
#!/bin/sh
# PING test targets
ping_targets="example.org"
# HTTP STATUS test targets
status_targets="http://example.org:5000"
# Notification recipients
mail_to="arthur.dent@42.galaxy"
@derhofbauer
derhofbauer / concatenation_benchmark.php
Created March 28, 2019 09:02
Compare string concatenation speed to array imploding, when it comes to combining strings
<?php
/**
* I was explaining how strings and arrays are stored differently in RAM to my
* students and I told them, that array imploding is much more efficient than
* traditional string concatenation.
*
* I created this benchmark to prove my point.
*/
@derhofbauer
derhofbauer / brightnessByColor.js
Last active October 10, 2018 14:45 — forked from w3core/brightnessByColor.js
Calculate brightness value by RGB or HEX color
/**
* Calculate brightness value by RGB or HEX color.
* @param color (String) The color value in RGB or HEX (for example: #000000 || #000 || rgb(0,0,0) || rgba(0,0,0,0))
* @returns (Number) The brightness value (dark) 0 ... 255 (light)
*/
function brightnessByColor (color) {
var color = "" + color, isHEX = color.indexOf("#") == 0, isRGB = color.indexOf("rgb") == 0;
if (isHEX) {
var m = color.substr(1).match(color.length == 7 ? /(\S{2})/g : /(\S{1})/g);
if (m) var r = parseInt(m[0], 16), g = parseInt(m[1], 16), b = parseInt(m[2], 16);
@derhofbauer
derhofbauer / moodle_upgrade.sh
Created November 2, 2016 15:51
Bash Moodle Upgrade Script
#!/bin/sh
echo "This script updates your moodle installation."
echo "You will need a few pieces of information to complete this process."
echo ""
echo "Warning: This will disable Web-Access to the moodle installation!"
echo "Make sure nobody is logged in at the moment or activate maintenance mode manually so no data is lost."
echo ""
echo ""
@derhofbauer
derhofbauer / facebook_album_downloader.py
Created October 28, 2016 11:21
Python3 Facebook Album Downloader: Album ID and Graph API Access token are required
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Get an access token here:
# https://developers.facebook.com/tools/explorer/
#
# Get the album id from the url when watching the album
# in your browser.