Skip to content

Instantly share code, notes, and snippets.

View catrope's full-sized avatar

Roan Kattouw catrope

  • Wikimedia Foundation
  • San Francisco, CA
View GitHub Profile
@catrope
catrope / gist:1208442
Created September 10, 2011 15:35
Attempted fix for AFT counter drift bug
Index: api/ApiArticleFeedback.php
===================================================================
--- api/ApiArticleFeedback.php (revision 96655)
+++ api/ApiArticleFeedback.php (working copy)
@@ -164,6 +164,13 @@
*/
private function insertRevisionRating( $pageId, $revisionId, $lastRevision, $ratingId, $updateAddition, $thisRating, $lastRating ) {
$dbw = wfGetDB( DB_MASTER );
+
+ // Fix previous logic bug: if the revision IDs of the previous and current ratings are NOT the same,
@catrope
catrope / gist:1230081
Created September 20, 2011 19:29
Undo RTL flipping for IE60Fixes rules
Index: skins/monobook/IE60Fixes.css
===================================================================
--- skins/monobook/IE60Fixes.css (revision 97651)
+++ skins/monobook/IE60Fixes.css (working copy)
@@ -11,16 +11,30 @@
margin-top: 3em;
height: 1%;
}
+.rtl div#column-content div#content {
+ margin-right: 12.2em;
@catrope
catrope / gist:1238478
Created September 23, 2011 21:25
Make formatTimePeriod() more flexible
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 97909)
+++ languages/messages/MessagesEn.php (working copy)
@@ -3656,10 +3656,15 @@
# Video information, used by Language::formatTimePeriod() to format lengths in the above messages
'video-dims' => '$1, $2×$3', # only translate this message to other languages if you have to change it
-'seconds-abbrev' => 's', # only translate this message to other languages if you have to change it
-'minutes-abbrev' => 'm', # only translate this message to other languages if you have to change it
Index: includes/HistoryBlob.php
===================================================================
--- includes/HistoryBlob.php (revision 98216)
+++ includes/HistoryBlob.php (working copy)
@@ -516,13 +516,17 @@
$header = unpack( 'Vofp/Vcsize', substr( $diff, 0, 8 ) );
# Check the checksum if mhash is available
+ # TEMPORARY WMF PATCH -- temporarily disable hash check, since a large number of
+ # revisions appear to have hash mismatches
@catrope
catrope / gist:1247811
Created September 28, 2011 12:29
Proposed hack for iOS API issue
Index: includes/parser/ParserCache.php
===================================================================
--- includes/parser/ParserCache.php (revision 98303)
+++ includes/parser/ParserCache.php (working copy)
@@ -50,7 +50,7 @@
// idhash seem to mean 'page id' + 'rendering hash' (r3710)
$pageid = $article->getID();
- $renderkey = (int)($wgRequest->getVal('action') == 'render');
+ $renderkey = (int)($wgRequest->getVal('action') == 'render') + 2*(int)($wgRequest->getVal('action') == 'parse');
@catrope
catrope / gist:1249390
Created September 28, 2011 22:06
es.DocumentModel.newFromPlainObject
/* Output (copypaste to Firebug to view):
{"data":[{"type":"document","node":null},{"type":"heading","attributes":{"level":1},"node":null},"T","h","i","s"," ","i","s"," ","a"," ",["h",{"type":"italic"}],["e",{"type":"italic"}],["a",{"type":"italic"}],["d",{"type":"italic"}],["i",{"type":"italic"}],["n",{"type":"italic"}],["g",{"type":"italic"}]," ","(","l","e","v","e","l"," ","1",")",{"type":"/heading","node":null},{"type":"heading","attributes":{"level":2},"node":null},"T","h","i","s"," ","i","s"," ","a"," ",["h",{"type":"italic"}],["e",{"type":"italic"}],["a",{"type":"italic"}],["d",{"type":"italic"}],["i",{"type":"italic"}],["n",{"type":"italic"}],["g",{"type":"italic"}]," ","(","l","e","v","e","l"," ","2",")",{"type":"/heading","node":null},{"type":"heading","attributes":{"level":3},"node":null},"T","h","i","s"," ","i","s"," ","a"," ",["h",{"type":"italic"}],["e",{"type":"italic"}],["a",{"type":"italic"}],["d",{"type":"italic"}],["i",{"type":"italic"}],["n",{"type":"italic"}],["g",{"type":"italic"}]," ","
@catrope
catrope / gist:1328815
Created October 31, 2011 20:30
es.DocumentNode.prototype.selectNodes
/**
* Gets a list of nodes and their sub-ranges which are covered by a given range.
*
* @method
* @param {es.Range} range Range to select nodes within
* @returns {Array} List of objects with 'node' and 'range' properties describing nodes which are
* covered by the range and the range within the node that is covered
*/
es.DocumentNode.prototype.selectNodes = function( range ) {
var nodes = [], i, left, right, start, end, startInside, endInside;
[2013-04-03 22:31:43 PDT] catrope@roanS9:~$ cat crash.js
var a = {};
a.b = a;
alert( JSON.stringify( a, function ( key, val ) {
// This technically needs an if statement to check that val is an object or array,
// but for this test it doesn't matter
var normalized = {}, keys = Object.keys( val ).sort(), i = 0, len = keys.length;
for ( ; i < len; i++ ) {
normalized[keys[i]] = val[keys[i]];
}
diff --git a/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/runtime/JSONObject.cpp b/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/runtime/JSONObject.cpp
index 27a508a..daeb4e9 100644
--- a/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/runtime/JSONObject.cpp
+++ b/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/runtime/JSONObject.cpp
@@ -370,6 +370,7 @@ inline JSValue Stringifier::toJSON(JSValue value, const PropertyNameForFunctionC
Stringifier::StringifyResult Stringifier::appendStringifiedValue(UStringBuilder& builder, JSValue value, JSObject* holder, const PropertyNameForFunctionCall& propertyNa
{
+ JSValue oldValue = value;
// Call the toJSON function.
@catrope
catrope / gist:5359763
Created April 11, 2013 00:49
Test class for handling own children
/*!
* VisualEditor DataModel MWEntityNode class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* DataModel MediaWiki image node.
*