Skip to content

Instantly share code, notes, and snippets.

View JamesMessinger's full-sized avatar

James Messinger JamesMessinger

View GitHub Profile
@JamesMessinger
JamesMessinger / README.md
Last active April 20, 2025 15:40
VSCode GitHub Markdown Theme

GitHub Markdown Theme for Visual Studio Code

This CSS stylesheet allows you to preview markdown files in VSCode using GitHub's mardown theme. This CSS was taken directly from the official GitHub Markdown repo. I replaced their top-level .markdown-body class with the body tag so it would work in VSCode, and added styling for the html tag to match GitHub's fixed-width container.

Instructions

  1. Copy the CSS file to your computer
    Copy the github-markdown.css file below to your computer. You can put it anywhere you want, but I chose to put it in the same folder as my VSCode settings file.

  2. Edit your VSCode settings
    If you want to use this theme for all of your projects, then edit your User Settings file. If you just want to use this them

@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active April 14, 2025 16:34
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@JamesMessinger
JamesMessinger / json-schema.js
Created July 27, 2017 19:21
Using JSON Schema in Postman (via an environment variable)
// Load the JSON Schema
const customerSchema = JSON.parse(environment.customerSchema);
// Test whether the response matches the schema
var customer = JSON.parse(responseBody);
tests["Customer is valid"] = tv4.validate(customer, customerSchema);
@JamesMessinger
JamesMessinger / swagger.json
Last active September 24, 2022 14:53
ShipEngine API definition
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "ShipEngine"
},
"host": "api.shipengine.com",
"schemes": [
"https"
],
@JamesMessinger
JamesMessinger / reuse-code.js
Created July 27, 2017 19:23
Saving JavaScript code to a variable in Postman
// Save common tests in a global variable
postman.setGlobalVariable("commonTests", () => {
// The Content-Type must be JSON
tests["Content-Type header is set"] = postman.getResponseHeader("Content-Type") === "application/json";
// The response time must be less than 500 milliseconds
tests["Response time is acceptable"] = responseTime < 500;
// The response body must include an "id" property
var data = JSON.parse(responseBody);
@JamesMessinger
JamesMessinger / postman-tests.js
Created July 27, 2017 19:25
Postman tests example
tests["Status code is 200"] = responseCode.code === 200;
tests["Response time is acceptable"] = responseTime < 200; // milliseconds
tests["Content-Type header is set"] = postman.getResponseHeader("Content-Type");
@JamesMessinger
JamesMessinger / set-next-request.js
Created July 27, 2017 19:24
setNextRequest() example
var customer = JSON.parse(responseBody);
if (customer.id === undefined) {
// No customer was returned, so don't run the rest of the collection
postman.setNextRequest(null);
}
else {
// Save the customer ID to a Postman environment variable
postman.setEnvironmentVariable("cust_id", customer.id);
@JamesMessinger
JamesMessinger / OSXApps.md
Last active January 31, 2022 20:02
James's Great Big List of Great Mac Apps

James’s Great Big List of Great Mac Apps

Apps

  • Chrome ($Free) - Because Safari sucks
  • VLC Media Player ($Free) - Because QuickTime blows
  • Acorn ($30) - Photoshop for humans
  • Airmail ($10) - An excellent email client, supports Gmail, Yahoo, Hotmail, Exchange, etc.
  • Twitter ($Free) - Twitter's official Mac client. It's pretty great.
@JamesMessinger
JamesMessinger / postman-bdd.js
Created July 27, 2017 19:22
Postman BDD example
describe('Get customer info', () => {
it('should return a valid response', () => {
response.should.have.status(200);
response.should.be.json;
response.body.should.not.be.empty;
});
it('should set the Location header', () => {
response.should.have.header('Location');
@JamesMessinger
JamesMessinger / reuse-code.js
Created July 27, 2017 19:23
Reusing code in Postman
// First, run the common tests
eval(globals.commonTests)();
// Then run any request-specific tests
tests["Status code is 200"] = responseCode.code === 200;