Skip to content

Instantly share code, notes, and snippets.

Iain Cambridge icambridge

Block or report user

Report or block icambridge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@icambridge
icambridge / snippet.go
Last active Aug 29, 2015
Force template format
View snippet.go
c.Request.Format = "json"
View gist:11329286
go get github.com/revel/revel
go get github.com/revel/cmd/revel
revel test github.com/icambridge/sitrep
@icambridge
icambridge / Constructor.php
Created Jun 5, 2014
Dependency Injection Examples
View Constructor.php
<?php
class Notify
{
/**
* @var SenderInterface
*/
protected $sender;
public function __construct(SenderInterface $sender)
@icambridge
icambridge / react-body.php
Created Jun 17, 2014
An example of how to get the request body
View react-body.php
<?php
require_once __DIR__ . "/../vendor/autoload.php";
$app = function (\React\Http\Request $request, \React\Http\Response $response) {
$data = new \React\Stream\BufferedSink();
$request->pipe($data);
$data->promise()->then(function($data) use ($request, $response) {
View recognition.feature
Scenario: Recognise outside of heirachry with line manager recognition approval and reward control table director approval
Given I am logged in to the system
And recognition approval is set to manual by line manager
And reward approval is set to manual with a budget control table of:
| Director | 100 |
| Plus one | 50 |
| Line Manager | 1 |
When I recognise someone outside of my heirarchy for "150"
Then the recognition status should be pending
And the reward status should control tabled
@icambridge
icambridge / exception.php
Created Nov 1, 2014
returning null compared to throwing an exception
View exception.php
<?php
$person = $peopleRepo->getLatest();
if (null === $person) {
$log->warn('No person found');
}
$person->inviteToParty();
// becomes
View class.hh
<?hh
class Example {
private int $numberNine = 9;
}
View gist:944f3f3ce5a65653bec5
<?php
define('WPSQT_VERSION', '1.2.1');
$oldVersion = get_option('wpsqt_version');
update_option('wpsqt_version',WPSQT_VERSION);
// Simple way of checking if an it's an update or not.
if ( !empty($oldVersion) && (version_compare($oldVersion, WPSQT_VERSION) < 0) ){
// Do upgrade stuff.
}
View five.yml
Icambridge\Entity\User:
id: encoder.super_duper_silly
View gist:7204f478dfcb8c5e4811
vagrant@php7dev:/vagrant$ php benchmark.php
time: 1.4532651901245
memory usage: 6291456
JMS - PHP 7
---
vagrant@php7dev:/vagrant$ nano benchmark.php
vagrant@php7dev:/vagrant$ php benchmark.php
time: 0.29000401496887
memory usage: 4194304
RAW - PHP 7
You can’t perform that action at this time.