Skip to content

Instantly share code, notes, and snippets.

View ringmaster's full-sized avatar

Owen Winkler ringmaster

View GitHub Profile
<?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);
@ringmaster
ringmaster / test.plugin.php
Last active December 16, 2015 20:19
Alter the login form.
<?php
public function action_modify_form_habari_login(FormUI $form) {
// Remove the reset message
$form->remove($form->reset_message);
// Create a ul wrapper that wraps its children in li's
$buttons = $form->append(FormControlWrapper::create('buttons')->set_setting('wrap_element', 'ul')->set_setting('wrap_each', '<li>%s</li>'));
// Move the login button from the dropbutton to the button wrapper we just created
$form->move_into($form->login, $buttons);
// Remove the dropbutton
$form->remove($form->submit_button);
@ringmaster
ringmaster / test.plugin.php
Created April 26, 2013 17:46
Add tests to a plugin.
public function filter_list_unit_tests($tests)
{
$unit_tests = glob(dirname(__FILE__). '/units/test_*.php');
$tests = array_merge($tests, $unit_tests);
return $tests;
}
/**
* Add objects or functions to the post-processing queue, executed via self::process_queue()
* @param QueryRecord|Callable $fn A QueryRecord to call ->update() on, or a function to execute
* @param null|string $name An index to save the queue under, defaults to the SPL object hash for objects
*/
public static function queue($fn, $name = null)
{
if(is_null($name) && is_object($fn)) {
$name = spl_object_hash($fn);
}
@ringmaster
ringmaster / form.php
Last active December 15, 2015 03:19
Form Sample Code
<?php
FormUI::register('registered_form', function(FormUI $form) {
$wrap = $form->append(FormControlWrapper::create('wrap')->set_wrap_each('<div>%s</div>'));
$wrap->append(FormControlLabel::wrap('Sample 1:', new FormControlText('sample1', 'sample1')));
$wrap->append(FormControlLabel::wrap('Right-side label', new FormControlText('sample2', 'sample2'))->set_template('control.label.onright'));
$wrap->append(FormControlLabel::wrap('Custom right-side label', new FormControlText('sample3', 'sample3'))->set_template_html(function($theme, $control) {
return $theme->content . '<label ' . $theme->_attributes . '>' . $theme->label . '</label>';
}));
});
@ringmaster
ringmaster / dabblet.css
Created March 17, 2013 04:32 — forked from michaeltwofish/dabblet.css
tiger in the snow (HTML5)
/**
* tiger in the snow (HTML5)
*/
figure {
min-width: 178px;
/** outline: solid 1px red; /* uncomment rule to see figure outline */
position: relative;
}
img {
max-width: 100%;