Skip to content

Instantly share code, notes, and snippets.

@tom--
tom-- / .borisrc
Created July 19, 2014 15:56
Start the wonderful Boris PHP REPL (https://github.com/d11wtq/boris) with Yii2. Handy for trying things out. Both files go in my home directory
<?php
require __DIR__ . '/startYii2.php';
$boris->setPrompt('yii2> ');
@tom--
tom-- / i18nStrings.php
Created March 7, 2014 19:07
i18n strings
<?php
$i18nStrings = array(
'Iñtërnâtiônàlizætiøn',
'החמאס: רוצים להשלים את עסקת שליט במהירות האפשרית',
'ايران لا ترى تغييرا في الموقف الأمريكي',
'独・米で死傷者を出した銃の乱射事件',
'國會預算處公布驚人的赤字數據後',
'이며 세계 경제 회복에 걸림돌이 되고 있다',
'В дагестанском лесном массиве южнее села Какашура',
@tom--
tom-- / Vagrantfile
Last active August 29, 2015 13:56
Two stage bootstrap of a Vagrant/Ansible provisioning environment to get rid of the insecure vagrant user account.
require 'yaml'
$ansible_vars = YAML.load_file('group_vars/all')
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.network :public_network
if ENV['FIRSTRUN'] != 'true'
config.vm.synced_folder ".", "/home/www"
config.ssh.username = $ansible_vars['unpriv_user']
@tom--
tom-- / Generic Colouriser php
Created January 14, 2014 16:49
Config of Generic Colouriser for php and yii logs. http://kassiopeia.juls.savba.sk/~garabik/software/grc.html
regexp=\] PHP [^\s]+ error:
colours=red
count=block
---
regexp=\] PHP Notice:
colours=yellow
count=block
---
regexp=\] PHP Warning:
colours=cyan
@tom--
tom-- / bash_prompt_fancy.sh
Last active June 8, 2018 23:54
A fancy bash prompt. Put it in your .bashrc
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
bold=$(tput bold)
dim=$(tput dim)
off=$(tput sgr0)
thumb () {
case $1 in
0) printf "\xF0\x9F\x91\x8d" ;;
*) printf "\xF0\x9F\x91\x8e $red($1)$off" ;;
@tom--
tom-- / cubrid join queries.txt
Created December 26, 2013 14:13
#cubrid discussion about join queries. see http://thefsb.tumblr.com/post/50437998370/
09:40 Topic is CUBRID Open source database highly optimized for Web applications || http://www.cubrid.org || CUBRID manual http://www.cubrid.org/manual/841/en || For questions also see: http://www.cubrid.org/questions
09:40 Set by eusto on July 19, 2012 11:31:26 AM EDT
09:40 Mode is +cnt
10:48 tom[]: not really a cubrid q but since the peeps here are so clever: http://thefsb.tumblr.com/post/50437998370
10:49 tom[]: How to get query results in normal form from a schema in normal form?
10:52 @rimio: tom[]: the guy likes to emulate a planner :)
10:53 tom[]: the guy being me :P
10:53 @rimio: :))
10:53 tom[]: isn't this an old question in SQL databases?
10:54 @rimio: might be, dunno
@tom--
tom-- / MyDbCriteria.php
Last active December 30, 2015 20:19
MyDbCriteria adds prefix match searching to Yii’s CDbCriteria
<?php
class MyDbCriteria extends CDbCriteria
{
/**
* Adds a prefix match comparison to the {@link CDbCriteria::condition} property.
* The search condition is of the form
* - "column LIKE 'value%'", or
* - "column NOT LIKE 'value%'"
* depending onthe $like parameter.
@tom--
tom-- / aliases
Last active December 28, 2015 19:49
OpenSMTPD config
root: my@emailaddress.foo
@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-- / 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 {*}