Skip to content

Instantly share code, notes, and snippets.

View chrismeller's full-sized avatar

Chris Meller chrismeller

View GitHub Profile
@chrismeller
chrismeller / gist:630321
Created October 16, 2010 22:01
Habari Taxonomy Structure Example
<?php
class Term extends QueryRecord {
protected $vocabulary; // set by child classes to indicate which vocabulary your term relates to
// these two would be emulated by __get() and __set() so that they're actually stored in $this->fields
// for QueryRecord to work but this would be the public API
public $term; // the slugified version of the term name
public $display; // the raw term name for display
<?php
$file = $argv[1];
$type = isset( $argv[2] ) ? $argv[2] : 'php';
$contents = file_get_contents( $file );
$url = 'http://localhost/test/post.php';
$options = array(
<?php
$results = $db->get_results( 'select name, value from options' );
$options = new stdClass();
foreach ( $results as $result ) {
$options->{$result->name} = $result->value;
}
<?php
define('UNIT_TEST', true);
include('index.php');
header( 'Content-Type: text/html;charset=utf-8' );
$url = '&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#1087;&#1088;&#1080;&#1084;&#1077;&#1088;&#46;&#1080;&#1089;&#1087;&#1099;&#1090;&#1072;&#1085;&#1080;&#1077;';
$url = html_entity_decode( $url, null, 'UTF-8' );
Utils::debug($url);
<?php
// connect
$connect_start = microtime(true);
try {
$pdo = new PDO('sqlite:test.db');
}
catch ( PDOException $e ) {
die('Unable to connect: ' . $e->getMessage());
}
@chrismeller
chrismeller / gist:949786
Created April 30, 2011 16:32
Problematic Rewrite Rules
public function filter_rewrite_rules ( $rules ) {
$rule = new RewriteRule( array(
'name' => 'cwm_display_archives',
'parse_regex' => '#^archives(?:/page/(?P<page>\d+))?/?$#i',
'build_str' => 'archives(/page/{$page})',
'handler' => 'UserThemeHandler',
'action' => 'display_archives',
'rule_class' => RewriteRule::RULE_THEME,
'is_active' => true,
@chrismeller
chrismeller / gist:1140353
Created August 11, 2011 18:26
Overlapping Habari Commit Hashes
HASH COMMIT
00a6 00a69b35173d5ac367ca282c167cddab8b554064
00a6 00a6c567eaa288de9d94dee8f251e2e99920a75c
02cf 02cf229b82fda17f59c6170f4a5d3ba41c220573
02cf 02cf91971a90548235bef7d31cba058db3a5c716
07ac 07ac368b59b33a537ec793fec086f986e3473d47
07ac 07acb13b737f2bdabc23ed9a07b20a4e1a18729d
0906 090646ee533cd1fc5fae39581df88b934458a059
0906 0906bff20ecc9b8fa66f4d248c76f223d357e2f5
0dd8 0dd80abcf189ec35eca7bc8d2ae6abcb05600e34
@chrismeller
chrismeller / gist:1140356
Created August 11, 2011 18:27
Overlapping Habari Commit Hash Counts
HASH COMMIT COUNT
00a6 00a69b35173d5ac367ca282c167cddab8b554064 2
02cf 02cf229b82fda17f59c6170f4a5d3ba41c220573 2
07ac 07ac368b59b33a537ec793fec086f986e3473d47 2
0906 090646ee533cd1fc5fae39581df88b934458a059 2
0dd8 0dd80abcf189ec35eca7bc8d2ae6abcb05600e34 2
0f97 0f976c555c29cf420537c63e0334a54c76543c65 2
1303 13036656fb6289706a059ea15f3e969cb066138d 2
136f 136f9e0778bde254ca9bad8c52ad3a05138ad0e8 2
1462 146286403f696bb344be4ac2ae6adbd43b9b13f8 2
@chrismeller
chrismeller / gist:1140359
Created August 11, 2011 18:28
Overlapping Habari Commit Hash Counts - 5 Chars
HASH COMMIT COUNT
43154 43154137f351ee531a9711cdbb34c5408f98ff5a 2
88d57 88d5724e70318501536db8f82a228585a41b0535 2
b6533 b6533328308a402cea339a05c5a538a539a0207f 2
cbb41 cbb41110ba0244d592255be1a83f4c2871d0e05f 2
<?php
if ( !isset( $_GET['type'] ) ) {
$type = 'json';
}
else {
$type = $_GET['type'];
}
switch ( $type ) {