Skip to content

Instantly share code, notes, and snippets.

View johnstcn's full-sized avatar
🏳️‍🌈

Cian Johnston johnstcn

🏳️‍🌈
  • Ireland
  • 11:28 (UTC +01:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am johnstcn on github.
  • I am cianjohnston (https://keybase.io/cianjohnston) on keybase.
  • I have a public key ASDp1RugXYlzG-JhqP7WCi5z3MeOeIGApgo6KEdM31CRKgo

To claim this, I am signing this object:

#!/usr/bin/env python
import fileinput
notes = [' '] + ('A Bb B C C# D Eb E F F# G G#'.split() * 2)
chars = ' abcdefghijklmnopqrstuvwy'
mapping = dict(zip(chars, notes))
def normalize(c):
return c.lower()
#!/usr/bin/env python
# Author: Cian Johnston <johnstcn@gmail.com>
import argparse
import itertools
def distance(s1, s2):
out = abs(len(s1) - len(s2))
for c1, c2 in zip(s1, s2):
@johnstcn
johnstcn / country_count.py
Created January 10, 2017 10:07
Print a frequency distribution of countries for a list of IP addresses using a local GeoIP database
#!/usr/bin/env python
import argparse
import json
import re
import sys
import GeoIP
from collections import Counter
@johnstcn
johnstcn / multiget.py
Created November 12, 2016 04:20
Get a list of URLs, run a regex on the content and output the match. In parallel.
#!/usr/bin/env python
import argparse
import re
import grequests
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
@johnstcn
johnstcn / csvmerge.py
Created April 11, 2014 02:30
Tool to merge csv files given a commonly named column header
#!/usr/bin/env python
import csv
import argparse
import sys
from collections import defaultdict
helptext = """Merge multiple CSV files using a commonly named column.
CSV files must have column headings, but do not need to be sorted.