Skip to content

Instantly share code, notes, and snippets.

View marchampson's full-sized avatar

Marc Hampson marchampson

View GitHub Profile
let animationImages:[UIImage] = [UIImage(named: "img_01")!, UIImage(named: "img_02")!, UIImage(named: "img_03")!]
loadingImageView.animationImages = animationImages
loadingImageView.animationDuration = 1.5
loadingImageView.animationRepeatCount = 0
loadingImageView.startAnimating()
self.addSubview(loadingImageView)
@marchampson
marchampson / ios popup alert
Last active August 29, 2015 14:11
IOS popup alert
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No network connection"
message:@"You must be connected to the internet to use this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
@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'));
});
@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 / gist:87328d169a540fc18710
Created July 4, 2014 08:01
OSX key repeat intellij (IdeaVim) PHPStorm
defaults write com.jetbrains.intellij ApplePressAndHoldEnabled -bool false
@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:7961175
Created December 14, 2013 16:14
ZF2 tablegateway pass in params
$this->tableGateway->select(function (Select $select) use ($param) {
@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');
$pages = $this->getPagesTable()->fetch(array('namespace'=>'webpage');
foreach($pages as $page) {
$this->getContentNodesTable()->saveContentNode($page->id, 'status', 'Live', $language = 'en');
}
die('fin');
$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);