Skip to content

Instantly share code, notes, and snippets.

View obestwalter's full-sized avatar
❄️
winter is coming

Oliver Bestwalter obestwalter

❄️
winter is coming
View GitHub Profile
@alecthomas
alecthomas / gist:4497119
Created January 9, 2013 21:28
*Very* hacky YAML + Salt structure validation.
import itertools
import functools
import fnmatch
import os
from StringIO import StringIO
import yaml
from yaml.parser import ParserError
import voluptuous as V
@naftaliharris
naftaliharris / trypy
Last active January 2, 2016 09:39
An enhancement to the "python" executable that automatically launches you into a debugger if your code throws an exception.
#!/bin/bash
# An enhancement to the "python" executable that automatically launches you into the python debugger on error.
#
# Use it like you would the "python" executable, for example:
# $ trypy somefile.py
# or
# $ trypy somefile.py arg1 arg2
#
# EXAMPLE:
@dabeaz
dabeaz / bug.py
Created January 7, 2016 10:11
Diabolical bug involving code that behaves differently in a class decorator vs. a metaclass
# bug.py
def decorate(func):
print('Decorating', func.__name__)
return func
def wrap_methods(cls):
for name in vars(cls):
if name.startswith('f_'):
setattr(cls, name, decorate(getattr(cls, name)))
@chmouel
chmouel / pan.zsh
Last active June 4, 2017 10:16
PAN: a zsh tool to switch easily with completion the tox virtualenvs and tests (demo: http://i.imgur.com/kJsJTjj.gif)
# Author: Chmouel Bodujnah <chmouel@chmouel.com>
#
# Pan a zsh tool to complete virtualenv tox targets and tests launched via
# testtools
#
# Demo: http://i.imgur.com/kJsJTjj.gif
#
# When you use zsh just source the file directly and when you are inside a
# project which has been pre-built with tox targets you can start do:
# pan <TAB>
@gibatronic
gibatronic / workit.bash
Last active June 24, 2019 09:10
Automatically run workon when entering a directory
function check_for_virtual_env {
[ -d .git ] || git rev-parse --git-dir &> /dev/null
if [ $? == 0 ]; then
local ENV_NAME=`basename \`pwd\``
if [ "${VIRTUAL_ENV##*/}" != $ENV_NAME ] && [ -e $WORKON_HOME/$ENV_NAME/bin/activate ]; then
workon $ENV_NAME && export CD_VIRTUAL_ENV=$ENV_NAME
fi
elif [ $CD_VIRTUAL_ENV ]; then
@xianyunwuxin
xianyunwuxin / gist:1835819
Created February 15, 2012 13:50 — forked from creotiv/gist:1217855
Multicore gevent wsgi server
import sys
from gevent import server
from gevent.server import _tcp_listener # gevent.baseserver._tcp_listener -> gevent.server._tcp_listener ( gevent>0.13.6 )
from gevent import pywsgi
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def hello_world(env, start_response):
if env['PATH_INFO'] == '/':
start_response('200 OK', [('Content-Type', 'text/html')])
@graygilmore
graygilmore / hover-color.scss
Last active February 4, 2021 16:30
The goal of this Sass function is provide a hover color that works with any color on any background. No longer do we need to bundle hover color options with our themes, let Sassy McSasserson take care of that for you.
/*
The Ultimate Hover Color Function
@author Gray Gilmore - http://code.graygilmore.com
The goal of this Sass function is provide a hover color that works
with any color on any background. No longer do we need to bundle
hover color options with our themes, let Sassy McSasserson take care
of that for you.
The hover color, seen in this demo as "After" text, must be visible in
@kasteph
kasteph / workshop.md
Last active February 11, 2021 16:52
PyCon Berlin 2019: Poetry Workshop

Package and Dependency Management with Poetry

The Poetry repository can be found here and the website here.

For documentation on the pyproject.toml file specific to Poetry, go here.

The goal of this workshop is to have a pyproject.toml that poetry can use to build your package to a distribution and then publish it to a private repository.

@renoirb
renoirb / VagrantMultipleMachineWorkspace.md
Last active December 10, 2021 16:53
Using Vagrant with Salty-Vagrant and Multiple virtual machines

Description

Have you ever wanted to have a Vagrant workspace with more than one Virtual Machine, and managed by Salt Stack? I did, but the documentation is not all there yet.

I managed to make it work with the following, hope it will be useful.

To use

See the Complete salty-vagrant setup, but use the current Vagrantfile to have two machines.