Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@icambridge
icambridge / snippet.go
Last active August 29, 2015 14:00
Force template format
c.Request.Format = "json"
go get github.com/revel/revel
go get github.com/revel/cmd/revel
revel test github.com/icambridge/sitrep
@icambridge
icambridge / Constructor.php
Created June 5, 2014 18:07
Dependency Injection Examples
<?php
class Notify
{
/**
* @var SenderInterface
*/
protected $sender;
public function __construct(SenderInterface $sender)
@icambridge
icambridge / react-body.php
Created June 17, 2014 20:49
An example of how to get the request body
<?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) {
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 November 1, 2014 22:55
returning null compared to throwing an exception
<?php
$person = $peopleRepo->getLatest();
if (null === $person) {
$log->warn('No person found');
}
$person->inviteToParty();
// becomes
<?hh
class Example {
private int $numberNine = 9;
}
<?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.
}
Icambridge\Entity\User:
id: encoder.super_duper_silly
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