Skip to content

Instantly share code, notes, and snippets.

View zsoldosp's full-sized avatar

Peter Zsoldos zsoldosp

View GitHub Profile
#### Tie display strings
class OnTieBothDisplayed(object):
def tie_str(self):
return '{}-All'.format(self)
def __str__(self):
return self.__class__.__name__
.PHONY: tag
SHELL=bash
# assuming v0.1.0 is the only tag in the repo
tag: nr_of_existing_tags := $(shell git tag | grep "\<${TAG}\>" | wc -l)
tag:
@echo ${nr_of_existing_tags}
ifeq (1,$(nr_of_existing_tags))
@echo tag ${TAG} already present ${nr_of_existing_tags}
else
import pytest
from django.core.cache import caches
@pytest.fixture()
def django_caches():
yield caches
# finalizer
for cache in caches.all():
cache.clear()
@zsoldosp
zsoldosp / data.yml
Last active September 25, 2015 20:43
avoiding duplication in yaml files. Heard about from @beerops https://twitter.com/beerops/status/647499854499987456 then googled and found https://gist.github.com/bowsersenior/979804
default: &DEFAULT
URL: stooges.com
throw_pies?: true
stooges: &stooge_list
larry: first_stooge
moe: second_stooge
curly: third_stooge
development:
<<: *DEFAULT
@zsoldosp
zsoldosp / repro.py
Last active August 29, 2015 14:17
openpyxl decimal/float formatting problem
from openpyxl.workbook import Workbook
from openpyxl.writer.excel import save_virtual_workbook, save_workbook
from openpyxl.reader.excel import load_workbook
from decimal import Decimal
import tempfile
import os
def get_filepath(name):
fh, path = tempfile.mkstemp(prefix=name, suffix='.xlsx')
@zsoldosp
zsoldosp / Vagrantfile
Last active August 29, 2015 14:17
Bugreport - ansible template task fails with Errno 26 when run in a ubuntu/trusty64 host via vagrant from a windows 7 x64 host
# -*- mode: ruby -*-
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", path: "bootstrap.sh"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "1024"
Feature: Showing off behave
Scenario: Run a simple test
Given we have behave installed
When we implement 5 tests
Then behave will test them for us!
mkdir vagrant-pytest-does-not-recogniz-pytest-django-on-ubuntu-trusty64
cd vagrant-pytest-does-not-recogniz-pytest-django-on-ubuntu-trusty64
vagrant init ubuntu/trusty64
vagrant ssh
@zsoldosp
zsoldosp / elixir macros-why-error.exs
Created February 8, 2014 19:38
Different errors given for the same elixir code - different scoping between iex and elixir? If so, why?
$ elixir macros-why-error.exs
false
** (UndefinedFunctionError) undefined function: MyMacro.unless/2
MyMacro.unless(false, [do: :ok])
(elixir) src/elixir_lexical.erl:17: :elixir_lexical.run/2
(elixir) lib/code.ex:301: Code.require_file/2
@zsoldosp
zsoldosp / gist:6586803
Created September 16, 2013 21:25
re: ayende challange
def assuming_sorted_input_with_callbacks(sorted_unique_integers, callback_to_invoke_on_each_consecutive_set):
""" context:
"""
if not sorted_unique_integers:
return # empty input
curr_lo = curr_hi = sorted_unique_integers[0]
for num in sorted_unique_integers[1:]:
if curr_hi != (num - 1):