Skip to content

Instantly share code, notes, and snippets.

@tom--
tom-- / tom__ Dark Mellow.icls
Created October 11, 2013 14:36
JetBrains IDEA color scheme. Devised by a PhpStorm user.
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="tom-- Dark Mellow" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.3" />
<font>
<option name="EDITOR_FONT_NAME" value="Consolas" />
<option name="EDITOR_FONT_SIZE" value="12" />
</font>
<font>
<option name="EDITOR_FONT_NAME" value="Andale Mono" />
<option name="EDITOR_FONT_SIZE" value="11" />
@tom--
tom-- / .vimrc
Created September 7, 2013 17:06
serialize and unserialize PHP expressions in vim
vmap <leader>s <esc>:'<,'> !php -r 'echo serialize(eval("return " . file_get_contents("php://stdin") . ";"));'<CR>
vmap <leader>u <esc>:'<,'> !php -r 'var_export(unserialize(file_get_contents("php://stdin")));'<CR>
@tom--
tom-- / dumpGlobals.php
Last active July 8, 2022 02:09
Inspect your globals. Include this file to display any globals that might be defined. Maybe exit() afterwards.
<?php
/**
* Inspect your globals.
*
* Include this file to display any globals that might be defined. Maybe exit() afterwards.
*
* @author Tom Worster <fsb@thefsb.org>
* @link https://gist.github.com/tom--/5876699
* @copyright Copyright © 2013 Tom Worster
* @license BSD 2-clause http://opensource.org/licenses/BSD-2-Clause

The plan

Initial status:

M1  -->  S1       <- Old hardware running 5.0 to be replaced 


S2       S3       <- New hardware runnign 5.5 to replace the old.

Transitional status:

@tom--
tom-- / Row number in a Yii CGridView.php
Created May 19, 2013 23:33
Row number in a Yii CGridView. The row number is that of the row in the data provider's overall data set.
<?php
/** @var CController $controller */
$controller->widget(
'zii.widgets.grid.CGridView',
array(
'columns' => array(
array(
'header' => 'Row',
'value' => '$row + ($this->grid->dataProvider->pagination->currentPage
@tom--
tom-- / fun with data uri.php
Last active December 16, 2015 02:39
More fun with `data:` URIs.
<?php
$x = "Hello world!";
$y = include(
'data:application/x-php;charset=utf8,<?php return'
. var_export($x, true)
.';'
);
@tom--
tom-- / Clean up stray & in XML.php
Last active December 15, 2015 20:29
Cleaning up stray & chars in a verkakte XML input document.
<?php
$input = preg_replace(
'{& (?! \#x[\da-f]{2,6} ; )
(?! \#\d{3,6} ; )
(?! [a-z0-9]{2,16} ; )
}xiu',
'&amp;',
$input
);
@tom--
tom-- / nowplaying.html
Last active December 14, 2015 13:49
Example of styling the text in a Spinitron "now playing" iframe. Description is in a comment below.
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Spinitron Playlists</title>
</head>
<body>
<p class="recentsong">
<span class="songpart"><b>Wave Guidance Allows Three</b></span>
<span class="artistpart">by <b><a target="_top" href="/public/index.php?station=wzbc&amp;dbdetail=a&amp;dbid=83733">The Swifter</a></b></span>
@tom--
tom-- / detect url regex.php
Last active December 14, 2015 02:49
detecting urls
<?php
$letnum = '\p{L}\p{Mn}\p{Mc}\p{Nd}';
$sym = '+&@#/%=~_|$';
$pnct = '?!:,.-';
$c1 = "[$letnum$sym$pnct]";
$c2 = "[$letnum$sym]";
// then the regex pattern is, so to speak:
// \b(?: https?:// | www\. ) (?: \($c1*\) | $c1 )* (?: \($c1*\) | $c2 )
// with xui options.