Skip to content

Instantly share code, notes, and snippets.

View Fleshgrinder's full-sized avatar
💀

Richard Fussenegger Fleshgrinder

💀
View GitHub Profile
@Fleshgrinder
Fleshgrinder / git-clean-branches
Last active March 25, 2019 07:50
clean git branches
#!/usr/bin/env bash
set -eu
# http://docopt.org/
usage() {
cat << EOT
Clean local branches except for master.
Usage: git-clean-branches [options...]
@Fleshgrinder
Fleshgrinder / windows-setup.ps1
Last active August 23, 2020 06:56
A few commands I routinely execute after setting up a new Windows machine to speed thing up a little and disable annoying stuff.
function dword {
Param([string] $path, [string] $name, [string] $value)
if (!(Test-Path $path)) {
New-Item -Path (Split-Path $path) -Name (Split-Path $path -leaf) | Out-Null
}
New-ItemProperty -Path $path -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
# disables the creation of so called 8dot3names
fsutil 8dot3name set 1 | Out-Null
@Fleshgrinder
Fleshgrinder / gradle
Last active August 30, 2020 18:33
Global script to resolve to the closest available Gradle Wrapper script.
#!/usr/bin/env bash
set -Eeuo pipefail
if command -v jenv &>/dev/null; then
JAVA_HOME=$(jenv javahome)
export JAVA_HOME
fi
if [[ -x gradlew ]]; then
exec ./gradlew "$@"
@Fleshgrinder
Fleshgrinder / pull-request-url.sh
Created June 19, 2018 16:56
Show GitHub link for PR creation after pushing to remote. Store this in `.git/hooks/pre-push` and make it executable.
#!/bin/sh
cat << EOF
Create PR at: https://github.com/$(git remote get-url origin | grep -Eo '[^/:]+/[^/.]+')/compare/$(git rev-parse --abbrev-ref HEAD)?expand=1
EOF
@Fleshgrinder
Fleshgrinder / gpg.sh
Last active May 17, 2021 10:00
Create GPG Key for GitHub Commit Signing
#!/bin/sh
set -eu
#
# Commands for generating a new GPG key for GitHub commit signing.
#
# https://help.github.com/articles/generating-a-new-gpg-key/
#
gpg --full-gen-key
@Fleshgrinder
Fleshgrinder / Nullsafe.ceylon
Created February 19, 2017 17:41
The Case of the Null Reference: Code Listing 4
function f(Integer? x) {
return x?.plus(42);
}
print(f(null));
@Fleshgrinder
Fleshgrinder / Referecnes.php
Created February 19, 2017 14:20
The Case of the Null Reference: Code Listing 3
<?php
class NaturalNumber {
private $n;
public function __construct(int &$n) {
if ($n < 1) {
throw new InvalidArgumentException('n must be greater than zero, got ' . $n);
}
@Fleshgrinder
Fleshgrinder / Main.php
Created February 19, 2017 13:54
The Case of the Null Reference: Code Listing 2
<?php
final class Main {
public static function f(int $x): int {
return $x + 42;
}
}
Main::f(null);
@Fleshgrinder
Fleshgrinder / Main.java
Created February 19, 2017 13:45
The Case of the Null Reference: Code Listing 1
public class Main {
public static void main(String[] args) {
f(null);
}
private static int f(Integer x) {
return x + 42;
}
}
@Fleshgrinder
Fleshgrinder / ssmtp-debian-setup.md
Last active December 19, 2021 11:06
Set up sSMTP on Debian as replacement for sendmail and usage with PHP

sSMTP Debian Setup

The sendmail package, which comes preinstalled with many distros, is often simply too much for a simple server that should not receive emails but rather deliver them. The sSMTP package is a lightweight replacement that does not set up regular cronjobs and only reacts if a subsystem actually wants to send a mail.

Uninstall Sendmail

apt-get purge --yes sendmail*