Skip to content

Instantly share code, notes, and snippets.


Kelvin Nicholson kelvinn

View GitHub Profile
kelvinn /
Created Jul 24, 2014
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000
kelvinn / gist:512f72bf1015047af945
Created Jun 6, 2014
Recursively Change Line Endings (Windows)
View gist:512f72bf1015047af945
REM On Unix you would do this: find ./ -type f -exec dos2unix {} \;
REM After installing dos2unix.exe in Windows, you can create a small bat script with the below in it to
REM recursively change the line endings. Careful if you have any hidden directories (e.g. .git)
for /f "tokens=* delims=" %%a in ('dir "C:\Users\username\path\to\directory" /s /b') do (
"C:\Program Files\unix2dos.exe" %%a
kelvinn /
Last active Apr 19, 2021
Installing GDAL (Python 3.6) on Mac OS X

How-To: Install GDAL Python Bindings

I've found two ways to install the GDAL Python bindings on Mac.

Via GDAL Framework / QGIS

First, you can install the GDAL Framework via QGIS (or get it directly), and then do...

kelvinn / docker-compose.yml
Last active Mar 9, 2021 — forked from ptisserand/docker-compose.yml
docker-compose to run mitmproxy with web interface using docker volume
View docker-compose.yml
version: '3.4'
image: mitmproxy/mitmproxy
- 8080:8080
- 8081:8081
- mitmproxy:/home/mitmproxy/.mitmproxy
kelvinn /
Created Jun 10, 2014
Example of creating Django superuser (with password) in dev environment using SaltStack
import os
import sys
# First, add the project to PATH. Adjust as needed.
PWD = os.path.dirname(os.path.abspath(__file__))
PROJECT_PATH = os.path.abspath(os.path.join(PWD, '../../../../'))
# Second, configure this script to use Django
import django
kelvinn /
Created Nov 21, 2013
This gist shows how to take the timeline backup from Twitter and transform it into a dictionary using the headers as keys. For example, if the CSV file looked had two columns, col1 and col2, it would result in list that looked like: [{'col1': 'hello', 'col2': 'world'}, {'col1': 'bye', 'col2': 'world'}] It also converts the format used by Twitter…
import csv
from dateutil import parser
qs_list = []
with open('C:\\Users\\username\\Desktop\\tweets.csv', 'rb') as csvfile:
qsreader = csv.reader(csvfile, delimiter=',', quotechar='"')
header =
for row in qsreader:
d = parser.parse(row[6])
row[6] = d.isoformat()
kelvinn /
Created Mar 30, 2015
Resolving Android authenticated calls to Google Cloud Endpoint
@ApiMethod(name = "sayHi", clientIds = {
audiences = { Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID },
scopes = {
"" })
kelvinn / new-do-db.yml
Last active Aug 29, 2015
Creating Digital Ocean Droplets with unique names using Ansible
View new-do-db.yml
- name: Prepare New Digital Ocean Droplet
user: ansible
- action: shell date +%s | sha256sum | base64 | head -c 6
register: rand_var
- digital_ocean: >
kelvinn / gist:701325f936af15fec982
Created Jun 27, 2014
Ansible Tower - setting SSH port numbers for hosts
View gist:701325f936af15fec982
# Add this to the YAML section:
ansible_ssh_port: 1234
kelvinn / StationList.csv
Created Jun 6, 2014
An example usage of the googlemaps package to lookup origin / destination information using Google Maps API.
View StationList.csv
Sydenham Station Marrickville Station
Dulwich Hill Station
Hurlstone Park Station
Canterbury Station
Campsie Station
Bankstown Station
Berala Station
Sefton Station
Leightonfield Station
Ashfield Station