Skip to content

Instantly share code, notes, and snippets.

var shortUrl = window.location.href.replace('@itm/./@gi','itm/');
$('<a>', { href: shortUrl, 'text': shortUrl }).insertAfter('#itemTitle');

Microframework

This is a PHP microframework based on anonymous functions.

Features

  • requested URLs matched using regular expressions
  • request methods (matches using regular expressions too)
  • differenced FIFO queues for each $priority
  • command line usage
  • backward compatibility
  • integrated Dependency Injection system
  • settings system
<?php
function array_keyValue($array, $key) {
return array_map(
function($item) use ($key) {
if (!is_array($item)) {
return null
} elseif (!array_key_exists($key, $item)) {
return null;
}
<?php
$a = 1;
$fn = function($toAdd) use ($a) {
return $a + $toAdd;
};
echo $fn(2);
$a = 4;
@BinaryKitten
BinaryKitten / boostrap-nav.php
Created March 18, 2013 14:43
Bootstrap Navigation style
<ul class="nav">
<?php foreach ($this->container AS $page) { ?>
<?php
// render li tag and page
$liClass = '';
$liClass .= $page->isActive() ? ' active' : '';
$liClass .= $page->getClass() ? ' ' . $page->getClass() : '';
$linkDropdown = '';
if ($page->hasChildren()) {
---- repeat with replacements -----
!!:gs<marker>SEARCH<marker>REPLACE
eg
git checkout branchA && git pull origin branchA && git merge branchB && git push origin branchA
!!:gs/branchA/branchC
!!:gs/branchC/branchD
[alias]
update = pull origin
st = status
submit = push origin
merge-branch = "!sh -c 'git checkout $1 && git update $1 && git checkout - && git merge $1' -"
merge-to = "!sh -c 'git checkout $1 && git update $1 && git merge - && git submit $1 && git checkout -' -"
<?php
class Pico_Cascadenav
{
public function get_pages(&$pages, &$current_page, &$prev_page, &$next_page)
{
$newPages = array('pages' => array());
foreach($pages as $page) {
<?php
namespace Application;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap(MvcEvent $e)
<?php
namespace CustomTheme;
use Zend\Stdlib\ArrayUtils;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
class Module implements ServiceProviderInterface,
ViewHelperProviderInterface