Skip to content

Instantly share code, notes, and snippets.

View glombard's full-sized avatar

Gert Lombard glombard

View GitHub Profile
// Created by Lawrence PC Dol. Released into the public domain.
// http://tech.dolhub.com
//
// Contributions by Carlos Gómez of Asturias, Spain, in the area of unary operators
// and right-to-left evaluations proved invaluable to implementing these features.
// Thanks Carlos!
//
// Source is licensed for any use, provided this copyright notice is retained.
// No warranty for any purpose whatsoever is implied or expressed. The author
// is not liable for any losses of any kind, direct or indirect, which result
@glombard
glombard / parse_markdown_images.py
Created May 4, 2016 22:45
Parse a Markdown doc using mistune
from __future__ import print_function
from collections import namedtuple
from mistune import Markdown
text = """"
# Sample using mistune to parse images from Markdown pages.
* This is a sample image: ![Alt text](/path/to/img.jpg "Optional title")
@glombard
glombard / backup_phone_photos.py
Last active April 16, 2016 00:02
Copy photos from my Android phone's SD card. Skip files that already exist locally.
"""Copy photos from my Android phone's SD card. Skip files that already exist locally.
"""
from __future__ import print_function
import subprocess
import csv
import os
photos_dirs = ['/storage/external_SD/DCIM/Camera', '/sdcard/DCIM/Camera']
@glombard
glombard / curl_exit_codes.json
Created January 13, 2016 02:24
Python script to generate json file and shell script with curl exit codes
[
{
"description": "All fine",
"code": 0,
"name": "CURLE_OK",
"long_description": "All fine. Proceed as usual.\n"
},
{
"description": "The URL you passed to libcurl used a protocol that this libcurl does not support",
"code": 1,
@glombard
glombard / jenkins-backup-job-config.py
Created October 27, 2015 20:27
Backup the config.xml of Jenkins jobs using the REST API
import logging
import requests
logging.captureWarnings(True)
SERVER = 'my-jenkins'
JOB_FILTER = 'test'
API_TOKEN = '<my-jenkins-api-token>'
USER = 'glombard'
@glombard
glombard / jenkins-build-duration-graph.py
Last active July 5, 2022 02:04
Plot a graph of Jenkins job build durations over time
import logging
import datetime
import time
from dateutil import tz
import matplotlib.pyplot as plt
import pytz
import requests
logging.captureWarnings(True)
@glombard
glombard / jinja_json_test.py
Created October 25, 2015 22:17
Querying JSON in Python using Jinja2
# Experimenting with one easy way to query a JSON document using a text query
# similar to how XPath works for XML docs.
# Jinja2 has a powerful expression syntax for evalulating/querying a Python dict.
# In this case, we want to query Maven Central to determine if the latest
# version of Robolectric is 3.0 ...
import requests
from jinja2 import Environment
@glombard
glombard / build-robolectric.gradle
Created October 7, 2015 02:50 — forked from kotucz/build-robolectric.gradle
Robolectric runtime dependencies downloader
/**
* Module that includes this will be configured to use offline dependencies for Robolectric
* This downloads robolectric dependencies once into the root project
*/
def robolectricDependenciesFolder = rootProject.buildDir.path + "/robolectric-dependencies"
// configuration that resolves Robolectric runtime dependencies
configurations.create('robolectricRuntime')
@glombard
glombard / my-job-generator.groovy
Created September 25, 2015 17:12
Using Jenkins Job-DSL plugin to create a job with a Post-Build Step / publisher plugin
job('my-generated-job') {
description('This job was automatically generated by a Job-DSL seed job')
steps {
shell('echo Testing Job-DSL and log-parser')
}
wrappers {
colorizeOutput('xterm')
}
// Use configure to add the 'publishers' XML node in the generated config.xml
configure { project ->
@glombard
glombard / clean_caches.sh
Created May 14, 2015 17:26
Clean the gradle/maven and robolectric cache files
find /var/folders -name '*robolectric*' | xargs rm -Rf
rm -Rf ~/.m2
rm -Rf ~/.gradle/caches