Skip to content

Instantly share code, notes, and snippets.

View ringmaster's full-sized avatar

Owen Winkler ringmaster

View GitHub Profile
@ringmaster
ringmaster / gist:5065881
Created March 1, 2013 16:35
Get Habari posts ordered by how many comments they have
$presets['most_comments'] = array(
'on_query_built' => function(Query $query) {
$query->join('LEFT JOIN {comments} c ON c.post_id = {posts}.id');
$query->groupby('{posts}.id');
$query->orderby('count(c.id) DESC');
}
);
if ( $token['type'] == HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE ) {
if(count($stack) > 0 && in_array($token['name'], Utils::array_map_field($stack, 'name'))) {
do {
$end = array_pop( $stack );
$end['type'] = HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE;
$end['attrs'] = null;
$end['value'] = null;
$summary[] = $end;
} while ( ( $bail || $end['name'] != $token['name'] ) && count( $stack ) > 0 );
}

Habari Hosting

We are working on producing a platform that will allow users to sign up for hosted Habari service, much like sites such as wordpress.com or tumblr.com. To do this, we would like to produce a single page sell sheet that briefly explains the platform and provides a form for the user to submit that will immediately configure their hosted Habari site and direct them to it.

This sell sheet should be one page, and have coloring conistent with the Habari brand (monochrome, gray). It should at a minimum include a Habari logo at the top, some description of the service provided in a paragraph below, and a form to sign up for service. A large call to action at the top of the page could draw a visitor's attention to the signup form elsewhere on the page. Some quotes of recommendation, screenshots, or other graphic embellishments would be welcome flourishes.

@ringmaster
ringmaster / config.php
Last active December 12, 2015 12:19
Host many Habaris from one directory, store configurations in a database
<?php if ( !defined( 'HABARI_PATH' ) ) { die( 'No direct access' ); }
/** User-settable stuff */
define('DEBUG', false);
define('SITEDATA_GUID', 'a random string'); // this is used for site guid for the cache and salt on the cache keys
Config::set('cache_class', 'APCCache'); // This should work with any Habari cache class that can run, including filecache
$cache_enabled = true;
/** Don't change the below */
1. Create a file at the webroot called whoami.php
2. Put this code in the whoami.php file and save it:
<?php echo `whoami`; ?>
3. Access whoami.php via the browswer to see who the user is that your web server runs as.
4. In the console, type this where {user} is the user from the whoami.php:
groups {user}
5. Observe the groups that the user belongs to. Usually it's just one. Usually it's "www-data"
6. cd to your WordPress directory
7. Run this command, change {user} to the user shown on the whoami.php page and {group} to the group from step 5 that looks like your server's group:
chown -R {user}:{group} wp-content
@ringmaster
ringmaster / gist:4693169
Last active December 12, 2015 01:39
My global git aliases
alias.st=status
alias.ci=commit
alias.br=branch
alias.co=checkout
alias.df=diff
alias.dc=diff --cached
alias.lol=log --graph --decorate --pretty=oneline --abbrev-commit
alias.lola=log --graph --decorate --pretty=oneline --abbrev-commit --all
alias.ls=ls-files
alias.ign=ls-files -o -i --exclude-standard
@ringmaster
ringmaster / gist:4674751
Created January 30, 2013 17:09
Add this to your style.css file at the end.
#menu{*zoom:1;zoom:1;border-bottom:1px solid #eaeaea;}#menu:before,#menu:after{content:"";display:table;}
#menu:after{clear:both;}
#menu:before,#menu:after{display:table;content:"";zoom:1;}
#menu:after{clear:both;}
#menu ol{list-style:none;margin-left:0;padding-left:0;}
#menu ol li{display:inline;float:left;line-height:24px;}
#menu ol li:hover{background:#582E91;}
#menu ol li:active>div>a{background-color:#582E91;font-weight:bold;}
#menu ol li ol{position:absolute;background:#582E91;z-index: 30;}
#menu ol li ol div{margin-top:10px;}
@ringmaster
ringmaster / gist:4626783
Created January 24, 2013 19:31
My Habari config file for 0.10
<?php
namespace Habari;
if ( !defined( 'HABARI_PATH' ) ) { die( 'No direct access' ); }
Config::set( 'db_connection', array(
'connection_string'=>'sqlite:habari.db',
'username'=>'',
'password'=>'',
'prefix'=>''
));
SELECT
DISTINCT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.input_formats AS input_formats,
{posts}.user_id AS user_id,
@ringmaster
ringmaster / Dead Pool
Created January 16, 2013 00:55
Here's a sample query to find people for my dead pool using SPARQL and the dbpedia.
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?name ?birth ?death ?person ?wikipedia ?occupation WHERE {
?person dbo:birthDate ?birth .
?person foaf:name ?name .
?person a dbo:Actor .
OPTIONAL {?person dbo:deathDate ?death .}
OPTIONAL {?person dbpprop:dateOfDeath ?death2 .}
FILTER (?birth < "1950-01-01"^^xsd:date)
FILTER (?birth > "1890-01-01"^^xsd:date)