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 | |
/** | |
* This is an example of daemon that runs for a set period of time and the quits. It only allows one task at time | |
* by using a PID file | |
* | |
* The scripts have a few timers that might need explaining | |
* | |
* First there are the $this->anotherInstanceRunning($this->timeout) that checks if a process haven't updated the | |
* pidfile in $this->timeout seconds, then we declare it as dead and start the task, otherwise it quits. |
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 | |
interface Text { | |
public function __toString(); | |
} | |
class HappyBirthday implements Text { | |
private $restOfLine = ''; | |
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 MemberAutocompleteField extends TextField { | |
private static $allowed_actions = array('suggest'); | |
public $maxSuggestionsNum = 50; | |
public function Field($properties = array()) { | |
Requirements::javascript("mysite/javascript/MemberAutocompleteField.js"); |
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 Model { | |
public function saveSomething(Member $member, $data) { | |
if($member && | |
$member instanceof Member && | |
$member->exists() && | |
Permissions::check($member, 'CMS_MAIN')) { | |
// dataobject banana |
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 | |
/** | |
* CreateSomething | |
* | |
* Create a bunch of dataobjects, in this case 10 Members. | |
* | |
*/ | |
class CreateSomething extends BuildTask { | |
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
## _config/myconfig.yml | |
name: OrderController | |
--- | |
OrderController: | |
dependencies: | |
mailerService: %$MailerService | |
Injector: | |
MailerService: | |
factory: MailerFactory | |
MailerFactory: |
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 start_session($timeout = 1800) | |
{ | |
session_cache_limiter(false); | |
session_start(); | |
ini_set("session.gc_maxlifetime", $timeout); | |
if (isset($_SESSION['lastSeen'])) { | |
$heartbeatAgo = time() - $_SESSION['lastSeen']; | |
$timeLeft = $timeout - $heartbeatAgo; |
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
#!/bin/bash | |
ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}' |
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
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "PHP Blue-Green Deployment environment template", | |
"Parameters" : { | |
"KeyName" : { | |
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances", | |
"Type" : "String", | |
"MinLength" : "1", | |
"MaxLength" : "64", | |
"AllowedPattern" : "[-_ a-zA-Z0-9]*", |
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
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Parameters" : { | |
"InstanceType" : { | |
"Description" : "WebServer EC2 instance type", | |
"Type" : "String", | |
"Default" : "m1.small" | |
} | |
"KeyName" : { |
OlderNewer