Skip to content

Instantly share code, notes, and snippets.

View marchampson's full-sized avatar

Marc Hampson marchampson

View GitHub Profile
@marchampson
marchampson / zf2 tableGateway order
Created March 1, 2013 13:21
tableGateway order
$resultSet = $this->tableGateway->select(function (Select $select) {
$select->order('name ASC');
});
return $resultSet;
@marchampson
marchampson / E3 image utility
Created March 6, 2013 14:46
E3 Image utility example usage
// Upload file
$File = $this->params()->fromFiles('image');
if($File['name'] != '') {
$thumbsDir = array(
array('dir' => 'small',
'resize' => '25'),
array('dir' => 'medium',
'resize' => '50'),
array('dir' => 'large',
$adapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
$results = $this->getPagesTable()->fetchAll();
$textUtils = new Text;
foreach($results as $page) {
$prettyurl = $textUtils->prettyurl($page->name);
$sql = "update pages set prettyurl = '".$prettyurl."' where id = ".$page->id;
$adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
$pages = $this->getPagesTable()->fetch(array('namespace'=>'webpage');
foreach($pages as $page) {
$this->getContentNodesTable()->saveContentNode($page->id, 'status', 'Live', $language = 'en');
}
die('fin');
@marchampson
marchampson / convert dates to text
Created May 2, 2013 12:12
globally convert dates E2 -> E3
$pages = $this->getPagesTable()->fetch(array('namespace'=>'event'));
foreach($pages as $page) {
// Get start date
$startDate = $this->getContentNodesTable()->getContentNode($page->id, 'startDate');
if($startDate->content != '') {
$date = date('Y-m-d',$startDate->content);
$this->getContentNodesTable()->saveContentNode($page->id, 'startDate', $date, $language = 'en');
}
$endDate = $this->getContentNodesTable()->getContentNode($page->id, 'endDate');
@marchampson
marchampson / gist:7961175
Created December 14, 2013 16:14
ZF2 tablegateway pass in params
$this->tableGateway->select(function (Select $select) use ($param) {
@marchampson
marchampson / routes.php
Created April 10, 2014 13:26
Listen for illuminate queries
Event::listen('illuminate.query', function($query) {
var_dump($query);
});
@marchampson
marchampson / gist:87328d169a540fc18710
Created July 4, 2014 08:01
OSX key repeat intellij (IdeaVim) PHPStorm
defaults write com.jetbrains.intellij ApplePressAndHoldEnabled -bool false
@marchampson
marchampson / gist:de9a1a414e89210a30ce
Created July 16, 2014 09:54
Touch device hover fix
$('a').on('click touchend', function(e) {
var el = $(this);
var link = el.attr('href');
window.location = link;
});
@marchampson
marchampson / laravel_file_download
Last active August 29, 2015 14:07
Laravel download respsonse type
<?php
// app/routes.php
Route::get('file/download', function()
{
$file = 'path_to_my_file.pdf';
return Response::download($file, 418, array('iron', 'man'));
});