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
### USAGE | |
Require the autoload in your bootstrap, and use the Application to start your app | |
require __DIR__ . '/../Autoload.php'; | |
$app = new Fastpress\Application; | |
$app->get('/hello/{:name}', function($name) use ($app){ | |
echo 'Hello ' $app->escape($name); // Hello world | |
}); |
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 VisiThorGraph{ | |
function __construct($myFile){ | |
$this->myFile = new SplFileObject($myFile); | |
} | |
function getTotalCount(){ | |
$count = null; | |
while(!$this->myFile->eof()){ | |
$explode = explode('#', str_replace("\n", "", $this->myFile->fgets())); | |
if(!empty($explode[1])){ |
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 SecureSessionHandler extends SessionHandler { | |
protected $key, $name, $cookie; | |
public function __construct($key, $name = 'MY_SESSION', $cookie = []) | |
{ | |
$this->key = $key; | |
$this->name = $name; |
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
Demo |
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
""" An example of a Linux daemon written in Python. | |
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ | |
The changes are: | |
1 - Uses file open context managers instead of calls to file(). | |
2 - Forces stdin to /dev/null. stdout and stderr go to log files. | |
3 - Uses print instead of sys.stdout.write prior to pointing stdout to the log file. | |
4 - Omits try/excepts if they only wrap one error message w/ another. |
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 getJsonPage($url) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); |
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 echo 1 + 1; ?> |
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 echo 'FOO' ?> |
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 echo /** foo */ ?> |