Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Richard Fussenegger Fleshgrinder

🎯
Focusing
View GitHub Profile
@Fleshgrinder
Fleshgrinder / ufw.sh
Last active Aug 29, 2015
Install and configure UFW firewall on Debian for easy firewall management.
View ufw.sh
#!/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 / purge-logs.sh
Created Sep 1, 2014
Purge /var/log daily cron
View purge-logs.sh
#!/bin/sh
find /var/log -regextype posix-extended -regex '.*\.([0-9]|gz)$' -type f -exec rm -f {} \;
View validate-ocsp-stapling.md

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 Aug 14, 2012
Generate htpasswd compatible password.
View crypt.pl
#!/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 Feb 19, 2017
The Case of the Null Reference: Code Listing 1
View Main.java
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 Feb 19, 2017
The Case of the Null Reference: Code Listing 2
View Main.php
<?php
final class Main {
public static function f(int $x): int {
return $x + 42;
}
}
Main::f(null);
@Fleshgrinder
Fleshgrinder / Referecnes.php
Created Feb 19, 2017
The Case of the Null Reference: Code Listing 3
View Referecnes.php
<?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 Feb 19, 2017
The Case of the Null Reference: Code Listing 4
View Nullsafe.ceylon
function f(Integer? x) {
return x?.plus(42);
}
print(f(null));
@Fleshgrinder
Fleshgrinder / pull-request-url.sh
Created Jun 19, 2018
Show GitHub link for PR creation after pushing to remote. Store this in `.git/hooks/pre-push` and make it executable.
View pull-request-url.sh
#!/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 Aug 16, 2012
mrtg opentracker configuration file
View opentracker.cfg
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