Skip to content

Instantly share code, notes, and snippets.

@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')

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
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;
@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
@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 / 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({