Skip to content

Instantly share code, notes, and snippets.

@okin
okin / test_integration.py
Created November 27, 2019 13:43
Nikola not failing TestCheckFailure
class TestCheckFailure(DemoBuildTest):
"""The demo build should pass 'nikola check'"""
def test_check_links_fail(self):
with cd(self.target_dir):
os.unlink(os.path.join("output", "archive.html"))
__main__.main(['check', '-l'])
def test_check_files_fail(self):
@okin
okin / failfinder.py
Created February 20, 2016 14:56
Simple log-parsing pipeline
#! /usr/bin/env python3
import argparse
import os
def check_folder(folder):
logs = get_logs(folder)
failures = collect_failures(logs)
print_failures(failures)
@okin
okin / string-formatting.py
Created April 23, 2015 11:38
Timing of various string formatting methods
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import string
import sys
import timeit
STRING_INTERPOLATION = "%s ist %i ist %.2f"
NAMED_STRING_INTERPOLATION = "%(letter)s ist %(ganzzahl)i ist %(dezimalzahl).2f"
#!/usr/bin/python3
# vim:ft=python ts=4 sw=4 sts=4 et
# table.py - Simple python script that dynamically formats an ascii art table where
# each table cell holds an integer number (incremented, per cell).
# This is a typical excercise task coding lesson for new workers and I just
# wanted to see how bad I perform on this task.
# Written by Armin (Github: netzverweigerer)
@okin
okin / gist:937cc63dd90694eb65a4
Created October 13, 2014 20:48
List Comprehension timing
#! /usr/bin/python3
import timeit
def list_comprehension(input):
data = [element for element in elements]
def for_loop(input):
@okin
okin / runner.py
Created October 13, 2014 20:47
pyStatus config
#! /usr/bin/env python3
from pyStatus.Bar import Bar
from pyStatus.plugins import Time
from pyStatus.plugins import Battery
from pyStatus.plugins import CPU
from pyStatus.plugins import Memory
from pyStatus.plugins import Ip
from pyStatus.plugins import ESSID
@okin
okin / gist:3165258
Created July 23, 2012 18:29
Parsing UTC + Offset with Python
#Package on pypi is: http://pypi.python.org/pypi/python-dateutil/2.1
from dateutil.parser import parse
#This is the value found somewhere
s = "20120629074518Z00'00'"
#This will give you a datetime to work with
dtime = parse(s)