Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jpitoniak on github.
  • I am jpitoniak (https://keybase.io/jpitoniak) on keybase.
  • I have a public key ASD0KxejI6cw2gFIZIgY11VvDuSf8qih9flirZAW-V-TuAo

To claim this, I am signing this object:

@jpitoniak
jpitoniak / function.formfield.php
Created February 20, 2017 18:48
Smarty plugin for generating form fields
<?php
/* formfield plugin
* Create dynamic HTML form elements programmatically
*
* Parameters:
* type - the type of element, can be any standard HTML <input> type or one of the options below (default = text)
* options - for select, checkboxes, and radios types, this should be an associative array of key => label pairs
* value - the default value of the element; for select or checkboxes types this can be an array selected/checked values, if an array is set for other types, only the first value in the array is used
* wrapper - the HTML wrapper to be applied to individual elements when using checkboxes or radios, use %s to specify where default makeup should be inserted
* content - the content between <button> and </button> tags in an htmlbutton field
@jpitoniak
jpitoniak / uuid.php
Created February 17, 2017 16:52
Generate a cryptographically-secure universally unique identifier (UUID) in PHP
<?php
/**
* Generate a universally unique identifier (UUID)
*
* Generates a universally unique identifier (UUID), also referred to as a globally
* unique identifier (GUID) using the best-available source of cryptographically-secure
* random data. If no adequate source of random data is available, an exception is thrown.
*
* Possible sources of random data include:
* * random_bytes() function, available in PHP7+
@jpitoniak
jpitoniak / quick-le
Last active May 25, 2016 13:07
A quick script for obtianing and automatically renewing Let's Encrypt certificates
#!/bin/bash
#
# Quick Let's Encrypt Certificate Autoinstaller
#
# Quick script to install a Let's Encrypt certificate on a bunch of domains
# and schedule automatic renewals with at
#
# Assumes that:
# 1. The "certbot-auto" client is available (https://github.com/certbot/certbot, https://certbot.eff.org/)
# 2. All of the domains can handle the /.well-known/acme-challenge request