Skip to content

Instantly share code, notes, and snippets.

@dbu
dbu / Vagrantfile
Created November 13, 2012 09:26
vagrant setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
this_dir = File.dirname(__FILE__) + "/"
require this_dir + "vagrant/hostmaster.rb"
Vagrant::Config.run do |config|
# define some colors for our output
def colorize(text, color_code) "#{color_code}#{text}\033[0m" end
Class IpRange
{
public function setStartingAddress($startingAddress)
{
InputValidator::assertValidAddress($startingAddress);
$this->startingAddress = (int) $startingAddress;
return $this;
}
}
@weierophinney
weierophinney / helper.php
Created October 29, 2012 13:54
static helper
<?php
abstract class Helper
{
public static function createHash(Paste $paste, PasteService $service)
{
$seed = $paste->language . $paste->timestamp . $paste->content;
do {
$seed . = uniqid();
$hash = hash('sha1', $seed);
} while ($service->exists($hash));
@mvriel
mvriel / gist:3823010
Created October 2, 2012 20:14
Generic notation in PHPDoc vs. plain array notation
<?php
/**
* @template <T> The type of the individual elements
*/
class ArrayCollection implements IteratorAggregate
{
private $elements;
/**
* @param array<T> $elements