Skip to content

Instantly share code, notes, and snippets.

View ringmaster's full-sized avatar

Owen Winkler ringmaster

View GitHub Profile
@ringmaster
ringmaster / results.csv
Created September 6, 2013 14:48
rework-autoloader results
run no autoloader cache APC
1 0.82526803 1.097486973
2 0.341663837 0.340631008
3 0.356065035 0.341625929
4 0.391163111 0.354048967
5 0.349993944 0.322378874
6 0.399251938 0.341935158
7 0.538627148 0.374629021
8 0.362586021 0.437278986
9 0.354948997 0.395817995
@ringmaster
ringmaster / timetest.php
Last active December 22, 2015 08:08
Autoloader tests
<?php
global $RUNTIME_NOAPPS;
$RUNTIME_NOAPPS = true;
define('PHPUNIT_RUN', 1);
require_once __DIR__.'/lib/base.php';
require_once __DIR__.'/lib/autoloader.php';
@ringmaster
ringmaster / gist:6346828
Created August 26, 2013 21:24
ownCloud clean script
#!/bin/bash
pushd /c/xampp/htdocs/vdr/master.oc.claire/htdocs
rm config/config.php
mysqladmin -f -s -uroot drop oc_master
mysqladmin -f -s -uroot create oc_master
rm -rf data/*
rm -rf data/.htaccess
#echo "<?php
#\$AUTOCONFIG = array(
# 'dbtype' => 'mysql',
@ringmaster
ringmaster / gist:6342696
Created August 26, 2013 15:26
Relevant parts of vhost config for XSendFile
SetEnv MOD_X_SENDFILE_ENABLED 1
XSendFile On
XSendFilePath /tmp/oc-noclean
@ringmaster
ringmaster / myplugin.plugin.php
Last active December 18, 2015 18:39
How Habari implments the WordPress code shown here: http://codex.wordpress.org/Settings_API
<?php
namespace Habari;
class MyPlugin extends Plugin
{
/* Implementing this function modifies the admin options form */
public function action_modify_form_admin_options(FormUI $form) {
// Add a wrapper for a new "example" section before the form buttons
<?php
//...
public function filter_final_output($buffer)
{
$regex = '%http://[^/]+?\.static\.flickr\.com/[0-9a-f/_]+\w?\.(jpg|png|gif)%i';
if(preg_match_all($regex, $buffer, $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$hashfile = 'flickr.static.' . md5($match[0]) . '.' . $match[1];
if(!file_exists(HABARI_PATH . '/user/files/' . $hashfile)) {
PREFIX terms:<http://wiktionary.dbpedia.org/terms/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc:<http://purl.org/dc/elements/1.1/>
SELECT ?swordRes ?sword ?slang ?spos
FROM <http://wiktionary.dbpedia.org>
WHERE {
?swordRes rdfs:label ?sword .
?swordRes dc:language <http://wiktionary.dbpedia.org/terms/English> .
?swordRes dc:language ?slang .
?swordRes terms:hasPoS ?spos .
function test_scrape_allconsuming() {
$out = array();
for($x = 1;$x <= 43; $x++) {
$p = file_get_contents('http://www.allconsuming.net/person/mikelietz/consumed/book?page=' . $x);
$h = \Habari\HTMLDoc::create($p);
foreach($h->find('strong a') as $node) {
if(preg_match('#^/item/view/#', $node->href, $matches)) {
$p = file_get_contents('http://www.allconsuming.net' . $node->href);
$h2 = \Habari\HTMLDoc::create($p);
$as = $h2->find('a');
public function action_before_act_admin( ) {
$this->add_template('dashboard', dirname(__FILE__) . '/templates/dash.php', true);
}
$form->insert($form->label_for_habari_username, $inputs = FormControlFieldset::create('inputs'));
$form->move_into($form->label_for_habari_username, $inputs);
$form->move_into($form->label_for_habari_password, $inputs);