Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# executables prefix
_prefix="/usr/bin"
# git executable
_git="$_prefix/git"
# branch from which to generate site
_origbranch="source"
# branch holding the generated site
@simon-weber
simon-weber / example.js
Created November 22, 2016 22:39
lovefield query/index/order bug example
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 / merge-xml-coverage.py
Last active April 16, 2017 19:04 — forked from tgsoverly/merge-xml-coverage.py
Merge Cobertura XML's
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 / example.py
Created June 15, 2017 22:06
disabling profiling around python-libfaketime example
# 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 / travis-secure-redefine.py
Last active October 15, 2017 18:44
Python script to allow use of TravisCI secure arg variables that would normally be defined on each line of a build matrix, but are too large for the key size when combined.See https://github.com/travis-ci/travis-ci/issues/1736 for motivation. If you just need to secure a lot of sample data, do something like https://github.com/travis-ci/travis/i…
#!/usr/bin/env python
from __future__ import print_function
"""
./%s 'cmd' <id-argname> <redef-argname> [<redef-argname>...]
Given the current environment:
IDARG=1
FOO1=foovalue
BAR1=barvalue
FOO2=foo-unused
@simon-weber
simon-weber / rchandler.py
Last active July 31, 2018 13:58
An example of using a StackContext to store request data globally in Tornado. See https://groups.google.com/d/msg/python-tornado/8izNLhYjyHw/TNKGa9fgvpUJ for motivation and further discussion.
import tornado
class RequestContextHandler(tornado.web.RequestHandler):
def _execute(self, transforms, *args, **kwargs):
# following the example of:
# https://github.com/bdarnell/tornado_tracing/blob/master/tornado_tracing/recording.py
global_data = {} # add whatever here, e.g. self.request
@simon-weber
simon-weber / externalcall.py
Last active November 24, 2018 21:52
Custom tooling to ease VCR.py management.
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 / gmusic_autoplaylists.py
Last active November 27, 2019 21:57
approximations of Google Music auto playlists
from operator import itemgetter
from gmusicapi import Api
api = Api()
api.login('me@gmail.com', 'my-password')
# => True
lib = api.get_all_songs()
@simon-weber
simon-weber / downstream_artifract_urls.py
Created July 30, 2015 15:51
recursively get all downstream jenkins artifact urls
#!/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 / README.md
Created August 28, 2020 16:03
Import Google Music playcount and last played to MediaMonkey

This Python 3 script imports some Google Music metadata to MediaMonkey. Matches are found by a complete match of the song name, album, and artist.

To use it:

  • shut down MediaMonkey
  • make a copy of your MM.DB MediaMonkey database and put it in the same directory as this script
  • use the Autoplaylists for Google Music debug interface to generate a csv of your library, then place it in the same directory as this script and name it google_music_library.csv
  • run python import_gm.py and investigate the logs; repeat on a fresh copy of MM.DB each time until satisfied
  • back up your existing MM.DB and then overwrite it with the modified one