Skip to content

Instantly share code, notes, and snippets.

View digitalresistor's full-sized avatar
🔒
ALL THE THINGS!

Delta Regeer digitalresistor

🔒
ALL THE THINGS!
  • ::1
View GitHub Profile
class Counter:
def __init__(self, high):
self.current = 0
self.highest = high
# This class is now considered and iterable because of this special function
def __iter__(self):
return self
def next(self):
@digitalresistor
digitalresistor / uwsgi-betatest.ini
Created October 8, 2014 02:11
uwsgi-betatest.ini
###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
###
[app:main]
use = egg:betatest
pyramid.reload_templates = false
pyramid.debug_authorization = false
@digitalresistor
digitalresistor / getaddrinfo.c
Created September 3, 2014 16:54
Quick and dirty program to get addrinfo.
// compile: clang -o getaddrinfo getaddrinfo.c
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
@digitalresistor
digitalresistor / gist:f49c4a8dc704a2f2d473
Created July 12, 2014 01:49
LibreSSL 2.0.0 vs OpenSSL 1.0.1e AES speed test
LibreSSL 2.0.0
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 147114.19k 155335.27k 158465.37k 158492.19k 159312.55k
aes-192 cbc 130243.58k 134851.41k 137229.74k 137544.84k 137448.55k
aes-256 cbc 114115.03k 119026.45k 120752.73k 121288.02k 120809.17k
OpenSSL 1.0.1e-freebsd 11 Feb 2013
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 96200.01k 102593.60k 104926.04k 270259.51k 272067.04k
aes-192 cbc 81196.22k 85284.99k 87320.82k 228529.87k 231628.80k
@digitalresistor
digitalresistor / redir.sh
Last active November 13, 2016 18:43
Simple script that prints a list of redirects, and what the final HTTP result was...
function count_redir {
curl -L -I -D - -o /dev/null $1 | awk 'BEGIN { redir = 0; status = 200; } tolower($1) ~ /http/ { redir=redir+1; status=$2 } tolower($1) ~ /location:/ { print redir, status, $2 } END { print "Completed, with ", redir-1, "redirects. Final result: ", status }'
}
@digitalresistor
digitalresistor / drupaltoblogofile.py
Created April 25, 2014 00:59
I needed a quick way to import all the nodes from Drupal, dump em into a Blogofile compatible format to move from Drupal to a static site generator.
#!/usr/bin/env python
"""
Drupal to Blogofile convertor
-----------------------------
Usage:
1. Create virtualenv
@digitalresistor
digitalresistor / Alias_domains_vimbadmin.md
Last active November 4, 2015 22:25
Being able to have full alias domains with ViMbAdmin is fairly handy, in that it allows people to have multiple domains forward to a single domain. This isn't supported out of the box with ViMbAdmin, and thus needs to be kind of hacked in... I am using Postfix + with Dovecot for virtual mail delivery

After updating your main.cf and your Dovecot configuration you can now add alias domains to ViMbAdmin:

  1. Create new domain example.net which we want to alias to example.com
  2. Create new alias on example.net named *@example.net that forwards to *@example.com
  3. Test send an email to [email protected] and [email protected] and verify both messages are delivered successfully to [email protected]

Users can log in to Dovecot (IMAP/POP3/SMTP AUTH) using either example.net or example.com. If login fails to find the username/password combo on the first try, it will attempt to look it up in the alias table, and allow login if that succeeds. This way users can configure their mail clients however they please.

@digitalresistor
digitalresistor / mysql-server-multi
Created April 2, 2014 00:21
Sometimes there is a requirement to run multiple different MySQL servers on the same FreeBSD host, this makes it possible to create profiles to run different MySQL servers with different database paths/settings.
#!/bin/sh
#
# PROVIDE: mysql
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable mysqlmulti:
#
# mysqlmulti_enable (bool): Set it to "YES" to enable uwsgi
# Default is "NO".
@digitalresistor
digitalresistor / myauthpolicy.py
Created October 29, 2013 04:02
Mah auth policy for Pyramid =)
# Let it be known that this code was written by the very awesome and talented @mmerickel
#
# Thanks! Much appreciated.
class BertsAuthPolicyMakerFactoryConfig(object):
def __init__(self, policy_factory, attr='auth_policy'):
self.policy_factory = policy_factory
self.attr = attr
def _get_policy(self, request):
#!/bin/sh
# PROVIDE: ec2_fetchkey
# REQUIRE: NETWORKING
# BEFORE: LOGIN ec2_firstboot
# Define ec2_fetchkey_enable=YES in /etc/rc.conf and create /root/firstboot
# to enable SSH key fetching when the system next boots.
#
: ${ec2_fetchkey_enable=NO}