Skip to content

Instantly share code, notes, and snippets.

View salathe's full-sized avatar
🐮
🔥

Peter Cowburn salathe

🐮
🔥
  • Akamai Technologies
  • Edinburgh, Scotland
View GitHub Profile
@salathe
salathe / gist:8317870
Last active January 2, 2016 14:39 — forked from J7mbo/gist:8317804
/**
* {@inheritdoc}
*
* @note Image dimensions returned as array(width, height)
*/
public function fetchMetaDataFrom($filePath)
{
if (!file_exists($filePath))
throw new MetaDataFileNotFoundException(sprintf("File %s could not be found for metadata retrieval", $filePath));
@salathe
salathe / nginx.conf
Created October 21, 2013 16:20 — forked from vessi/nginx.conf
# available in /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
}
<?php
namespace Seedstream;
use React\EventLoop\LoopInterface,
React\Socket\ConnectionInterface;
class Pusher
{
private $loop;
@salathe
salathe / list.php
Last active December 18, 2015 18:29 — forked from evert/list.php
<?php
$var = "foo";
list($foo, $bar, $baz) = $var;
var_dump($foo, $bar, $baz);
list($foo, $bar, $baz) = "foo";
var_dump($foo, $bar);
/*
@salathe
salathe / mysql.md
Created July 24, 2012 10:38 — forked from teresko/gist:2907749
cannonical SO comment for mysql_* users
@salathe
salathe / comment.txt
Created June 11, 2012 12:40 — forked from teresko/gist:2907749
cannonical SO comment for mysql_* users
Please, don't use `mysql_*` functions for new code. They are no longer maintained and the community has begun the [deprecation process](http://news.php.net/php.internals/53799). See the [**red box**](http://php.net/mysql-connect)? Instead you should learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) and use either [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli). If you can't decide, [this article](http://php.net/mysqlinfo.api.choosing) will help to choose. If you care to learn, [here is good PDO tutorial](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers).
@salathe
salathe / json.php
Created June 21, 2011 09:33 — forked from alkavan/json.php
JSON Helper for Kohana v3
<?php defined('SYSPATH') or die('No direct script access.');
/**
* JSON helper class
*
* Examples:
* $j = JSON::decode('{"Organization": "Kohana"}'); // Good
* $j = JSON::decode("{'Organization': 'Kohana'}"); // Invalid
* $j = JSON::decode('{"Organization": "Kohana"}', NULL, 1); // depth stack exceeded
*
* @package Kohana
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
var url=document.location;
var links=document.getElementsByTagName('link');
var found=0;
for(var i = 0, l; l = links[i]; i++) {
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) {
found=l.getAttribute('href');
break;
}