Skip to content

Instantly share code, notes, and snippets.

Simon Weber simon-weber

Block or report user

Report or block simon-weber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@simon-weber
simon-weber / example.py
Created Jun 15, 2017
disabling profiling around python-libfaketime example
View example.py
# An example to disable profiling when faking time with python-libfaketime.
# Call this once from setup_package or a similar hook at the start of the test run.
# https://github.com/simon-weber/python-libfaketime
def disable_profiling_around_libfaketime(nose_config):
"""
libfaketime's interception of time system calls will break profilers.
If we detect that we're running under a profiler, we set up libfaketime callbacks to
temporarily disable profiling when we're faking the time.
@simon-weber
simon-weber / example.js
Created Nov 22, 2016
lovefield query/index/order bug example
View example.js
document.write = function (s) {
// jsfiddle doesn't allow document.write.
document.body.insertAdjacentHTML("beforeend", s);
}
const schemaBuilder = lf.schema.create('schema', 1);
schemaBuilder.createTable('Item').
addColumn('id', lf.Type.INTEGER).
addColumn('num', lf.Type.STRING).
addPrimaryKey(['id']).
@simon-weber
simon-weber / disable_troublesom_scaling_processes.py
Created Aug 26, 2016
disable ASG scaling processes during CodeDeploy deploys
View disable_troublesom_scaling_processes.py
"""
Suspend an auto scaling group's scaling processes that can interfere with CodeDeploy deploys.
It assumes a single ASG per deployment group.
To use this:
* create a lambda function with this code, then hook up it up to an SNS topic that receives all deployment events (but not host events).
* attach that topic as a trigger in your deployment groups.
Unlike AWS's in-appspec approach, this supports arbitrary deploy concurrency.
View merge-xml-coverage.py
import sys
import os
import xml.etree.ElementTree as ET
import logging
import re
from shutil import copyfile
from optparse import OptionParser
### This file came from the https://github.com/flow123d/flow123d repo they were nice enough to spend time to write this.
### It is copied here for other people to use on its own.
@simon-weber
simon-weber / downstream_artifract_urls.py
Created Jul 30, 2015
recursively get all downstream jenkins artifact urls
View downstream_artifract_urls.py
#!/usr/bin/env python
"""
Run on Jenkins to print a url for each artifact generated by a downstream multijob build.
"""
import os
import requests
@simon-weber
simon-weber / pre-commit.sh
Created Jul 29, 2015
venmo linting pre-commit
View pre-commit.sh
#!/bin/sh
GITROOT=`git rev-parse --show-toplevel`
EXIT_STATUS=0
# Lint all the files in the index, excluding deletions and directories.
git diff-index -z --cached --name-only --diff-filter='ACMRTUXB' HEAD | xargs -0 ls -dp | grep -v '/$' | xargs "$GITROOT/lint"
if [ "$?" != "0" ]; then
@simon-weber
simon-weber / lint.sh
Created Jul 29, 2015
toplevel venmo linting script
View lint.sh
#!/usr/bin/env bash
# Usage:
#
# lint [file1] [file2]...
#
# With no arguments, lint any tracked files with modifications.
# Get venmolint.py into the path so that git-lint detects it.
@simon-weber
simon-weber / script.js
Last active Aug 29, 2015
indicate gmail focus
View script.js
function is_non_inbox_node(node){
var is_non_inbox = false;
if (node.isContentEditable ||
node.tagName == 'INPUT' ||
node.tagName == 'TEXTAREA' ||
node.getAttribute('aria-haspopup') == 'true'
){
is_non_inbox = true;
}
@simon-weber
simon-weber / externalcall.py
Last active Nov 24, 2018
Custom tooling to ease VCR.py management.
View externalcall.py
import vcrutils
VCR_CASSETTE_PATH = APPROOT + '/venmo_tests/cassettes/' # eg
MAKE_EXTERNAL_REQUESTS = os.environ.get('MAKE_EXTERNAL_REQUESTS') == 'TRUE'
@dual_decorator # convert a paramaterized decorator for no-arg use (https://gist.github.com/simon-weber/9956622).
def external_call(*args, **kwargs):
"""Enable vcrpy to store/mock http requests.
@simon-weber
simon-weber / dual_decorator.py
Created Apr 3, 2014
Use a paramaterized Python decorator without calling it.
View dual_decorator.py
def dual_decorator(func):
"""This is a decorator that converts a paramaterized decorator for no-param use."""
# modified from http://stackoverflow.com/a/10288927/1231454.
@functools.wraps(func)
def inner(*args, **kw):
if ((len(args) == 1 and not kw and callable(args[0])
# Exceptions are callable; the next line allows us to accept them as args.
and not (type(args[0]) == type and issubclass(args[0], BaseException)))):
return func()(args[0])
You can’t perform that action at this time.