Skip to content

Instantly share code, notes, and snippets.

<?hh
class Example {
private int $numberNine = 9;
}
@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
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 / 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) {
@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)
go get github.com/revel/revel
go get github.com/revel/cmd/revel
revel test github.com/icambridge/sitrep
@icambridge
icambridge / snippet.go
Last active August 29, 2015 14:00
Force template format
c.Request.Format = "json"
@icambridge
icambridge / interface.go
Last active November 1, 2017 00:59
Observer pattern - golang
type TestCallBack struct {
}
func (c *TestCallBack) Exec(o *Observable) {
log.Println(o.Name)
}
type Callback interface {
Exec(h *Observable)
@icambridge
icambridge / gist:7071555
Last active December 26, 2015 01:29
A simple break down of for loops

Understanding for loops

the basic syntax of a for loop goes

for ($var = 0; $var < 10; $var++) {
    // do stuff
}
@icambridge
icambridge / gist:4587114
Created January 21, 2013 16:14
Quick gist of adding new nodes to a load balancer.
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata
import org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersApi
import org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersAsyncApi
import org.jclouds.rackspace.cloudloadbalancers.domain.NodeRequest
import org.jclouds.rest.RestContext
org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseNode._
val nova = loadBalance.getContext.unwrap.asInstanceOf[RestContext[CloudLoadBalancersApi, CloudLoadBalancersAsyncApi]]
val nodeApi = nova.getApi.getNodeApiForZoneAndLoadBalancer(zone,id.toInt)