Skip to content

Instantly share code, notes, and snippets.

View putnik's full-sized avatar
🇺🇦
Нет войне!

Sergei Leshchina putnik

🇺🇦
Нет войне!
View GitHub Profile
@putnik
putnik / trends_ru.py
Last active October 14, 2015 20:28
@RuwikiTrends
@putnik
putnik / trends_be.py
Created October 14, 2015 20:29
@BeWikiTrends
@putnik
putnik / wikidata-dump.py
Created July 12, 2016 16:59
Чтение дампа Викиданных на Python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import ijson
import gzip
f = gzip.open('wikidata-all.json.gz', 'rb')
for item in ijson.items(f, 'item'):
# coding: utf8
#
# Copyright (c) 2016 Sergey Leschina (putnik) <[email protected]>
#
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
import pywikibot
from pywikibot import pagegenerators
@putnik
putnik / data-3.csv
Last active February 14, 2018 23:40 — forked from d3noob/data-3.csv
v4 curve interpolation comparison
date close
1907-01-01 51815
2011-01-01 310956
2017-01-01 269022
{
"version": 2,
"width": 700,
"height": 300,
"data": [
{
"name": "table",
"values": [
{"year":1907,"population":51815},
{"year":2011,"population":310956},
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "Population over time.",
"data": {
"values": [
{"year": 1907,"population": 51815},
{"year": 2011,"population": 310956},
{"year": 2017,"population": 269022}
]
},
@putnik
putnik / order_awards.py
Last active January 9, 2022 10:38
Generate a sorted list of awards from Wikidata
# Copyright 2018-2022 Sergey Leschina <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@putnik
putnik / pre-commit.sh
Last active March 11, 2019 09:09 — forked from peinwag/pre-commit.sh
Precommit hook for git that checks new modified lines against a given codingstandard with phpcs
#!/bin/bash
files=$(git diff-index --name-only --diff-filter=ACMR HEAD --)
for file in $files; do
phpcsout=$(phpcs -s $file --standard=phpcs.xml)
if [ "$phpcsout" != "" ]; then
affectedLines=$(git blame -p -s $file | grep 00000000 | cut -d " " -f2)
<html>
<head>
<script src="http://code.jquery.com/jquery-2.0.0.js"></script>
<script>
var sparql = `
select ?item ?itemLabel ?article {
?item wdt:P31/wdt:P279/wdt:P279 wd:Q174211 .
?item wdt:P279 wd:Q11173
OPTIONAL { ?article schema:about ?item; schema:isPartOf <https://ru.wikipedia.org/> }
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru,en" }