Skip to content

Instantly share code, notes, and snippets.

View jpmckinney's full-sized avatar

James McKinney jpmckinney

View GitHub Profile
@jpmckinney
jpmckinney / Makefile
Created January 10, 2016 05:25
Makefile for reporting the status, unpushed commits, branches and stashes of all repositories in a directory. Useful if you have a lot of repositories.
# Run all these commands with the `-s` flag.
# Prints the status of all unclean repositories.
status:
for dir in */; do \
if [ -d $$dir/.git ]; then \
cd $$dir; \
if [[ ! -z `git st` ]]; then \
echo $$dir; \
git st; \
@jpmckinney
jpmckinney / stefan_baack.rb
Last active November 19, 2015 22:17
Prints the top users who contribute to the most civic tech repositories outside their home organization(s).
# Prints the top 10 users who contribute to the most civic tech repositories
# outside their home organization(s). If you'd like to print the top 15, run:
#
# ruby stefan_baack.rb 15
#
# To see the top 3 organizations to which each user contributed, run:
#
# ruby stefan_baack.rb 10 3
#
# @see http://sbaack.com/2015/11/19/scraping-the-global-civic-tech-community-on-github-part-2.html
@jpmckinney
jpmckinney / Email unobfuscation.md
Last active September 25, 2015 22:09
Notes on email unobfuscation

CloudFlare

# http://www.conservative.ca/team/member/?fname=Arnold&lname=Viersen&type=candidates
span = page.xpath('//span[@class="__cf_email__"]/@data-cfemail')
code = span[0]
operand = int(code[:2], 16)
return ''.join(chr(int(code[i:i + 2], 16) ^ operand) for i in range(2, len(code), 2))
@jpmckinney
jpmckinney / start_event-end_event.json
Created June 3, 2015 19:25
Popolo `start_event` and `end_event` example.
// Old member
{
"organization_id": "house-of-commons",
"person_id": "john-doe",
"end_event": "john-doe-resigns"
}
// Resignation
{
"id": "john-doe-resigns",
// Acme Ltd organization
{
"id": "acme-ltd",
"name": "Acme Ltd"
}
// Board of Directors sub-organization
{
"id": "acme-board",
"name": "Board of Directors",
@jpmckinney
jpmckinney / index.html
Last active August 29, 2015 14:21
Polymaps example
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@jpmckinney
jpmckinney / Gemfile
Last active August 29, 2015 14:17
Used to answer some Popolo questions on Poplus list.
source 'https://rubygems.org'
gem 'data_mapper'
gem 'dm-postgres-adapter'
@jpmckinney
jpmckinney / mysql_database_structure.sql
Created March 19, 2015 16:31
CorpWatch API database structure
-- MySQL dump 10.13 Distrib 5.5.31, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: edgarapi_live
-- ------------------------------------------------------
-- Server version 5.5.31-0ubuntu0.13.04.1-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
@jpmckinney
jpmckinney / index.html
Last active July 16, 2016 19:07
Side-by-side comparison of draft versus final Canada OGP National Action Plan 2014-16. http://bl.ocks.org/jpmckinney/raw/0a4fda35b8183fc8a73d/
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.text
{
width: 50%;
float: left;
font: 300 16px/23px Helvetica,Arial,sans-serif;
}
.text-del
@jpmckinney
jpmckinney / patch.diff
Created September 26, 2014 17:31
rangeslider.js is not accessible (https://github.com/andreruffert/rangeslider.js/issues/47), its math is wrong in getPositionFromValue, and it treats 0 as falsy.
diff --git a/app/assets/javascripts/rangeslider.js b/app/assets/javascripts/rangeslider.js
index 1531b77..9637194 100644
--- a/app/assets/javascripts/rangeslider.js
+++ b/app/assets/javascripts/rangeslider.js
@@ -107,7 +107,7 @@
this.identifier = 'js-' + pluginName + '-' +(pluginIdentifier++);
this.min = parseFloat(this.$element[0].getAttribute('min') || 0);
this.max = parseFloat(this.$element[0].getAttribute('max') || 100);
- this.value = parseFloat(this.$element[0].value || this.min + (this.max-this.min)/2);
+ this.value = parseFloat(this.$element[0].getAttribute('value') || this.min + (this.max - this.min) / 2);