Skip to content

Instantly share code, notes, and snippets.

View brianbancroft's full-sized avatar
🌲

Brian Bancroft brianbancroft

🌲
View GitHub Profile
@brianbancroft
brianbancroft / clean-ids.py
Created July 26, 2018 15:00
Cleans census tract id's which have accidentally been converted to floats from strings.
import psycopg2
database = ''
host = 'localhost'
port = 5432
user = ''
password = ''
table = ''
@brianbancroft
brianbancroft / generate.py
Created June 7, 2018 02:51
Generates a series of output images from a map scene in QGIS. Needs heavy editing.
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
coverage = "/Users/joellawhead/qgis_data/atlas/grid.shp"
atlasPattern = "/Users/joellawhead/qgis_data/atlas/output_"
# Load the map layer. This example uses a shapefile
# but you can use any supported QGIS layer.
vlyr = QgsVectorLayer(coverage, "grid", "ogr")
@brianbancroft
brianbancroft / gist:2cb17b975a0b3240de05e5b8a5960096
Created June 7, 2018 02:49 — forked from philipn/gist:1148693
GeoTIFFs -> One Big GeoTIFF
"""
Likely not useful to anyone else, but just putting it out there.
This script will take a directory of GeoTIFFs and merge them together without issues.
This script simply decompresses the files, runs nearblack to remove pseudo-black borders caused by compression, and then uses gdalwarp to stitch the files together.
The script is designed to use the minimal amount of disk space possible -- it cleans up each file after decompression and continually merges with a master image.
"""
import os
@brianbancroft
brianbancroft / README.md
Last active October 15, 2018 20:36
Census DIM Dictionary

Census DIM

This is a supplement to https://github.com/adventice/census, and contains content you need to make a table with:

  • Headings for each value
  • Subheadings for each value

Building the table

Carry out the following to build the table

@brianbancroft
brianbancroft / convert.py
Created February 28, 2018 20:03
Convert all jpg photos in ~/Desktop/photos to jpeg
import os
import re
regexp = re.compile(r'\.jpg')
folder = os.path.expanduser('~/Desktop/photos')
for filename in os.listdir(folder):
infilename = os.path.join(folder, filename)
if regexp.search(filename):
oldbase = os.path.splitext(filename)
newname = infilename.replace('.jpg', '.jpeg')
output = os.rename(infilename, newname)
@brianbancroft
brianbancroft / deploy.sh
Last active November 13, 2017 16:14
Ember Azure Deploy
#!/bin/bash
# ----------------------
# KUDU Deployment Script
# Version: 1.0.15
# ----------------------
# Helpers
# -------
@brianbancroft
brianbancroft / .zshrc
Last active February 23, 2018 14:38
My zsh config
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/brianbancroft/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
ZSH_THEME="powerlevel9k/powerlevel9k"
@brianbancroft
brianbancroft / .gitconfig
Created November 12, 2017 18:13
.gitconfig
[user]
name = Brian
email = hello@brianbancroft.ca
name = Brian
name = Brian
name = --repace-all
name = Brian Bancroft
[push]
default = upstream
[branch]
@brianbancroft
brianbancroft / multi-time-count.sql
Created October 27, 2017 12:51
Get me some registrations
SELECT(
SELECT COUNT(*)
FROM regs
WHERE invite_sent_at <= NOW() - INTERVAL '10 days'
) AS count_users,
(
SELECT COUNT(*)
FROM regs
WHERE invite_sent_at <= NOW() - INTERVAL '30 days'
) AS count_users,
@brianbancroft
brianbancroft / console-red.rb
Created October 14, 2017 22:33
Make the puts go red:
def warn(message)
puts "\e[#{31}m#{message}\e[0m"
end