Skip to content

Instantly share code, notes, and snippets.

View timstallmann's full-sized avatar

Tim Stallmann timstallmann

View GitHub Profile
@timstallmann
timstallmann / chartist-v1-axis-title-plugin.js
Last active September 26, 2023 07:43
chartist-v1-axis-title-plugin.js
/**
* Original source: https://github.com/alexstanbury/chartist-plugin-axistitle
*
* Chartist.js plugin to display a title for 1 or 2 axes.
* version 0.0.7
* author: alex stanbury
*/
import {Svg, normalizePadding} from 'chartist';
@timstallmann
timstallmann / PostGIS_Proximity_analysis.sql
Created July 3, 2018 14:22
DataWorksNC: PostGIS Proximity Analysis Examples
-- Create some indices in state plane on the census geometry
CREATE INDEX idx_bg_geom_state_plane on geom.blockgroup USING gist (ST_Transform(geom, 102719));
CREATE INDEX idx_tract_geom_state_plane on geom.tract USING gist (ST_Transform(geom, 102719));
-- Import data from staging into final tables.
-- Create table of dwelling units per blockgroup / per tract
CREATE MATERIALIZED VIEW nbhd_correlates.dwelling_units__blockgroup__2017 AS
SELECT bg.gid as gid, bg.geom as geom, bg.fips as fips, sum(du.sum_du) as dwelling_units FROM geom.blockgroup bg JOIN
staging.parcels_2018_dwellingunits du ON st_intersects(st_transform(bg.geom, 102719), du.geom)
@timstallmann
timstallmann / export.sh
Created April 13, 2018 13:40
Manual quarterly rental listings export for Q1 2018
docker-compose exec -T db sh -c 'psql rent_aggregator_db -t -P pager=off -c "COPY (select geoid, count(*) as count_all, min(ask) as min_all, max(ask) as max_all, quantile(ask, 0.5) as med_all, round(avg(ask/bedrooms) FILTER (WHERE bedrooms > 0),2) as mean_per_bedroom, count(*) FILTER (WHERE bedrooms=1) as count_1br, min(ask) FILTER (WHERE bedrooms=1) as min_1br, max(ask) FILTER (WHERE bedrooms=1) as max_1br, quantile(ask,0.5) FILTER (WHERE bedrooms=1) as med_1br, count(*) FILTER (WHERE bedrooms=2) as count_2br, min(ask) FILTER (WHERE bedrooms=2) as min_2br, max(ask) FILTER (WHERE bedrooms=2) as max_2br, quantile(ask,0.5) FILTER (WHERE bedrooms=2) as med_2br, count(*) FILTER (WHERE bedrooms=3) as count_3br, min(ask) FILTER (WHERE bedrooms=3) as min_3br, max(ask) FILTER (WHERE bedrooms=3) as max_3br, quantile(ask,0.5) FILTER (WHERE bedrooms=3) as med_3br, count(*) FILTER (WHERE bedrooms>=4) as count_4upbr, min(ask) FILTER (WHERE bedrooms>=4) as min_4upbr, max(ask) FILTER (WHERE bedrooms>=4) as max_4upbr, quanti
@timstallmann
timstallmann / 3D city tiles workflow.md
Created October 11, 2017 02:21
3D City Tiles Workflow for BC150

3d Printed City Model workflow

  1. ArcMap:
    1. Digitize streets, bldg outlines, acquire DEM. Choose 1/8 mile square area (create graphic than convert to feature). Clip all features & DEM to this outline
  2. CityEngine
    1. Create new scene
    2. Load terrain from DEM. Use DEM as texture file or use generic texture
    3. Load streets/bldgs/lots data into CityEngine by File->Import
    4. Building footprints:
  3. “Align shapes to Terrain” — translate to average
@timstallmann
timstallmann / fix-permissions.sh
Created November 16, 2015 20:40
updated fix-permissions script
#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.