View .htaccess
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
RewriteEngine On | |
# The following rule tells Apache that if the requested filename | |
# exists, simply serve it. | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
# The following rewrites all other queries to index.php. The | |
# condition ensures that if you are using Apache aliases to do |
View test_bench.php
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 | |
// Testing md5 vs. preg_replace_callback() | |
$execPreg = 0; | |
$execMd5 = 0; | |
for ($i=0; $i<100000; $i++) { | |
$name = randomName(10); | |
$start = microtime(true); | |
$result = preg_replace_callback( |
View global.php
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/autoload/global.php | |
// ... | |
'router' => array( | |
'routes' => array( | |
'oauth' => array( | |
'options' => array( | |
'route' => '/oauth', | |
), | |
), |
View gist:f34b22f347d4a0c985a1
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 Zend\Stratigility\MiddlewarePipe; | |
use Zend\Diactoros\Server; | |
require 'vendor/autoload.php'; | |
$app = new MiddlewarePipe(); | |
$server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); | |
// Injected for all the URL |
View encrypt_file.php
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 | |
// include the ZF2 library | |
use Zend\Filter\Encrypt; | |
if (!isset($argv[1]) or !isset($argv[2])) { | |
die("Usage: " . basename(__FILE__) . " <file_to_encrypt> <encryption_key>\n"); | |
} | |
if (!file_exists($argv[1])) { | |
die("The file {$argv[1]} specified doesn't exist\n"); |
View gist:6138279
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
CREATE TABLE post ( | |
id int(11) NOT NULL auto_increment, | |
title varchar(100) NOT NULL, | |
content TEXT NOT NULL, | |
user_id int(11), | |
category_id int(11), | |
publish_date DATETIME, | |
PRIMARY KEY (id) | |
); |
View gist:6071979
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
RPC: GET /getalbum | |
Request | |
{ "id" : 1 } | |
OK Response (200): | |
{ | |
"id" : 1, | |
"artist" : { | |
"name" : "Metallica", | |
"history" : "Simply the best heavy metal band ever!", | |
"genre" : "Heavy metal, Hard rock, Speed metal, Thrash metal" |
View gist:6071087
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
/GET /user | |
OK Response (200): | |
{ | |
"user" : { | |
"name" : "Foo", | |
"email" : "foo@bar.com" | |
} | |
} |
View gist:5301941
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 | |
$database = ''; | |
$user = ''; | |
$password = ''; | |
$hostname = ''; | |
$port = 446; | |
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;". | |
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;"; |
View gist:5135662
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 | |
$database = ''; | |
$hostname = ''; | |
$port = ''; | |
$user = ''; | |
$password = ''; | |
return array( | |
'db' => array( |