This file contains hidden or 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 | |
require __DIR__.'/request.php'; | |
require __DIR__.'/response.php'; | |
use badphp\context\request; | |
use badphp\context\response; | |
/** | |
* Request handling examples |
This file contains hidden or 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 bash completion for brew | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
. $(brew --prefix)/etc/bash_completion | |
fi | |
# git prompt | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/' | |
} |
This file contains hidden or 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
" pathogen | |
execute pathogen#infect() | |
syntax on | |
filetype plugin indent on | |
" colors | |
set t_Co=256 | |
colorscheme Monokai |
This file contains hidden or 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 | |
# @author Jesus A. Domingo | |
# @license MIT <http://noodlehaus.mit-license.org> | |
namespace noodlehaus\pico; | |
# returns the value for an http request header | |
function request_header($name) { | |
$headers = &$GLOBALS['app/state']['request_headers']; |
This file contains hidden or 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 function_stringify($func) { | |
$ref = new ReflectionFunction($func); | |
if ($ref->isInternal()) | |
return '[internal]'; | |
$top = $ref->getStartLine() - 1; | |
$len = $ref->getEndLine() - $top; |
This file contains hidden or 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 noodlehaus\minsql; | |
# create pdo conn, or get last used, or null | |
function connect(...$args) { | |
static $pdo = null; | |
if (!count($args)) | |
return $pdo; |
This file contains hidden or 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 get_rank($votes_min, $votes_item, | |
$rating_average_global, $rating_average_item) { | |
return | |
($votes_item / ($votes_item + $votes_min)) * $rating_average_item + | |
($votes_min / ($votes_item + $votes_min)) * $rating_average_global; | |
} | |
$data = array( | |
[5, 10], |
This file contains hidden or 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 | |
/** | |
* procedural wrappers for web request/response variables | |
* | |
* @author Jesus A. Domingo <[email protected]> | |
* @license MIT | |
*/ | |
/** | |
* Gets a request parameter (from $_GET over $_POST combination) |
This file contains hidden or 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
server { | |
listen 8080; | |
server_name myserver; | |
root /path/to/root; | |
access_log /var/log/myserver-access.log; | |
error_log /var/log/myserver-error.log debug; |
This file contains hidden or 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
# topic mappings | |
POST /index/topic/_mapping -d '{ | |
"topic": { | |
"properties": { | |
"section_id": { "type": "integer" }, | |
"title": { "type": "string" }, | |
"message": { "type": "string" }, | |
"post_count": { "type": "integer" }, | |
"status": { "type": "string", "index": "not_analyzed" }, | |
"created_at": { "type": "integer" }, |