Skip to content

Instantly share code, notes, and snippets.

View darkwing's full-sized avatar

David Walsh darkwing

View GitHub Profile
<% var wiki = module.exports = buildAPI({
/*
* Given a MediaWiki path attempt to update it to a Kuma path
* This is not a DekiScript function
*/
kumaPath: function(in_path) {
// Strip the base path, allows this to replace Template:getRelativeURL
path_strip = in_path.replace(RegExp('^https:\/\/developer\.mozilla\.org','i'),'');
// Get/fix/update/add language
var pathLang = (path_strip.match(/^\/?(\w{2}(?:[-|_]\w{2})?)?(?=\/)/)[1] || env.locale).replace(/^en$/i,'en-US').replace(/^(?:zh_)?cn$/i,'zh-CN').replace(/zh_tw/i,'zh-TW').replace(/^pt$/i,'pt-PT');
@darkwing
darkwing / gist:4083092
Created November 16, 2012 01:28
Stylesheet from Microsoft.com
<link rel="stylesheet" type="text/css" href="http://i.s-microsoft.com/en-us/home/style.cssx?k=~/shared/templates/Styles/reset-css.aspx;~/shared/templates/Styles/cols-css.aspx;~/shared/templates/Styles/webfont-css.aspx;~/shared/templates/Styles/type-css.aspx;~/shared/templates/Styles/layout-css.aspx;~/shared/templates/Styles/header-css.aspx;~/shared/templates/Styles/_search-css.aspx;~/shared/templates/Styles/_listoflinks-css.aspx;~/shared/templates/Styles/_menu-css.aspx;~/shared/templates/Styles/hero-css.aspx;~/shared/templates/Styles/_pivot-css.aspx;~/shared/templates/Styles/_features-css.aspx;~/shared/templates/Styles/_news-css.aspx;~/shared/templates/Styles/prefooter-css.aspx;~/shared/templates/Styles/footer-css.aspx;~/shared/templates/Styles/animations-css.aspx;~/shared/templates/Styles/feedback-css.aspx&amp;sc=/en-us/home/site.config&amp;pc=/en-us/home/PageConfig/Optimize.config.xml&amp;v=1762138064"></link>
@darkwing
darkwing / gist:3744439
Created September 18, 2012 17:23
Mozilla Developer Network Search Bookmarklet
(function()%7Bvar%20d=document,w=window,ds=d.getSelection,ws=w.getSelection,ss=d.selection,e=encodeURIComponent;t=(ws)%3Fws():(ds)%3Fds():(ss)%3Fss.createRange().text:'';t=(t.toString().length)%3Ft:prompt('What term would you like to research?','');if(t)%7Ba='https://developer.mozilla.org/en-US/search?q=';u=a+e(t);f=function()%7Bx=w.open(u,'nfx','scrollbars=1,toolbar=0,resizable=1,status=1,width=600,height=600');if(!x)w.location.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(f,0);else%20f();%7D%7D)();
// Document
{{ GetAttachmentContent() }}
// Intermediate template
<%- mdn.getFileContent(env.files[0]) %>
// Complete template:mdn:common
<% module.exports = {
parent_id = request.POST.get('parent_id', '')
# Attempt to set a parent
if show_translation_parent_block and parent_id:
try:
parent_doc = get_object_or_404(Document, id=parent_id)
doc.parent = parent_doc
except Document.DoesNotExist:
logging.debug('Could not find posted parent')
[12/Jun/2012 07:36:38] "GET /fr/__debug__/m/js/toolbar.min.js HTTP/1.1" 304 0 (time: 0.63s; sql: 0ms (0q))
[profile] Total time to render was 0.00s
[12/Jun/2012 07:36:38] "GET /en-US/jsi18n/build:dev HTTP/1.1" 200 1761 (time: 0.52s; sql: 0ms (0q))
[12/Jun/2012 07:36:40] "GET /docs/ckeditor_config.js?t=B8DJ5M3 HTTP/1.1" 301 0 (time: 0.09s; sql: 0ms (0q))
[12/Jun/2012 07:36:40] "GET /__debug__/m/css/toolbar.min.css HTTP/1.0" 301 0 (time: 0.10s; sql: 0ms (0q))
[profile] Total time to render was 0.01s
[12/Jun/2012 07:36:40] "GET /fr/__debug__/m/css/toolbar.min.css HTTP/1.1" 304 0 (time: 0.62s; sql: 0ms (0q))
[profile] Total time to render was 0.05s
[12/Jun/2012 07:36:41] "GET /fr/docs/ckeditor_config.js?t=B8DJ5M3 HTTP/1.1" 200 2118 (time: 0.71s; sql: 0ms (1q))
[profile] Total time to render was 0.01s
info: Service pid 6681 initializing
info: Service pid 6684 initializing
info: Starting up service on port 9080
info: Service pid 6686 initializing
info: Starting up service on port 9080
info: Service pid 6689 initializing
info: Starting up service on port 9080
info: Service pid 6688 initializing
info: Starting up service on port 9080
@darkwing
darkwing / gist:2838005
Created May 30, 2012 18:06
Zamboni + Vagrant Updater
#!/bin/sh
# The purpose of this file is to document the process of upgrading a vagrant
# machine for zamboni, since the VM defaults seem well out of date
# Run the post-install
chmod +x postinstall.sh
sudo ./postinstall.sh
# Create a temp folder for downloads
var cycles = 0;
var loaded = true;
var minTime = 15000;
var int = 50
var loaded = false;
$(window).load(function() {
loaded = true;
});
var MyClass = new Class({
options: {
option1: 1,
option2: 2
},
Implements: [Options,Events],
Requires: [DependencyClass1,DependencyClass2],