Skip to content

Instantly share code, notes, and snippets.

Avatar

James McKinney jpmckinney

View GitHub Profile
@jpmckinney
jpmckinney / tz_identifiers_to_rails_identifiers.rb
Created Jan 5, 2011
Maps tz database time zone identifiers to Rails time zone identifiers
View tz_identifiers_to_rails_identifiers.rb
# 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",
@jpmckinney
jpmckinney / .block
Last active Jun 29, 2020
WeWork Place Ville-Marie Mac OS X Printing Instructions
View .block
license: cc-by-4.0
@jpmckinney
jpmckinney / README.md
Last active Nov 30, 2019
Compare differences after making changes to Sphinx
View README.md

Written as part of https://github.com/open-contracting/standard_profile_template/issues/33

curl -O https://gist.githubusercontent.com/jpmckinney/ba38d531e245c175e254ea3bc4218001/raw/bbb015f613ba936b3b42f25c576e833d196e5181/diff-reduce.py
python diff-reduce.py
diff -rq build t | grep Only | sort
diff -ru -x '*.js' -x '.buildinfo' -x '_sources' build t | less
View framework-agreement-tmp-paraguay.json
{
"tender": {
"title": "Adquisición de Útiles de Oficina",
"id": "355477-adquisicion-utiles-oficina",
"procuringEntity": {
"id": "50",
"name": "Dirección Nacional de Contrataciones Públicas (DNCP)"
},
"procurementMethod": "open",
"procurementMethodDetails": "Licitación Pública Nacional",
@jpmckinney
jpmckinney / twitter_list_members.rb
Last active Aug 22, 2019
Download all Twitter list members to CSV
View twitter_list_members.rb
require 'csv'
require 'twitter'
Twitter.configure do |config|
config.consumer_key = ''
config.consumer_secret = ''
config.oauth_token = ''
config.oauth_token_secret = ''
end
@jpmckinney
jpmckinney / README.md
Created Jul 20, 2019
Test the performance of approaches to flattening JSON to CSV.
View README.md

simple-one-table.py

Building a dict by reference is faster than recursively building a dict (slowest) or list of tuples.

dict:

return {key: obj}
…
d = {}
View translate_markdown.py
import gettext
import os
import re
import sys
from collections import OrderedDict
from docutils import frontend
from docutils import nodes
from docutils.parsers import rst
from docutils.utils import new_document
@jpmckinney
jpmckinney / memcache_model.rb
Created Nov 1, 2010
ActiveModel class with Memcache backend
View memcache_model.rb
# blog post: http://blog.slashpoundbang.com/post/1455548868/memcachemodel-make-any-ruby-object-that-persists-in
# No transactions or exceptions (yet).
module MemcacheModel
def self.included(base)
base.class_eval do
extend ActiveModel::Naming
extend ActiveModel::Translation
extend ActiveModel::Callbacks
extend MemcacheModel::ClassMethods
@jpmckinney
jpmckinney / character-class.rb
Created Feb 14, 2017
Character class to match encoding errors
View character-class.rb
/[¡¢£¤¥¦§¨©ª¬­®¯°±²³´µ¶·¸¹º¼½¾¿ÂÃÅËŒœŠšŸŽžƒˆ˜‘‚„†‡•…‰‹›€™]/
@jpmckinney
jpmckinney / _readme.md
Last active Feb 3, 2017
Languages used by government GitHub repositories
View _readme.md

These files list government GitHub repositories, and the number of bytes of code written in each language.

Produced by running the languages:github Rake task from open_source_canada against the list of 'U.S. City' and 'U.S. Federal' GitHub organizations. Data for Canadian GitHub organizations is elsewhere.

You can’t perform that action at this time.