Skip to content

Instantly share code, notes, and snippets.

@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-- / 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

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-- / 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
@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-- / 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-- / tomEditable.js
Created October 29, 2013 20:51
jQuery plugin makes DOM elements with contenteditable attribute trigger a change event when their contents change.
/**
* Makes contenteditable elements within a container generate change events.
*
* When you do, e.g. $obj.editable(), all the DOM elements with attribute contenteditable
* that are children of the DOM element $obj will trigger a change event when their
* contents is edited and changed.
*
* See: http://html5demos.com/contenteditable
*
* @return {*}
@tom--
tom-- / colored-fenced-code-blocks-in-nanoc.md
Last active December 27, 2015 12:59
Rendering fenced code blocks in Markdown files in nanoc using redcarpet with a custom renderer to run the code through pygments.

The standard redcarpet renderer generates code blocks like <pre><code class="ruby">... instead of the W3C-standard <pre><code class="language-ruby">.... This means the nanoc ColorizeSyntax Filter cannot cope with standard output from redcarpet.

One way to fix this is to customize the redcarpet renderer to generate colorized code blocks and skip the nanoc ColorizeSyntax Filter. The redcarpet readme shows how to extend its HTML renderer to do it. I put the custom renderer class in my nanoc /lib dir like this:

In /lib/default.rb

require 'redcarpet'
@tom--
tom-- / aliases
Last active December 28, 2015 19:49
OpenSMTPD config
root: my@emailaddress.foo