Skip to content

Instantly share code, notes, and snippets.

@kvas-it
kvas-it / bla.clj
Created April 30, 2019 22:38
Find what changed between two data structures
(defn- prefix-paths
"Add a prefix to each of the paths in a sequence."
[pfx paths]
(map #(cons pfx %) paths))
(defn changed-paths
"Return a sequence of paths that differ between two nested data structures."
[a b]
(cond
; same item: no differences
@kvas-it
kvas-it / test_hg_hook.py
Created April 18, 2019 14:57
End to end test for Mercurial-Trac integration hook
#!/usr/bin/env python
"""An end-to-end test for Mercurial-Trac integration hook.
Creates a local repository with the hook installed and pushes some commits
into it to cause the hook to trigger.
"""
import argparse
import logging

Arms Race Modeling. Problems and Prospects -- by Anderton, C. H.

  • Original: http://doi.org/10.1177/0022002789033002008

  • It's reasonable to assess any model based on what we use it for. Richardson model might fit the data well in some cases but it doesn't help us in making strategic decisions or predicting the impacts of policies.

  • There's a lot of literature dedicated to extending Richardson-type approach but none of them seem to transcend the limitations of the original model. At the end of the day, systems of differential equations don't seem to be a good

@kvas-it
kvas-it / count-categories.py
Created February 21, 2019 10:07
Count items in categories
#!/usr/bin/env python
import collections
from trustednews import powder
counts = collections.defaultdict(int)
with open('tn-metacert-bias.xml') as f:
for domain, path, category in powder.read(f):
@kvas-it
kvas-it / meandist_decay.py
Created December 4, 2018 13:23
Mean distance with exponential decay to 0.5
#!/usr/bin/python3
import math
import pprint
import random
# Words that we use for producing random answers.
WORDS = """
Am if number no up period regard sudden better. Decisively surrounded all
@kvas-it
kvas-it / meandist.py
Created December 4, 2018 13:13
Mean distance without decay
#!/usr/bin/python3
import math
import pprint
import random
# Words that we use for producing random answers.
WORDS = """
Am if number no up period regard sudden better. Decisively surrounded all

Keybase proof

I hereby claim:

  • I am kvas-it on github.
  • I am kvas (https://keybase.io/kvas) on keybase.
  • I have a public key ASCRjizGfgSjaJDULmKT9QcPaK3BNEBRXdqLsQ9iOOgQ6wo

To claim this, I am signing this object:

@kvas-it
kvas-it / download.py
Created January 17, 2017 17:59
Download a file from Google Cloud Storage
import sys
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
KEY_FILE = 'test-2492.json'
URL = 'https://storage.googleapis.com/test-bucket-2492/test-data.txt'
STORAGE_RO_SCOPE = 'https://www.googleapis.com/auth/devstorage.read_only'
@kvas-it
kvas-it / .bashrc
Created January 11, 2017 09:57
toxenv bash function
# This function activates one of the virtualenvs created by tox and installs
# current package there in development mode. Handy for working on python
# packages that have tox testing.
function toxenv {
env=$1
if [ "$env" == "" -a -d .tox/py35 ]; then
env=py35
fi
if [ "$env" == "" -a -d .tox/py27 ]; then
env=py27
@kvas-it
kvas-it / report.md
Created July 24, 2016 20:20
Investigate metafunc.parametrize() behaviour in pytest

I took pytest from features branch because it has --setup-plan flag that makes it display the order of setup and teardown of fixtures. This information is quite useful for understanding what happens in this issue.

I added the following lines to Metafunc.parametrize in _pytest/python.py to observe parametrization (I used python 2 for consistency with the examples from the issue):

diff --git a/_pytest/python.py b/_pytest/python.py