Skip to content

Instantly share code, notes, and snippets.

View Fleshgrinder's full-sized avatar
💀

Richard Fussenegger Fleshgrinder

💀
View GitHub Profile
@Fleshgrinder
Fleshgrinder / purge-logs.sh
Created September 1, 2014 14:15
Purge /var/log daily cron
#!/bin/sh
find /var/log -regextype posix-extended -regex '.*\.([0-9]|gz)$' -type f -exec rm -f {} \;
@Fleshgrinder
Fleshgrinder / ufw.sh
Last active August 29, 2015 14:05
Install and configure UFW firewall on Debian for easy firewall management.
#!/bin/sh
# Install ufw and its dependencies.
export DEBIAN_FRONTEND=noninteractive
aptitude install -q -y ufw
# SEE: https://serverfault.com/questions/416727
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Configure ufw to allow SSH, HTTP and HTTPS and enable it.
@Fleshgrinder
Fleshgrinder / validate-ocsp-stapling.md
Last active December 26, 2015 01:49
Validate OCSP Stapling

One can use OpenSSL’s c_client to validate that OCSP Stapling is working.

openssl s_client -connect 127.0.0.1:443 -tls1 -tlsextdebug -status
@Fleshgrinder
Fleshgrinder / crypt.pl
Created August 14, 2012 14:16
Generate htpasswd compatible password.
#!/usr/bin/perl
use strict;
chomp(my $filename=$ARGV[0]);
chomp(my $username=$ARGV[1]);
chomp(my $password=$ARGV[2]);
if (!$filename || !$username || !$password) {
print "USAGE: ./crypt.pl filename username password\n\n";
} else {
@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 / 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 / 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 / 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 / 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 / opentracker.cfg
Created August 16, 2012 23:50
mrtg opentracker configuration file
enableIPv6: no
WorkDir: /var/www/tracker/
Options[_]:
YSize[_]: 150
pagetop[tracker-conn]: <h1>tracker - Connections/min</h1><hr>
target[tracker-conn]: `curl http://localhost:6969/stats?mode=conn`
maxbytes[tracker-conn]: 100000000
title[tracker-conn]: Connections/min
options[tracker-conn]: growright, nopercent, perminute