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
var i18n = function(messages) { | |
this._messages = messages || {}; | |
this.addMessages = function(messages) { | |
this._messages = $.extend({}, this._messages, messages); | |
}; | |
this.getMessage = function(code) { | |
return this._messages[code] || code; | |
}; | |
}; |
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
var TemplateEngine = function() { | |
this.compile = function(template) { | |
return { | |
render: function(scope) { | |
var rendered = template; | |
for(var key in scope) { | |
rendered = rendered.replace(new RegExp('\{\{' + key + '\}\}', 'g'), scope[key]); | |
} | |
return rendered; | |
} |
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/sh | |
echo 'Number of arguments: '$# | |
echo 'All arguments: '$* | |
echo 'All arguments: '$@ | |
echo 'Shell parameters: '$- | |
echo 'Exit code of last app: '$? | |
echo 'Shell PID: '$$ | |
ls -lah > /dev/null & | |
echo 'Last daemonized(&) PID: '$! |
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 | |
$request = $guzzleClient->get('/'); | |
$request->addSubscriber(new \Guzzle\Plugin\Mock\MockPlugin(array( | |
new \Guzzle\Http\Message\Response(200, null, json_encode(array( | |
'error' => 0, | |
))) | |
))); | |
$response = $request->send(); |
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
# log rotation for nginx+php-fpm stack on FreeBSD | |
# File: /etc/newsyslog.conf | |
/var/log/nginx/*.log 644 15 1000 @T00 JBCG /var/run/nginx.pid 30 | |
/var/log/php_errors.log www:www 644 15 1000 @T00 JBCG /var/run/php-fpm.pid 30 |
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 | |
/** | |
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 | |
*/ | |
function timestampToHttpDate($timestamp) { | |
return gmdate('D, d M Y H:i:s', $timestamp) . ' GMT'; | |
} |
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 | |
$client = new \Predis\Client([ | |
'read_write_timeout' => 0, | |
]); | |
while(true) { | |
$message = $client->blpop('queue1', 0); | |
} |
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 Observable implements \SplSubject | |
{ | |
private $_observers = array(); | |
public function notify() | |
{ | |
foreach($this->_observers as $observer) { | |
$observer->update($this); |
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 | |
use PhpAmqpLib\Connection\AMQPConnection; | |
use PhpAmqpLib\Message\AMQPMessage; | |
// connect | |
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest'); | |
// create channel | |
$channel = $connection->channel(); |
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 | |
use PhpAmqpLib\Connection\AMQPConnection; | |
use PhpAmqpLib\Message\AMQPMessage; | |
// connect | |
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest'); | |
// create channel | |
$channel = $connection->channel(); |
OlderNewer