Skip to content

Instantly share code, notes, and snippets.

View simonrjones's full-sized avatar

Simon R Jones simonrjones

View GitHub Profile
@simonrjones
simonrjones / parseCsv.php
Last active August 29, 2015 14:10
Parse CSV file snippet
<?php
// Read CSV file
// PHP5.4+
ini_set('auto_detect_line_endings', true);
$file = new SplFileObject("path/to/file.csv");
$file->setFlags(SplFileObject::READ_CSV);
$line = 0;
$headers = [];
foreach ($file as $row) {
@simonrjones
simonrjones / gist:8783515
Created February 3, 2014 13:09
Sub-modules in Zend Framework. See blog post at http://simonrjones.net/2010/06/sub-modules-in-zend-framework/
<?php
/**
* Studio 24 Application
*
* @category Studio 24
* @package S24_Application
* @copyright Copyright (c) 2009-2010 Studio 24 Ltd (www.studio24.net)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @author Simon R Jones <simon@studio24.net>
* @version 1.1
<?php
// Error reporting
error_reporting(E_ALL);
ini_set('display_errors', true);
// Return the Apache user
$tmpFilename = tempnam('/tmp', 'TEST');
$handle = fopen($tmpFilename, 'w');
fwrite($handle, 'testdata');
fclose($handle);
@simonrjones
simonrjones / HTML5 novalidate
Last active December 30, 2015 21:39
Bookmarklet to remove HTML5 validation from any forms on a page. Useful for testing.
<a href="javascript:var f%3Ddocument.getElementsByTagName(%27form%27)%3Bfor (var i%3D0%3B i<f.length%3Bi%2B%2B)%7Bf%5Bi%5D.setAttribute(%27novalidate%27,%27novalidate%27)%3B%7D">HTML5 novalidate</a>