Skip to content

Instantly share code, notes, and snippets.

View bendechrai's full-sized avatar

Ben Dechrai bendechrai

View GitHub Profile
@bendechrai
bendechrai / entypo.css
Last active December 18, 2015 04:48 — forked from jokka/entypo.css
@font-face {
font-family: 'EntypoRegular';
src: url('font/entypo.eot');
src: url('font/entypo.eot?#iefix') format('embedded-opentype'),
url('font/entypo.woff') format('woff'),
url('font/entypo.ttf') format('truetype'),
url('font/entypo.svg#EntypoRegular') format('svg');
font-weight: normal;
font-style: normal;
}
@bendechrai
bendechrai / gencert
Last active August 29, 2015 14:01
OpenSSL certificate generation helper script
#!/bin/bash
################################################################################################################
#
# Place this script in /etc/ssl/private and chown it root and chmod 700
#
# This script will generate basic OpenSSL files and self-sign a certificate
#
# Usage is `gencert domain.name` and the result is domain.name.{key,csr,crt,pem}
# If the domain name provided is a wildcard, the asterisk is replaced with an underscore
@bendechrai
bendechrai / gnupg_backup
Last active August 29, 2015 14:03
.gnupg file backup helper
#!/bin/bash
# Helper script used to back up your gnupg directory
#
# Author: Ben Dechrai <ben@ctoforhire.com.au>
# License: GPLv3 <http://www.gnu.org/licenses/gpl-3.0.txt>
#
# Installation instructions:
# wget https://gist.githubusercontent.com/bendechrai/8bbde547642404a4986c/raw/8049dcd7def5b2c96c28c7dd3b09933d2d5c9190/gnupg_backup -O ~/.gnupg/backup
@bendechrai
bendechrai / meetup_rand.php
Last active August 29, 2015 14:06
Meetup random attendee selector
<?php
$ug = 'Melbourne-PHP-Users-Group'; // Usergroup slug
$eid = '202990892'; // Event ID
$html = file_get_contents("http://www.meetup.com/$ug/events/$eid/");
preg_match_all("#<a href=\"http://www.meetup.com/$ug/members/[0-9]*\">([^<]*)</a>#", $html, $array);
$names = $array[1];
$winner = array_rand( array_unique( $names ));
echo $names[$winner] . "\n";
@bendechrai
bendechrai / parse-westpac
Created October 28, 2014 11:17
Simple parser of Westpac statements
#!/usr/bin/php
<?php
/**
* Simple parser of Westpac statements
* @author Ben Dechrai <ben@dechrai.com>
* @license http://www.json.org/license.html
*
* Run ./parse-westpac input.txt output.csv
*
@bendechrai
bendechrai / mailman-discard-ban.user.js
Last active January 12, 2017 17:17
Mailman Always Discard and Ban (Greasemonkey Script)
// ==UserScript==
// @name Mailman Always Discard and Ban
// @namespace https://bendechrai.com/
// @description Automatically selects "Discard" and ticks the "Add" and Ban" checkboxes on Mailman admin requests for pending messages
// @downloadURL TBA
// @match *://*/mailman/admindb/*
// @match *://*/lists/admindb/*
// @version 1
// @grant none
// ==/UserScript==
@bendechrai
bendechrai / textareaPlaceholderNewlines.css
Last active March 26, 2016 21:31
Textarea Placeholder with Newlines
textarea.placeholder {
color: #aaa;
}
@bendechrai
bendechrai / README.md
Created May 9, 2016 00:19
NGINX SSL Config

Creating a dhparam file

screen
openssl dhparam -out dhparams.pem 4096 &```

This can take up to an hour, so starting in `screen` will allow you to come back later :)
@bendechrai
bendechrai / le-nginx-renew.sh
Created July 11, 2016 01:33
LetsEncrypt Nginx Renew
#!/bin/bash
for meta in /etc/letsencrypt/renewal/*conf
do
DOMAIN=`basename $meta | sed 's,.conf$,,'`
# Does the domain appear as a servername in any config file
if [ $(grep -E "^[ \t]*server_name\W+(.*[ \t])?$DOMAIN[ \t;]" /etc/nginx/sites-enabled/*| wc -l) -gt 0 ]
then
@bendechrai
bendechrai / payment.php
Last active May 26, 2017 03:20
DO NOT USE THIS CODE IN ANY WAY FOR ANYTHING DESTINED FOR PRODUCTION
<?php
$cc_number = "4444 3333 2222 1111";
$p = new Payment();
$p->processPayment($cc_number);
class Payment {
static $url = 'https://api.paypal.com/web_run/f';