Skip to content

Instantly share code, notes, and snippets.

View cballou's full-sized avatar

Corey Ballou cballou

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1fo4sVGAUxsB22mMK1xFAFQCdb7YUcSvh https://explorer.blockstack.org/address/1fo4sVGAUxsB22mMK1xFAFQCdb7YUcSvh

Keybase proof

I hereby claim:

  • I am cballou on github.
  • I am coreyballou (https://keybase.io/coreyballou) on keybase.
  • I have a public key ASBMvS6f_1MLwT-AgL2aCt9z2y7BS-TyRw6z9AHwOvd24Ao

To claim this, I am signing this object:

Verifying that "corey.id" is my Blockstack ID. https://onename.com/corey
@cballou
cballou / laravel-global-exception-handler.php
Last active September 12, 2021 10:45
Global handling of Laravel exceptions to better support AJAX requests.
<?php namespace App\Exceptions;
use Log;
use Mail;
use Config;
use Exception;
use Illuminate\Auth\Access\UnauthorizedException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
@cballou
cballou / mcrypt-pad-aes.php
Created June 5, 2017 14:48
Mcrypt helper function for padding AES encryption keys to ensure PHP 5.6-7.1 is backwards compatible with PHP <= 5.5.
<?php
/**
* Pad an AES encrypted key to ensure it's of valid size according
* to specification. This function is backwards compatible with
* PHP <= 5.5 and is intended for usage with PHP 5.6+.
*/
function pad_aes($str) {
$c = strlen($str);
$validLengths = array(16, 24, 32);
foreach ($validLengths as $l) {
@cballou
cballou / example-config.php
Created March 9, 2017 17:57
Watchdog is a PHP library using inotify to watch for file changes.
<?php
return array(
'types' => array('sass', 'scss', 'less', 'styl', 'jade', 'haml'),
'watch' => array(
'/path/to/public/css',
'/path/to/alternate/css'
),
'minify' => true,
'ignore' => array()
@cballou
cballou / config-template-example.php
Last active March 9, 2017 17:13
Example of using Winston, a PHP AB/split testing library which utilizes machine learning and Redis.
<?php
$config = array(
'tests' => array(
'signup-submit-button-test' => array(
'description' => 'A sample test',
'variations' => array(
array(
'id' => 'submit-default',
'text' => '<button type="submit" {{click}}>Submit</button>'
),
@cballou
cballou / client-usage.php
Last active March 8, 2017 11:31
Documentation regarding GoogleAuthenticatorRedux. Official documentation of the library can be found at https://www.craftblue.com/projects/php/google-authenticator-2fa
<?php
// if you are using composer, which is the preferred method of autoloading
require_once('./vendor/autoload.php');
// create a new secret for a user wishing to enable 2FA
// you will need to store this securely
$secret = $ga->createSecret();
// example of generating a QR code to display to the end user
@cballou
cballou / mongosession-advanced-usage.php
Created June 5, 2016 19:21
MongoSession example usage
<?php
require_once('MongoSession.php');
// the config array for loading MongoDB servers
$config = array(
// cookie related vars
'cookie_path' => '/',
'cookie_domain' => '.mydomain.com', // .mydomain.com
// session related vars
@cballou
cballou / jQuery-Double-Rainbow-Plugin-default-configuration-options.js
Created May 18, 2016 11:39
An example of using the jQuery Double Rainbow plugin.
$.fn.doubleRainbow.defaults = {
startDistance: 500,
steps: 20,
startBgColor: '#333333',
endBgColor: '#999999',
startColor: '#CCCCCC',
endColor: '#FFFFFF'
};