This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
function restart_web($interface) { | |
passthru("ifconfig $interface down"); | |
passthru("ifconfig $interface up"); | |
sleep(5); | |
} | |
function ping($host) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BaseAdder | |
{ | |
public function add($a, $b) | |
{ | |
return $a + $b; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$decrease = function($self, $number) { | |
if ($number >= 0) { | |
echo $number . PHP_EOL; | |
$self($self, --$number); | |
} | |
}; | |
$decrease($decrease, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function describe($testedClass, callable $tests) { | |
print ("$testedClass" . PHP_EOL); | |
$tests(); | |
} | |
function it($testName, callable $test) { | |
print(" $test" . PHP_EOL); | |
$test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trimAndLower($elem -> { | |
return trim(strtolower($elem)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sayHi = { echo "hi"; }; | |
$sayHi(); // prints: hi | |
$sayHello = $name -> { echo "hello, $name"; }; | |
$sayHello("Chuck Norris"); // prints: hello, Chuck Norris |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('Europe/London'); | |
$alarm = '06:00'; | |
$musicFileToPlay = '~/Music/4\ non\ blondes/1-01\ Train.mp3'; | |
$open = 'open'; // change this to what is the command in you OS. This works for MacOSX | |
while (true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Behat\Mink\Driver\Selenium; | |
use \PHPUnit_Extensions_SeleniumTestCase as SeleniumTestCase; | |
class Client extends SeleniumTestCase | |
{ | |
public function __construct($browser = '*firefox', $sid = null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
md@bossa:phpspec (develop) $ behat | |
Feature: Developer sees help | |
As a developer | |
In order to know which cammands are available in PHPSpec | |
I want a command line option that displays the help | |
Scenario: Long option # features/developer_sees_help.feature:6 | |
When I use the command "phpspec --help" # CommandContext::iUseTheCommand() | |
Then I should see # CommandContext::iShouldSee() | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AutoRun { | |
static public $lastTime; | |
public static function main($argc, array $argv = array()) { | |
chdir("."); | |
$lastTime = time(); | |
$dir = new DirectoryIterator("."); | |
$autorun = new AutoRun($lastTime, $dir); |
NewerOlder