Skip to content

Instantly share code, notes, and snippets.

Aaron Halfaker halfak

Block or report user

Report or block halfak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Output.py
>>> from itertools import islice
>>>
>>> import mwapi
>>>
>>> my_agent = 'gap finder script'
>>> session = mwapi.Session('https://wikidata.org',
... formatversion=2,
... user_agent=my_agent)
>>>
>>>
View query_revisions_by_titles.py
def query_revisions_by_titles(titles, batch=50, **params):
titles_iter = iter(titles)
while True:
batch_titles = list(islice(titles_iter, 0, batch))
if len(batch_titles) == 0:
break
else:
doc = session.get(action='query', prop='revisions',
titles=batch_titles, **params)
View find_need_in_haystack.py
$ python
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> [i for i, c in enumerate("hello") if c == "e"]
[1]
>>> [i for i, c in enumerate("hello") if c == "l"]
[2, 3]
View feature_importances.py
$ python
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from revscoring import Model
>>> m = Model.load(open("models/enwiki.damaging.gradient_boosting.model"))
>>> m.estimator.feature_importances_
array([8.39962459e-03, 7.93533540e-03, 3.04496444e-08, 2.25381150e-02,
2.08058610e-02, 2.26880141e-02, 1.87132900e-02, 1.60180859e-02,
2.23545834e-02, 2.14488512e-02, 1.90494208e-02, 2.54534679e-02,
View ThreadPool.js
/**
* Construct a thread pool using nWorkers.
*
* @constructor
* @param {int} [nWorkers] The number of worker threads
*/
var ThreadPool = function(nWorkers) {
this.activeWorkers = 0;
this.nWorkers = nWorkers
View foo.json
"schemas": {
"contentquality": {
"type": "object",
"properties": {
"contentquality": {
"type": "string"
}
},
"required": ["contentquality"]
},
@halfak
halfak / hard_to_parse.wikitext
Created Oct 11, 2018
Demonstrate signal timeout
View hard_to_parse.wikitext
[[File:PPBarbour.jpg|right|thumb|150px|
[[Philip P. Barbour]]
Presiding officer]] The '''Virginia Constitutional Convention of 1829–1830''' was a constitutional convention for the [[U.S. state|state]] of [[Virginia]], held in [[Richmond, Virginia|Richmond]] from October 5, 1829 to January 15, 1830. == Background and composition == {{History of Virginia}} Almost immediately, the Constitution of 1776 was recognized as flawed both for its restriction of the suffrage by property requirements, and for its malapportionment favoring the smaller eastern counties. Between 1801 and 1813, petitioners called on the Assembly to initiate a constitutional convention ten times. The House of Delegates passed a bill twice, but the conservative eastern planter majority in the Virginia Senate killed both measures. Continuing growth in the western parts of the state led to another fifteen years of agitation. Several counties in the Eastern Shore, northern Piedmont and western counties began opening polls for direct expression fr
View ext.ores.api.js
( function ( mw, $ ) {
/**
* @class OresApi
*/
/**
* @property {Object} defaultOptions Default options for #ajax calls. Can be overridden by passing
* `options` to OresApi constructor.
* @property {Object} defaultOptions.parameters Default query parameters for API requests.
* @property {Object} defaultOptions.ajax Default options for jQuery#ajax.
View gist:17a8bc86968f0be39307e9bb3381e32c
+--------------+---------------+---------------+
| wiki | table_data_MB | index_data_MB |
+--------------+---------------+---------------+
| arwiki | 1875.00 | 3742.99 |
| bnwiki | 480.98 | 861.59 |
| bswiki | 339.17 | 668.60 |
| cawiki | 1495.50 | 2923.97 |
| cswiki | 2025.64 | 3951.56 |
| dewiki | 20936.03 | 41440.21 |
| elwiki | 956.12 | 1811.99 |
View gist:959a7e26381e5dab994d34dd4f6c1c59
> explain revision;
+--------------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------------+------+-----+---------+----------------+
| rev_id | int(8) unsigned | NO | PRI | NULL | auto_increment |
| rev_page | int(8) unsigned | NO | MUL | 0 | |
| rev_text_id | int(8) unsigned | NO | | 0 | |
| rev_comment | varbinary(255) | YES | | | |
| rev_user | int(5) unsigned | NO | MUL | 0 | |
| rev_user_text | varbinary(255) | NO | MUL | | |
You can’t perform that action at this time.