Skip to content

Instantly share code, notes, and snippets.

@saurini
saurini / closure_migation.php
Last active December 19, 2015 00:49
A quick migration script to convert the hierarchy stored in a badly-made path enumeration table to a closure table. Since there were no root nodes in the old table, I made some new ones to contain everything.
<?php
/*
* Convert the path enumeration of depts from dept_assign to closure table
*/
class Department {
public $dept_code;
@saurini
saurini / shortcodes.php
Created September 19, 2012 09:37
Github for WordPress
<?php
// Inserts an embedded gist into the content usage [gist id="12345"]
function saurini_gist_func( $atts ){
extract(shortcode_atts(array(
'id' => '1337'), $atts));
// Only allow gist ids that are letters or numbers
if ( preg_match( '/[^0-9^a-z^A-Z]/', $id ) )
return;