This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
class XFDF(object): | |
"""Generate XFDF files to populate PDF forms with data. | |
Form data on PDF files can be populated by using one of these formats: | |
- FDF (File Data Format) | |
- XFDF (XML Forms Data Format) | |
XFDF is an XML format and utf-8 by default. Prefer this to FDF if possible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import unittest | |
"""Valid passwords | |
- are between 8 and 20 characters long | |
- contain at least one number | |
- have at least one uppercase and one lowercase character | |
- have a special char of !"§$%&/()=? | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import unittest | |
"""Valid passwords | |
- are between 8 and 20 characters long | |
- contain at least one number | |
- have at least one uppercase and one lowercase character | |
- have a special char of !"§$%&/()=? | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class Lookahead(object): | |
def __init__(self, things, count): | |
self.things = tuple(things) | |
self.count = count | |
self.windows = len(things) - count + 1 | |
def __iter__(self): | |
return (self.things[i:i+self.count] for i in range(self.windows)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import difflib | |
import itertools | |
import string | |
def check_sum(box_ids): | |
"""Advent of Code 2018, Day 2, Part I""" | |
counts = [Counter(id_).values() for id_ in box_ids] | |
twos = sum(2 in c for c in counts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
import re | |
from collections import defaultdict | |
from itertools import product | |
class Fabric: | |
def __init__(self): | |
self._claimed = defaultdict(int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from abc import ABC, abstractmethod | |
class DuplicateKeyException(Exception): | |
def __init__(self, key): | |
msg = f"Key {key} is already taken" | |
super(DuplicateKeyException, self).__init__(msg) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { performance } = require('perf_hooks'); | |
// LIZENZ: Gehört Horst Schneider | |
function Statistics(X) { | |
function Percentile(X, percent) { | |
this.value = function () { | |
const k = (X.length - 1) * percent; | |
const lower = Math.floor(k); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = require('assert'); | |
describe('Parse', () => { | |
it('strict', function () { | |
// these are fine | |
assert.strictEqual(parseStrict(0), 0); | |
assert.strictEqual(parseStrict(-0), -0); | |
assert.strictEqual(parseStrict(1), 1); | |
assert.strictEqual(parseStrict(3.14159), 3.14159); | |
assert.strictEqual(parseStrict(-3.14159), -3.14159); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* imap(iterable, func) { | |
for (item of iterable) { | |
yield func(item); | |
} | |
} | |
function* ifilter(iterable, predicate) { | |
for (item of iterable) { | |
if(predicate(item)) { | |
yield item; |
OlderNewer