Skip to content

Instantly share code, notes, and snippets.

View notconfusing's full-sized avatar

Max Klein notconfusing

View GitHub Profile
var socket = io.connect('stream.wikimedia.org/rc');
printPlainObj({
'event': 'connect',
'messsage': 'Connecting to stream.wikimedia.org...'
});
socket.on('connect', function () {
printPlainObj({
'event': 'connect',
'messsage': 'Connection established!'
@notconfusing
notconfusing / getting_subclass_of.py
Created August 14, 2015 16:46
Using Pywikibot to Get a Wikidata Subclass of Superclass
import pywikibot
wikidata = pywikibot.Site('en','wikipedia').data_repository()
drummer = pywikibot.ItemPage(wikidata, 'Q386854')
data = drummer.get()
claims = data['claims']
subclass_ofs = claims['P279'] #Property P279 is subclass of
superclass_items = [superclass.target for superclass in subclass_ofs]
def english_name(item):
return item.get()['labels']['en']
@notconfusing
notconfusing / Untitled.ipynb
Created February 27, 2016 18:40
Calculate the Labour Hours of a user using PAWS wmflab SQL services.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# copied from harvest_template.py which is due to:
# (C) 2013 Multichill, Amir
# (C) 2013 Pywikipediabot team
#
# Distributed under the terms of MIT License.
#
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@notconfusing
notconfusing / flask_thank_app.py
Created January 8, 2019 17:26
Send a "thanks" on Wikipedia via OAUTH
# -*- coding: utf-8 -*-
"""Example Flask application which can authenticate the user via OAuth, and send a thank
see for the https://phabricator.wikimedia.org/source/tool-my-first-flask-oauth-tool/ for more of the flask OAUTH details
This file focuses on what's necessary to thank via OAUTH using the mediawiki API."""
import flask
import mwoauth
import os
import werkzeug.contrib.fixers
@notconfusing
notconfusing / User Name Validator.ipynb
Created May 15, 2019 20:24
Wikipedia User Name Validator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@notconfusing
notconfusing / User Name Validator.ipynb
Created May 15, 2019 20:24
Wikipedia User Name Validator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@notconfusing
notconfusing / rtm2todoist.py
Last active March 11, 2023 20:10 — forked from konnov/rtm2todoist.py
Converting Remember-the-milk tasks (ICS) to a Todoist template (CSV)
#!/usr/bin/env python
# coding: utf-8
# whereas the original rtm2todoist.py[1] worked off the .ics export, this version uses the more modern .json export
# [1] https://gist.github.com/notconfusing/68c84868098dcaa04e44522bebb77638
import json
import pandas as pd
import datetime