Skip to content

Instantly share code, notes, and snippets.

@slaporte
slaporte / anon_edit.js
Created May 8, 2012 20:26
WP anon api edits
var sendData = {
action: 'edit',
format: 'json',
title: 'User:Slaporte/sandbox',
text: 'test',
summary: 'test',
token: '+\\'
};
$.ajax({
@slaporte
slaporte / iframe api edit
Created May 9, 2012 09:01
Using an iframe to post an anon edit to wp api
var sendData = {
action: 'edit',
format: 'json',
title: 'User:Slaporte/sandbox',
text: 'test',
summary: 'test',
token: '+\\'
};
function iframe_post(url, data) {
@slaporte
slaporte / recentchanges_monitor.py
Created June 14, 2012 05:21
monitor wikipedia recentchanges feed with twisted
# some code from Twisted Matrix's irc_test.py
from twisted.words.protocols import irc
from twisted.internet import reactor, protocol
import time, sys, re, datetime
CHANNEL = 'en.wikipedia' # use language.project
def process_message(message):
color_re = re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?", re.UNICODE) # remove IRC color codes
var GLOBAL_TIMEOUT = 26000; // milliseconds
var jsdom = require('jsdom');
var dummy_window = jsdom.jsdom().createWindow();
dummy_window.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
var jq_lib = require('jquery');
var $ = jq_lib.create(dummy_window);
$.support.cors = true;
var extend = $.extend;

Prefixes

  • ah: article history template
  • a: assessment template
  • bl: backlinks via wikipedia api
  • d: dom
  • f4: article feedback v4 (ratings)
  • f5: article feedback v5 (comments)
  • gn: google news results
  • gs: google search results
  • pv: page views
@slaporte
slaporte / fomp_constructor.py
Created October 6, 2012 20:56
fomp constructor for orange
import Orange
from Orange import orange
attributes = [a for a in in_data.domain.attributes if 'trimmed' not in a.name and 'kurtosis' not in a.name and 'skewness' not in a.name and 'variance' not in a.name and not a.name.startswith('rv_')]
fomp = Orange.feature.Discrete("fomp", values=['True', 'False'])
def check_fomp(inst, return_what):
try:
if inst['ah_mainpage_age'] > 0 and inst['ah_current'] == 'FA':
return fomp('True')
== Learner results ==
CA Sens Spec AUC IS F1 Prec Recall Brier MCC
d_Earth 0.7581 0.7806 0.7352 0.8354 0.3776 0.7646 0.7493 0.7806 0.3384 0.5164
d_CN2 0.7244 0.8544 0.5925 0.7783 0.1917 0.7574 0.6801 0.8544 0.4005 0.4635
rv_wo_Earth 0.7452 0.8220 0.6674 0.8179 0.3347 0.7646 0.7147 0.8220 0.3821 0.4955
rv_all_Earth 0.7330 0.7368 0.7290 0.8215 0.3455 0.7353 0.7338 0.7368 0.3464 0.4659
rv_all_CN2 0.7389 0.8893 0.5863 0.8013 0.2613 0.7742 0.6855 0.8893 0.3669 0.4996
rv_t_Earth 0.6711 0.6638 0.6785 0.7191 0.1729 0.6702 0.6767 0.6638 0.4307 0.3423
links_Earth 0.6321 0.6610 0.6028 0.6837 0.1221 0.6440 0.6279 0.6610 0.4505 0.2643
[('w_per_d_int_link_text_mean', (6.0, 99.999999999999986, 100.0)), ('w_per_d_spoken_wp_count', (5.0, 22.577742708935169, 23.770124639507372)), ('w_per_d_h2_text_rel_std_dev', (4.0, 14.471598650263878, 15.482189959570947)), ('w_per_d_caption_word_mean_trimmed', (3.0, 5.7619132808119673, 6.6283144220189563))]
[('d_word_count', (6.0, 100.0, 99.999999999999986)), ('d_thumb_right_count', (5.0, 22.179757861855681, 23.332685527701166)), ('d_spoken_wp_count', (4.0, 13.471589052699164, 14.463359298026649)), ('d_h2_text_rel_std_dev', (3.0, 7.1381725095355932, 7.9374177678378803))]
[('d_word_count', (14.0, 100.0, 100.0)), ('d_thumb_right_count', (13.0, 31.302728818298792, 33.166031248246895)), ('d_spoken_wp_count', (12.0, 23.571797752505049, 25.434284334151592)), ('d_h2_text_rel_std_dev', (11.0, 17.937711328380029, 19.745359721277694)), ('d_p_median', (10.0, 12.91909193432876, 14.663181514100341)), ('d_has_notes_sect', (9.0, 10.486430177615439, 12.083929495472743)), ('d_cite_journal', (8.0, 8.1500972384260066, 9.60310
media_attrs = ['d_all_img_count',
'd_geo_count',
'd_image_map_count',
'd_ipa_count',
'd_midi_count',
'd_ogg_count',
'd_pdf_count',
'd_spoken_wp_count',
'd_svg_count',
@slaporte
slaporte / stat_lists.py
Created November 18, 2012 07:46
qualityvis stat lists
structure = [
'd_fr_sect_count',
'd_has_ext_link_sect',
'd_has_notes_sect',
'd_has_ref_sect',
'd_ext_link_sect_li_count',
'd_thumb_left_count',
'd_thumb_right_count',
'd_int_link_text_count',