Skip to content

Instantly share code, notes, and snippets.

@dimp-pl
dimp-pl / conftest.py
Created March 12, 2018 12:56
Taurus pytest multiple args setup
def pytest_addoption(parser):
parser.addoption("--flag", action="store_true", help="just a flag")
parser.addoption("--fileargument", action="store", default="bar", help="expecting config.json")
@dimp-pl
dimp-pl / cesk.py
Created June 9, 2017 13:57
CESK Machine for Java-like language in Python
import abc
import copy
class ClassDef(object):
ClassMap = {}
def __init__(self, name, parent_class_name):
self.name = name
self.parent_class_name = parent_class_name
@dimp-pl
dimp-pl / requests-logic-proposal.md
Last active February 6, 2024 22:56
Taurus: Adding Flow Control to HTTP Requests

Adding Flow Control to Requests

Sometimes it is useful to control order of execution of HTTP requests (to execute a request only if last request didn't fail, to attach data from last request to current, etc). Currently, Taurus script language allows only sequential execution of requests with no flow control abilities.

This proposal describes possible design of adding flow control to Taurus by adding "logic blocks" to scenario.requests.

By flow control this proposal understands:

  • ability to execute one request multiple times per session
  • conditional request execution
  • ability to execute one of many given requests
@dimp-pl
dimp-pl / arch-container-howto.md
Last active August 29, 2015 14:13
Arch systemd containers

Install pacstrap

pacman -S arch-install-scripts

Create base rootfs with pacstrap utility (this will also install systemd and linux, which can be removed later)

pacstrap -i -c -d ~/containers/arch base base-devel
@dimp-pl
dimp-pl / StackMachine.hs
Created May 16, 2014 21:54
Another way of evaluating arithmetic expressions — stack machine
module StackMachine where
type Value = Double
data Instruction = IPush Value | IAdd | ISubtract | IMultiply | IDivide
deriving (Show)
data Expr = Lit Value
| Add Expr Expr
| Subtract Expr Expr
@dimp-pl
dimp-pl / preview-snap.py
Created February 6, 2014 15:34
Dirty preview/snap photo script. Relies on gphoto2 and piggyphoto.
import piggyphoto
import pygame
def quit_pressed():
for event in pygame.event.get():
if event.type == pygame.QUIT:
return True
return False
def show(file):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dimp-pl
dimp-pl / regs.py
Created May 13, 2013 22:58
Regular languages engine built on top of Python generators
"""
Simple engine for maching regular languages.
Proof of concept that regexps can be built on top of Python generators.
"""
def literal(c): # regexp 'a'
assert len(c) < 2
def matcher(input):
if input.startswith(c):
yield input[len(c):]