Skip to content

Instantly share code, notes, and snippets.

View dantman's full-sized avatar

Daniel Friesen dantman

View GitHub Profile
1 Aggregator
1 Auth_remoteuser
1 Citation
1 Description
1 DisableSpecialPages
1 EnhanceContactForm
1 FootNote
1 FormPreloadPostCache
1 GlobalNotice
1 GoogleDocs4MW
@dantman
dantman / lang.php
Created October 22, 2011 23:03
lang.php to parse accept-lang and return it as json for js to fetch and handle
<?php
define('MEDIAWIKI', 1);
require_once dirname( __FILE__ ) . '/languages/Names.php';
require_once dirname( __FILE__ ) . '/includes/json/FormatJson.php';
// Based on http://www.thefutureoftheweb.com/blog/use-accept-language-header
$langs = array();
if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
// break up string into pieces (languages and q factors)
@dantman
dantman / HOWTOUSE
Created November 19, 2011 06:50
Script to deobfuscate MediaWiki svn USERINFO emails
- Checkout the svn USERINFO folder into a directory.
- Setup this script right next to it and cd to that directory.
((ie: You should have ./USERINFO and ./useremails.rb sitting in front of you))
((Note: Users who don't have an e-mail set are omitted from outputs))
- `ruby useremails.rb` will give you a list of svn users, their name, and e-mail
- `ruby useremails.rb list` will give you that same list but in a comma separated "Name <email>" format
- `ruby useremails.rb obfuscated` will filter the list to only users who have obfuscated their e-mail
- `ruby useremails.rb obfuscated list` will take that filtered list and put it in the "Name <email>" format
@dantman
dantman / Scalar.skin.php
Created February 27, 2012 23:58
Scalar skin (Example of a Vector derived skin)
<?php
/**
* Scalar
*
* @file
* @ingroup Skins
*/
if( !defined( 'MEDIAWIKI' ) )
die( -1 );
<?php
namespace Gareth\GarethWebBundle\Libs;
class GarethGit {
private $path;
public function __construct( $path ) {
$this->path = $path;
@dantman
dantman / gist:3115181
Created July 15, 2012 05:38
Closure based result iterator
<?php
class Application {
// [...]
function getOwners() {
$res = $db->select(
array( 'user', 'application_owner' ),
User::selectFields(),
array( 'ao_app' => $this->getID() ),
__METHOD__,
null,
@dantman
dantman / gist:3333040
Created August 12, 2012 17:10
MediaWiki Notification System Intro
var time = 0;
[
[ 0, 'This is the new notification system.' ],
[ 6, 'As you can see it has autohide just like the previous one.' ],
[ 6, 'And clicking on a message will also hide it just like before.' ],
[ 6, 'But this time arround.' ],
[ 1, 'We support multiple messages.' ],
[ 2, 'Any sane number of them, really.' ],
[ 6, 'Auto-hide is good and all. But frankly sometimes you just HAVE to have a notification stick around.' ],
[ 1, 'This one uses { autoHide: false }', { autoHide: false } ],
@dantman
dantman / TemplateParser.php
Created October 24, 2012 03:14
New templated skin parser attempt
<?php
class TemplateNode {
}
class TemplateText extends TemplateNode {
}
class TemplateCondition extends TemplateNode {}
@dantman
dantman / gist:5273637
Last active December 15, 2015 14:19
Typical RL definition for skins.
<?php
$wgResourceModules['skins.yourskin'] = array(
'styles' => array(
'yourskin/yourskin.css' => array( 'media' => 'screen' ),
),
'remoteBasePath' => &$GLOBALS['wgStylePath'],
'localBasePath' => &$GLOBALS['wgStyleDirectory'],
);
@dantman
dantman / gevent-stompest-pingpong.py
Created April 2, 2013 07:06
Ping-Pong STOMP server. Demonstrating stompest with gevent.
import logging, gevent
from gevent import monkey
from stompest.config import StompConfig
from stompest.protocol import StompSpec
from stompest.sync import Stomp
## Ideally this code (or something like it) would work without the following two lines
monkey.patch_socket()
monkey.patch_select()