Skip to content

Instantly share code, notes, and snippets.

---- 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
@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()) {
<?php
$a = 1;
$fn = function($toAdd) use ($a) {
return $a + $toAdd;
};
echo $fn(2);
$a = 4;
<?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;
}

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
var shortUrl = window.location.href.replace('@itm/./@gi','itm/');
$('<a>', { href: shortUrl, 'text': shortUrl }).insertAfter('#itemTitle');
var shortUrl = window.location.href.replace('@itm/./@gi','itm/');
var item = jQuery('<tr><td class="vi-Vr-itemattrTh"><div class="itm_num_lbl">Shorter URL</div></td><td></td><td width="100.0%">&nbsp;</td></tr>');
item.find('td').eq(1).append($('<a>', { href: shortUrl, 'text': shortUrl }));
item.appendTo('#itemAttrCntr table');
<?php
namespace Zend\Mvc {
class MvcEvent {
public function getRequest() {}
public function getResponse() {}
public function getApplication() {}
}
}
<?php
use Zend\Stdlib\ArrayUtils;
//.....
public function getConfig()
{
$config = array();
$folder = realpath(__DIR__ . '/config');
<?php
return array(
'doctrine' => array(
'driver' => array(
'zfcuser_entity' => array(
'paths' => 'location of your xml files thing'
)
)
),
);