Skip to content

Instantly share code, notes, and snippets.

$Locations_from_line =
array_map(
function($loc) {
return array_map(
function($part) {return trim($part);},
explode(',', $loc)
);
},
explode(';', $line['VC Portfolio URL'])
);
<?php
namespace ynd\thsx\core;
class Router {
protected $prefix;
protected $routes;
// Used in specificity calculations.
const MAX_PATH_SEGMENTS = 10;
public function __construct($routes, $prefix = NULL) {
$remove = array();
foreach($company_names as $company_name) {
$remove_name = false;
foreach($company_names as $compare) {$remove_name = $remove_name || (strpos($compare, $company_name) == 0);}
if ($remove_name) {$remove[] = $company_name;}
}
$company_names = array_diff($company_names, $remove);
== Sinatra/0.9.4 has taken the stage on 4567 for development with backup from WEBrick
[2009-11-27 21:02:36] INFO WEBrick 1.3.1
[2009-11-27 21:02:36] INFO ruby 1.9.1 (2009-07-16) [i486-linux]
[2009-11-27 21:02:41] INFO WEBrick::HTTPServer#start: pid=7040 port=4567
^C
== Sinatra has ended his set (crowd applauds)
[2009-11-27 21:02:45] INFO going to shutdown ...
[2009-11-27 21:02:45] INFO WEBrick::HTTPServer#start done.
[2009-11-27 21:02:45] INFO WEBrick 1.3.1
[2009-11-27 21:02:45] INFO ruby 1.9.1 (2009-07-16) [i486-linux]
{
"id": "/en/fantastic_mr_fox_2007",
"key": {
"namespace": "/source/fandango/movie",
"value": "fantasticmr.fox_109297nu",
"connect": "insert"
}
}
<?php
mb_internal_encoding("UTF-8");
mb_http_output("UTF-8");
iconv_set_encoding('input_encoding', 'UTF-8');
iconv_set_encoding('output_encoding', 'UTF-8');
iconv_set_encoding('internal_encoding', 'UTF-8');
$Database = mysql_connect('localhost', 'user', 'pass', true);
(( ${+functions[vcs_info]} )) && vcs_info
autoload -Uz vcs_info
(( ${+functions[vcs_info]} )) && vcs_info
public static function makeIdentifier($string, $entity=null) {
$base_identifier = Model::sanitizeName($string);
if ($entity) {
$new_increment =
Kohana_ORM::factory($entity)
->select(new Kohana_Database_Expression('substring(identifier, -1) + 1 as new_increment'))
->regex('identifier', $base_identifier.'[1-9][0-9]*')
->orderby('new_increment', 'desc')
->limit(1)
->find();
if (!function_exists('get_called_class')) {
function get_called_class() {
$bt = debug_backtrace();
$lines = file($bt[1]['file']);
preg_match(
'/([a-zA-Z0-9\_]+)::'.$bt[1]['function'].'/',
$lines[$bt[1]['line']-1],
$matches
);
return $matches[1];