Skip to content

Instantly share code, notes, and snippets.

View piotr-piatkowski's full-sized avatar

Piotr Piatkowski piotr-piatkowski

View GitHub Profile
$ mypy t.py
t.py:16: error: Argument 1 of "foo" is incompatible with supertype "BaseTest"; supertype defines the argument type as "TBase" [override]
t.py:16: note: This violates the Liskov substitution principle
t.py:16: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
Found 1 error in 1 file (checked 1 source file)
#include <stdio.h>
#define LEN 1200000000
char nums[LEN];
int main() {
nums[0] = 1;
nums[1] = 1;
long next_state_change = 0;
long state = -1;
void loop() {
if(digitalRead(PIN_BUTTON) == LOW) {
state = 5;
// it will start counting after releasing button
next_state_change = millis() + 10000;
#!/usr/bin/python3
import json
import requests
def get_by_keys(res, *keys):
try:
for k in keys:
res = res[k]
return res
def get_by_keys(res, *keys):
try:
for k in keys:
res = res[k]
return res
except (TypeError, KeyError, IndexError):
return None
book_data = {
'title': get_by_keys(result, 'volumeInfo', 'title'),
#!/usr/bin/env python
# my_first_calculator.py by AceLewis
# optimized by Kompas
if 3/2 == 1: # Because Python 2 does not know maths
input = raw_input # Python 2 compatibility
print('Welcome to this calculator!')
print('It can add, subtract, multiply and divide whole numbers from 0 to 50')
num1 = float(input('Please choose your first number: '))
import RPi.GPIO as GPIO
import time
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('')
logger.setLevel(logging.DEBUG)
>>> class Node(object):
... def __init__(self, n): self.name = n
... def getName(self): return self.name
...
>>> n = Node('abc')
>>> n.getName()
'abc'
>>> node('xyz')
<__main__.Node object at 0x7f7dbc033f50>
>>> def node(name): return Node(name)
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/kompas/.ssh/config
debug1: /home/kompas/.ssh/config line 39: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to bamboo16.lzil.la [25.51.23.16] port 22.
debug1: Connection established.
debug1: identity file /home/kompas/.ssh/id_rsa type 1
debug1: identity file /home/kompas/.ssh/id_rsa-cert type -1
#!/usr/bin/env python
# coding: utf-8
from influxdb import InfluxDBClient
import time
DBNAME = 'test_db'
SERIES_NAME = 'test_series'
POINTS_NUMBER = 5000000
THRESHOLD = 500000