Skip to content

Instantly share code, notes, and snippets.

@mearns
mearns / inventory.py
Last active October 22, 2016 22:20 — forked from gmr/inventory.py
#! /usr/bin/env python
# vim: set fileencoding=utf-8:
""" Process URL for intersphinx targets and emit html or text """
def validuri(string):
return string
from sphinx.ext.intersphinx import read_inventory_v2
from posixpath import join
import pprint
@mearns
mearns / java-build.gradle
Last active December 21, 2015 17:06
Basic gradle build file for java projects with commonly used dependencies
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.1'
}
}
@mearns
mearns / download-java.sh
Created December 29, 2015 15:08
Download java installation packages for linux without a web browser
#!/bin/bash
# You could go to http://www.oracle.com/technetwork/java/javase/downloads/index.html
# And pick the file you want to download, but it's an interactive thing that requires you to
# click some buttons and accept the agreement. Doing that on a headless machine is a bit tricky.
# This script will do it for you.
#Configure which version to download.
export JAVA_VERSION_MAJOR=8
export JAVA_VERSION_MINOR=66
@mearns
mearns / serverspec_rspec_cheatsheet.html
Last active September 2, 2023 20:33
A cheat sheet for server spec and rspec
<!DOCTYPE html >
<html>
<!-- This was hacked together by hand after python-markdown output the bulk of it.
Maybe someday I'll put together a better script to aut-generate this from markdown source. -->
<head>
<!-- github-markdown, plus github pygments -->
<style type='text/css'>
/* <![CDATA[ */
@font-face {
font-family: octicons-link;
// GIVEN
const http = require('some-well-known-http-request-module');
sandbox.stub(http, 'post').returns(EXPECTED_RESPONSE_BODY);
// WHEN
makeRestApiCall(EXPECTED_POST_DATA);
// THEN
expect(http.post).to.have.been.calledWith('expectedEndPoint', EXPECTED_POST_DATA);
// GIVEN
const http = require('some-well-known-http-request-module');
sandbox.stub(http, 'post').returns(EXPECTED_RESPONSE_BODY);
sandbox.stub(http, 'config');
// WHEN
makeRestApiCall(EXPECTED_POST_DATA);
// THEN
expect(http.config).to.have.been.calledWith({ baseUrl: 'http://example.com/rest/api/' });
const http = require('some-well-known-http-request-module');
function init() {
http.config({
baseUrl: 'http://example.com/rest/api/'
});
}
function makeRestApiCall(data) {
return http.post('expectedEndpoint', data);
function makeRestApiCall(client, data) {
return client.post('http://example.com/rest/api/expectedEndpoint', data);
}
// GIVEN
const mockClient = {
post: sandbox.stub().returns(EXPECTED_RESPONSE_BODY)
};
// WHEN
makeRestApiCall(mockClient, EXPECTED_POST_DATA);
// THEN
expect(mockClient.post).to.have.been
// GIVEN
const http = require('some-well-known-http-request-module');
sandbox.stub(http, 'post').returns(EXPECTED_RESPONSE_BODY);
// WHEN
makeRestApiCall(EXPECTED_POST_DATA);
// THEN
expect(http.post).to.have.been
.calledWith('http://example.com/rest/api/expectedEndPoint', EXPECTED_POST_DATA);