Skip to content

Instantly share code, notes, and snippets.

View colynb's full-sized avatar
🎯
Focusing

C Brown colynb

🎯
Focusing
View GitHub Profile
@colynb
colynb / FSBOEvent.php
Created April 28, 2017 01:03
Simple PHP event handling class
<?php
namespace Events;
class FSBOEvent
{
/**
* @var array
*/
protected static $eventHandlers = [];
@colynb
colynb / functions.php
Last active May 22, 2023 05:09
PHP - convert any dollar/cents amount into just cents
<?php
function to_pennies($value)
{
return intval(
strval(floatval(
preg_replace("/[^0-9.]/", "", $value)
) * 100)
);
}
@colynb
colynb / gist:5421554b4b23f45963075f5aad9e8286
Created December 16, 2016 19:34 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@colynb
colynb / index.html
Created September 28, 2016 20:59
VueJS Server Rendering Test
<div id="app">
<ul>
<li v-for="option in options">
<span class="red">{{ option.text }}</span>
</li>
</ul>
<ul v-if="!fetched">
<li>One</li>
<li>Two</li>
@colynb
colynb / bordered-with-arrows.sass
Last active September 11, 2016 20:56
CSS arrows w/borders
.box
background-color: #fff
border: solid 1px #ccc
border-radius: 8px
&::before,
&::after
border: solid transparent
content: ""
height: 0
@colynb
colynb / 0_reuse_code.js
Created September 11, 2016 20:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@colynb
colynb / index.html
Created June 28, 2016 15:34
Animated and Styled Checkboxes
<!DOCTYPE html>
<html lang="en">
<head>
<title>Animated and Styled Checkboxes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="assets/img/favicons/favicon.ico">
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body>
@colynb
colynb / gist:09734bcef5b32455abae
Last active August 29, 2015 14:12
Install PHP on OSX

There are many ways to get the latest PHP version running on your mac, but so far the one that seemed the least complicated is to use phpbrew

Start here: https://github.com/phpbrew/phpbrew

From there, there are instructions for getting PHP installed. It's also used as a version switcher, which can be useful for managing multiple projects with different version requirements.

I noticed, the build failed because of a missing component called "libmcrypt". To fix that I just installed that with homebrew:

@colynb
colynb / index.html
Last active August 29, 2015 14:06 — forked from anonymous/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<style id="jsbin-css">
.js-banner {
padding: 40px;
background: #a4b357;
@colynb
colynb / mongo_install.bash
Last active August 29, 2015 14:03
MongoDB install on Ubuntu
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list
apt-get -y update
apt-get -y --force-yes install mongodb-10gen