Skip to content

Instantly share code, notes, and snippets.

View Abbe98's full-sized avatar
📧
Tons of notifications here, send me an email instead.

Albin Larsson Abbe98

📧
Tons of notifications here, send me an email instead.
View GitHub Profile
import getopt, sys, requests
class Bot:
def __init__(self):
options, remainder = getopt.getopt(sys.argv[1:], 'v', ['verbose'])
for opt, arg in options:
if opt in ('-v', '--verbose'):
self.verbose = True
print('Setting application to verbose mode.')
@Abbe98
Abbe98 / ComplexNumber.py
Last active December 20, 2018 08:13
Implementation of Polar and Cartesian coordiantes and conversion between them.
import math
'''
Implementation of Polar and Cartesian coordiantes and conversion between them.
These features exists within the Python standard library, this was meant
for educational purposes.
'''
class ComplexNumber:
import sys, pywikibot, re
from pywikibot import pagegenerators
pywikibot.handle_args(sys.argv[1:])
gen = pagegenerators.SearchPageGenerator('http://www.orientering.se', namespaces = [0])
pattern = re.compile(r'(http:\/\/www.orientering\.se(?:\/[A-Za-z0-9\-\._~:\/\?\&\=]*)?)')
class Memory:
def __init__(self, oldURL, newURL):
import sys, pywikibot
from pywikibot import pagegenerators
pywikibot.handle_args(sys.argv[1:])
site = pywikibot.Site('wikidata', 'wikidata')
repo = site.data_repository()
query = 'SELECT ?item ?population WHERE{ ?item wdt:P31 wd:Q515 . ?item wdt:P1082 ?population . FILTER (?population > 100000) MINUS { ?item wdt:P31 wd:Q1549591 }} ORDER BY DESC(?population)'
generator = pagegenerators.WikidataSPARQLPageGenerator(query, site=site)
import urllib.request, json, requests
class wikidata:
endpoint = 'https://www.wikidata.org/w/api.php'
sparqlEndpoint = 'https://query.wikidata.org/sparql?query='
def __init__(self, user, password):
requestString = self.endpoint + '?action=login&lgname=' + user + '&lgpassword=' + password + '&format=json'
try:
// ==UserScript==
// @name KOK-boken
// @match http://www.katrineholmsok.org/KOK-boken
// @match http://www3.idrottonline.se/KatrineholmsOK-Orientering/KOK-boken/
// ==/UserScript==
window.onload = function () {
// Overide paste blocking functions
window.doBeforePaste = null;
window.doPaste = null;
// stuff should only happen in the File namespace
if (mw.config.values.wgCanonicalNamespace === 'File') {
// use the Mediawiki API to check for the use of Template:Map on this page
$.ajax({
url: 'https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=templates&redirects=1&tllimit=100&pageids=' + mw.config.values.wgArticleId,
success: function(result) {
var templates = result.query.pages[mw.config.values.wgArticleId].templates;
for (var key in templates) {
if (templates[key].title === 'Template:Map') {
// the Map template exists and the Warper client code can be internalized
// create popup window
var domain = 'http://wikimaps.mapwarper.net';
var myPopup = window.open(domain + '/u/auth/github?omniauth_window_type=newWindow&auth_origin_url=' + window.location.href, 'myWindow');
// periodical message sender
var messenger = setInterval(function() {
var message = 'requestCredentials';
//send the message and target URI
myPopup.postMessage(message, domain);
}, 500);
Coord Label
61.1503,10.6895 Sjusjøen, Hedmark, Norway
61.5826,8.40454 Visdalen, Oppland, Norway
59.53576,9.29699 Ramberg, Telemark, Norway
69.6444,19.1615 Vasstrand, Troms, Norway
59.0772,16.3699 Himlinge, Södermanland, Sweden
58.2701,13.7247 Stenstorp, Västra Götaland, Sweden
@Abbe98
Abbe98 / output.rdf
Last active February 19, 2016 12:20 — forked from jiemakel/output.rdf
RDF example/dummy output from the OpenStreetMap API(OpenHistoricalMap).
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ohmdm="http://schemas.openhistoricalmap.org/#">
<rdf:Description rdf:about="http://www.openhistoricalmap.org/way/198179683">
<ohmdm:timestamp>2015-04-11</ohmdm:timestamp>
<ohmdm:elementType rdf:resource="http://schemas.openhistoricalmap.org/element#way"/>
<ohmdm:osmVersion>0.6</ohmdm:osmVersion>
<ohmdm:changeset>1141</ohmdm:changeset>
<ohmdm:version>8</ohmdm:version>
<ohmdm:user>Abbe98</ohmdm:user>