Skip to content

Instantly share code, notes, and snippets.

@abrahamvegh
abrahamvegh / named.conf.options
Created December 21, 2020 00:04
BIND ACL for use with Linode’s AXFR service
acl "linode"
{
// Dallas
// axfr1.linode.com
104.237.137.10;
2600:3c00::a;
// Fremont
// axfr2.linode.com
65.19.178.10;
@abrahamvegh
abrahamvegh / unifi_ssl_import.sh
Last active October 9, 2016 01:48 — forked from stevejenkins/unifi_ssl_import.sh
Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems
#!/usr/bin/env bash
# unifi_ssl_import.sh
# UniFi Controller SSL Certificate Import Script for Unix/Linux Systems
# by Steve Jenkins <http://www.stevejenkins.com/>
# modified by Abraham Vegh <https://abrahamvegh.com>
# Incorporates ideas from https://source.sosdg.org/brielle/lets-encrypt-scripts
# Version 3.0
# Last Updated October 8, 2016
@abrahamvegh
abrahamvegh / keybase.md
Created April 28, 2015 17:08
keybase.md

Keybase proof

I hereby claim:

  • I am abrahamvegh on github.
  • I am abrahamvegh (https://keybase.io/abrahamvegh) on keybase.
  • I have a public key whose fingerprint is A7AA F5D7 347C D58C 296F FA46 3ABF D2D0 C39E 7551

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am abrahamvegh on github.
  • I am abrahamvegh (https://keybase.io/abrahamvegh) on keybase.
  • I have a public key whose fingerprint is 8055 1386 B8BF BC26 303D 82E7 6ADC DEC7 D423 9579

To claim this, I am signing this object:

@abrahamvegh
abrahamvegh / namespaces.php
Created June 26, 2013 02:51
You can't explain that.
<?php
namespace SDM\DB
{
class MySQL
{
public function __construct ()
{
echo 'MySQL->__construct()', "\n";
}
}
# Requirements:
# 1. No www.
# 2. Always SSL.
# 3. Full IPv4 and IPv6 compatibility.
#
# If you can do better than this, feel free to improve.
# The server in question only serves a single domain.
# Pesky version strings
server_tokens off;
@abrahamvegh
abrahamvegh / hesitant.php
Last active December 14, 2015 05:39
Hesitant?
<?
define('HESITANT', preg_match('/^hesitant/', $_SERVER['HTTP_HOST']));
function hesitant ($m, $a = NULL) { return HESITANT ? $m : (is_null($a) ? '' : $a) ; }
@abrahamvegh
abrahamvegh / json_headers.php
Last active December 14, 2015 00:39
Return received HTTP headers as JSON
<?
function normalize_header_name ($name)
{
$name = substr($name, 5);
$name = str_replace('_', '-', $name);
$name = strtolower($name);
return $name;
}
@abrahamvegh
abrahamvegh / certificate.sh
Last active February 4, 2020 19:44
Commonly-used PKI functions
# Check certificate expiration date
openssl x509 -in certificate.pem -noout -enddate
# Create new ECC key and CSR
openssl ecparam -out private.key -name prime256v1 -genkey
chmod 400 private.key
openssl req -new -key private.key -out csr.txt -subj '/CN=domain.tld'
# Create new RSA key and CSR
openssl req -out csr.txt -new -newkey rsa:4096 -sha256 -nodes -keyout private.key -subj '/CN=domain.tld' > /dev/null 2>&1
@abrahamvegh
abrahamvegh / gist:4630846
Last active December 11, 2015 16:58
Some 100% generic rewrite rules for enforcing desired URL and HTTPS modes.
RewriteEngine on
# Force No-WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]