Skip to content

Instantly share code, notes, and snippets.

View hettiger's full-sized avatar

Martin Hettiger hettiger

View GitHub Profile
@hettiger
hettiger / README.md
Last active February 1, 2020 14:58
~/Developer Directory Structure

Developer

A directory where all the source code lives. Do not put any additional project files in here.
Instead organize such files under ~/Documents.

Suppose you have a directory for additional project files ~/Documents/…/Some\ Project:

It is advisable to create a symlink pointing to the corresponding source code directory.
You should also add a .url file that is linking to the corresponding repository on GitHub or the like.

@hettiger
hettiger / rgb-to-hsl.ts
Created November 8, 2018 23:08
RGB to HSL
/**
* @see https://de.wikipedia.org/wiki/HSV-Farbraum#Umrechnung_RGB_in_HSV/HSL
*/
private convertRgbToHsl(rgbColor: { r: number; g: number; b: number; }): { h: number; s: number; l: number; } {
let h: number;
let s: number;
let l: number;
let { r, g, b } = rgbColor;
[ r, g, b ] = [ r, g, b ].map((value) => value / 255);
@hettiger
hettiger / check-replication-status
Last active January 21, 2024 22:28
Monitor MariaDB replication
#!/bin/bash
##
# Configuration
##
MASTER_SERVER_ADDRESS="_ENTER_YOUR_LAPTOP_IP_HERE_"
MAILFROM="_ENTER_FROM_EMAIL_HERE_"
MAILTO="_ENTER_TO_EMAIL_HERE_"
@hettiger
hettiger / example.css
Created March 1, 2015 14:22
Absolute Center
.example {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
@hettiger
hettiger / foo.less
Last active August 29, 2015 14:16 — forked from anonymous/foo.less
Gulp: Less + Prefixing + Minify
// Initialize ... (just an example)
@import "components/normalize";
@import "variables";
@import "mixins";
// Load optional components
@hettiger
hettiger / macros.php
Created August 20, 2014 12:37
Laravel: Form::selectTime()
<?php
// Path: app/macros.php (required once in app/start/global.php)
Form::macro('selectTime', function($name, $low, $high, $unit, $options = [], $selected = null, $step = 1)
{
if ( ! Lang::has('options.' . $unit) )
{
throw new InvalidArgumentException('Failed finding a translation for the provided unit.');
}
@hettiger
hettiger / hosts.md
Last active August 29, 2015 14:02
Good Hosts
7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)
0 = 0 (no permission)
chmod 124 /file
@hettiger
hettiger / smooth-scroll.js
Last active May 29, 2019 14:14
Simple smooth scrolling with jQuery :-)
$(function () {
$("nav").find("a[href*=#]:not([href=#])").click(function () {
var offset = 0;
var speed = 1000;
var target = $(this.hash);
$("html,body").animate({
scrollTop: target.offset().top - offset
}, speed);
});