Skip to content

Instantly share code, notes, and snippets.

View jpmckinney's full-sized avatar

James McKinney jpmckinney

View GitHub Profile
@jpmckinney
jpmckinney / tz_identifiers_to_rails_identifiers.rb
Created January 5, 2011 21:44
Maps tz database time zone identifiers to Rails time zone identifiers
# blog post: http://blog.slashpoundbang.com/post/2613268281/changing-from-tz-database-identifiers-to-rails-friendly
{
"Australia/Adelaide" => "Adelaide",
"Australia/Broken_Hill" => "Adelaide",
"America/Anchorage" => "Alaska",
"America/Juneau" => "Alaska",
"America/Nome" => "Alaska",
"America/Yakutat" => "Alaska",
"Pacific/Gambier" => "Alaska",
"Asia/Almaty" => "Almaty",
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Codelist schema",
"description": "Schema for codelist CSV files.",
"type": "array",
"items": {
"$ref": "#/definitions/Row"
},
"definitions": {
"Row": {
.xbox .abxy,.xbox .arrows,.xbox .bumpers,.xbox .button,.xbox .dpad,.xbox .face,.xbox .quadrant,.xbox .stick,.xbox .sticks,.xbox .triggers{position:absolute}.controller.xbox{background:url(https://imgur.com/eWlI7VE.png);height:630px;width:750px}.xbox.white{background:url(https://imgur.com/dC9NkhO.png)}.xbox.disconnected{background:url(https://imgur.com/1i0fvvM.png)}.xbox.disconnected div{display:none}.xbox .triggers{width:427px;height:121px;left:160px;top:-8px}.xbox .trigger{width:88px;height:121px;background:url(https://imgur.com/yB8ABy5.png);opacity:0}.xbox .trigger.left{float:left;background-position:0 0}.xbox .trigger.right{float:right;left:8px;transform:rotateY(180deg)}.xbox .bumper{width:170px;height:61px;background:url(https://imgur.com/lr9lHUc.png);opacity:0}.xbox .bumpers{width:528px;height:61px;left:110px;top:113px}.xbox .back.pressed,.xbox .bumper.pressed,.xbox .face.pressed,.xbox .start.pressed{opacity:1}.xbox .back,.xbox .bumper.left{float:left}.xbox .bumper.right{float:right;-webkit-transform:rot
@jpmckinney
jpmckinney / extension.json
Last active July 7, 2023 05:34
lib-cove-ocds test fixture: Unresolvable JSON reference
{}
@jpmckinney
jpmckinney / extension.json
Created July 7, 2023 01:26
lib-cove-ocds test fixture: invalid metadata file
,
@jpmckinney
jpmckinney / release-schema.json
Last active July 7, 2023 01:26
lib-cove-ocds test fixture: no metadata file
{}
@jpmckinney
jpmckinney / flaticon_to_iso2.py
Last active December 2, 2021 00:11
Renames flags from Flaticon to use ISO 3166-1 alpha 2 codes.
import os
import sys
from hdx.location.country import Country
# https://www.flaticon.com/packs/rectangular-country-simple-flags?word=flags
FLAG_PATH = 'path/to/flaticon/folder'
excluded = {
# Non-ISO states with limited recognition
@jpmckinney
jpmckinney / opml_generator.rb
Last active November 25, 2021 17:14
Given an array of URLs, outputs an OPML file to STDOUT
# blog post: http://blog.slashpoundbang.com/post/3385815540/how-to-generate-an-opml-file-with-ruby
require 'open-uri'
require 'builder'
require 'truffle-hog'
require 'nokogiri'
# CHANGE ME
urls = %w(http://example.com/ http://example.org/)
@jpmckinney
jpmckinney / unpack_and_beautify.h
Created December 27, 2010 23:17
unpack_and_beautify.js as char array
// blog post: http://blog.slashpoundbang.com/post/2488598258/running-javascript-from-the-command-line-with-v8
const char unpack_code[] = {
0x2f,0x2f,0x20,0x62,0x6c,0x6f,0x67,0x20,0x70,0x6f,0x73,0x74,0x3a,0x20,0x68,0x74,
0x74,0x70,0x3a,0x2f,0x2f,0x62,0x6c,0x6f,0x67,0x2e,0x73,0x6c,0x61,0x73,0x68,0x70,
0x6f,0x75,0x6e,0x64,0x62,0x61,0x6e,0x67,0x2e,0x63,0x6f,0x6d,0x2f,0x70,0x6f,0x73,
0x74,0x2f,0x32,0x34,0x32,0x38,0x35,0x35,0x37,0x30,0x30,0x37,0x2f,0x75,0x6e,0x70,
0x61,0x63,0x6b,0x2d,0x61,0x6e,0x64,0x2d,0x62,0x65,0x61,0x75,0x74,0x69,0x66,0x79,
0x2d,0x6a,0x61,0x76,0x61,0x73,0x63,0x72,0x69,0x70,0x74,0x0a,0x0a,0x2f,0x2f,0x20,
0x41,0x73,0x73,0x75,0x6d,0x65,0x73,0x20,0x6a,0x73,0x5f,0x62,0x65,0x61,0x75,0x74,
@jpmckinney
jpmckinney / fix_invalid_json.py
Last active May 10, 2021 18:53
Fixes errors in invalid JSON. Running time is (length of input) x (number of errors).
#!/usr/bin/env python
import json
import sys
def run(filename):
with open(filename) as f:
s = f.read()
# This code will re-read the file from the beginning after fixing each error, which is slow. A better solution