Skip to content

Instantly share code, notes, and snippets.

View davebarnwell's full-sized avatar

Dave Barnwell davebarnwell

View GitHub Profile
@davebarnwell
davebarnwell / pre-commit
Created October 24, 2016 20:16 — forked from chelmertz/pre-commit
pre-commit hook for git, running php lint
#!/usr/bin/php
<?php
// copied from http://phpadvent.org/2008/dont-commit-that-error-by-travis-swicegood
// authored by Travis Swicegood
$output = array();
$return = 0;
exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return);
$against = $return == 0 ? 'HEAD' : '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
@davebarnwell
davebarnwell / countries.csv
Created August 26, 2016 19:00 — forked from zspine/countries.csv
Country Code, ISO and Nationality
Code Country ISO Nationality
AD Andorra 53 Andorian
AE United Arab Emirates 126 Emirian
AF Afghanistan 133 Afghani
AI Anguilla 55 Anguillan
AM Armenia 58 Armenian
AO Angola 54 Angolian
AQ Antarctica 55 Antarctic
AR Argentina 57 Argentine
AS Austria 3 Austrian
@davebarnwell
davebarnwell / FileExtMimeTypes.php
Last active July 2, 2016 19:05
file extension to Mime Types in a PHP array
<?php
/**
* File extension to mime types
* User: dave
*
* Usage:
*
* $mime_types = require('FileExtMimeTypes.php');
*
*/
@davebarnwell
davebarnwell / apitest.php
Created March 1, 2016 22:08 — forked from karlkranich/apitest.php
Updated PHP code to use the Google Sheets API. See usage instructions at http://karl.kranich.org/2015/04/16/google-sheets-api-php/
<?php
require_once realpath(dirname(__FILE__) . '/vendor/autoload.php');
include_once "google-api-php-client/examples/templates/base.php";
$client = new Google_Client();
/************************************************
ATTENTION: Fill in these values, or make sure you
have set the GOOGLE_APPLICATION_CREDENTIALS
@davebarnwell
davebarnwell / README.md
Created February 5, 2016 15:26 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@davebarnwell
davebarnwell / youtube-vimeo-embed-urls.php
Last active June 6, 2018 13:22 — forked from cballou/youtube-vimeo-embed-urls.php
PHP Function to Convert Youtube and Vimeo URLs to Lightbox-Ready Equivalents
<?php
/**
* Given a string containing any combination of YouTube and Vimeo video URLs in
* a variety of formats (iframe, shortened, etc), each separated by a line break,
* parse the video string and determine it's valid embeddable URL for usage in
* popular JavaScript lightbox plugins.
*
* In addition, this handler grabs both the maximize size and thumbnail versions
* of video images for your general consumption. In the case of Vimeo, you must
* have the ability to make remote calls using file_get_contents(), which may be
#!/bin/sh
# Pre-commit hook for git which removes trailing whitespace, converts tabs to spaces, and enforces a max line length.
# The script does not process files that are partially staged. Reason: The `git add` in the last line would fully
# stage a file which is not what the user wants.
if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@davebarnwell
davebarnwell / LICENSE
Last active August 29, 2015 14:15 — forked from jdennes/LICENSE
Campaign monitor Ajax submit
The MIT License (MIT)
Copyright (c) James Dennes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: