Skip to content

Instantly share code, notes, and snippets.

<?php
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return value($default);
}
<?php
function wrapFunction(callable $func, array $params)
{
try {
$data = $func(...$params);
} catch (\Exception $e) {
$data = false;
}
<?php
class HttpException extends \Exception
{
/**
* List of additional headers
*
* @var array
*/
private $headers = array();
@jworksuk
jworksuk / README.md
Last active May 25, 2016 21:20
Installing Python on Max OS X El Capitan

Installing Python Stuff on Max OS X El Capitan

Install Homebrew - http://brew.sh/

Install Python via brew

brew install python

Check your Python version

@jworksuk
jworksuk / vhost-site
Created May 23, 2014 15:27
VirtualHost Site
<VirtualHost *:80>
ServerAdmin __adminemail__
ServerName __domain__
ServerAlias __domainalias__
DocumentRoot /var/www/__path__/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@jworksuk
jworksuk / redirect.php
Last active December 23, 2015 11:01
simple redirect
<?php
/**
* Function to redirect browser to a specific page
*/
function redirect($url)
{
if ( ! headers_sent() )
{
header('Location: '.$url);
}
@jworksuk
jworksuk / flushcolumns.less
Created May 22, 2013 08:52
@subotnick : I expanded Semantic.gs to allow for fluid columns without margins - either on both sides, just left or just right.
.columnflush(@x,@columns:@columns) {
display: inline;
float: left;
width: @total-width*((((@gutter-width+@column-width)*@x)) / @gridsystem-width);
}
.columnflushleft(@x,@columns:@columns) {
display: inline;
float: left;
width: @total-width*((((@gutter-width+@column-width)*@x)-(@gutter-width*.5)) / @gridsystem-width);
@jworksuk
jworksuk / internal-scrolling.js
Created April 30, 2013 08:52
Smooth scrolling for internal links
// Wicked credit to
// http://www.zachstronaut.com/posts/2009/01/18/jquery-smooth-scroll-bugs.html
var scrollElement = 'html, body';
$('html, body').each(function () {
var initScrollTop = $(this).attr('scrollTop');
$(this).attr('scrollTop', initScrollTop + 1);
if ($(this).attr('scrollTop') == initScrollTop + 1) {
scrollElement = this.nodeName.toLowerCase();
$(this).attr('scrollTop', initScrollTop);
return false;
<VirtualHost *:80>
ServerName __domain__
ServerAlias __domainalias__
DocumentRoot /Users/jjames/Sites/__folder__/
<Directory /Users/jjames/Sites/__folder__/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny