Skip to content

Instantly share code, notes, and snippets.

View hamishcampbell's full-sized avatar
🚀
rockets

Hamish Campbell hamishcampbell

🚀
rockets
View GitHub Profile
@hamishcampbell
hamishcampbell / gist:873351
Created March 16, 2011 21:27
ParserRegexp state before Apache (windows) crash
object(ParserRegexp)[30]
public 'parser' =>
object(SSTemplateParser)[29]
protected 'includeDebuggingComments' => boolean false
protected 'match_Template_typestack' =>
array
0 => string 'Template' (length=8)
protected 'match_Word_typestack' =>
array
0 => string 'Word' (length=4)
@hamishcampbell
hamishcampbell / gist:872020
Created March 16, 2011 04:34
Example of a regex expression that crashes Apache on Windows
<?php
$rx = <<<'RX'
/
(
(\\.) | # Any escaped character
([^<${]) | # Any character that isn't <, $ or {
(<[^%]) | # < if not followed by %
($[^A-Za-z_]) | # $ if not followed by A-Z, a-z or _
({[^$]) | # { if not followed by $
({$[^A-Za-z_]) # {$ if not followed A-Z, a-z or _
@hamishcampbell
hamishcampbell / SilverStripeBuildUpdater.sh
Created March 6, 2011 22:11
Simple Bash script to automate updating of SilverStripe build submodules.
branches=( master 2.4 )
modules=( sapphire cms themes )
for branch in "${branches[@]}"
do
echo "================"
echo "Updating $branch"
echo "----------------"
echo " * pull"
git pull 1> /dev/null
@hamishcampbell
hamishcampbell / gist:837545
Created February 21, 2011 19:18
Example statement to determine linear chainage from line segment (PostgreSQL + PostGIS)
/**
* @lon = longitude of selected point
* @lat = latitude of selected point
*/
SELECT
name,
CAST(
offset +
ST_Length(the_geom) * ST_Line_Locate_Point(the_geom, ST_Point(@lon, @lat))
) AS Double)