Lately, I’ve gotten into the practice of storing configuration in environment variables and keeping those in a .env file in the root of my project directory.
This file contains simple environment variable assignment and is used by Heroku and Docker.
However making sure these environment variables get set for any command being run in the development environment.
I often work in Python virtual environments, so putting the shell commands in the postactivate and postdeactivate scripts makes sense to me.
To set environment variables in postactivate:
#!/bin/bash
# This hook is sourced after this virtualenv is activated.
cd ~/workspace/scrape-represent-statements
set -a
source .env
set +a
To unset environment variables in postdeactivate:
#!/bin/bash
# This hook is sourced after this virtualenv is deactivated.
while read var; do unset $var; done < <(cat .env | grep -v '^\s*#' | sed 's/\s*\([^=]*\)=.*/\1/')
I didn’t read the instructions when I let PostgreSQL get upgraded from 9.3 to 9.5 with brew upgrade. This is what I had to do to migrate my data after I had already upgraded:
# Switch back to the previous version of postgres, postgis
brew switch postgres 9.3.5_1
brew switch postgis 2.1.4_1
# Start the server (run this in a separate shell)
postgres -D /usr/local/var/postgres
# Dump all my databases
pg_dumpall > pg_dump
# Stop the server
pg_ctl -D /usr/local/var/postgres stop
# Switch back to the up-to-date version of postgres, postgis
brew switch postgresql 9.5.0
brew switch postgis 2.2.1
# Move the old data directory out of the way
mv /usr/local/var/postgres/ /usr/local/var/postgres9.3
# Initialize the data directory for Postgres 9.5
initdb /usr/local/var/postgres
# Start the server
postgres -D /usr/local/var/postgres
# Import the database dump
psql -d postgres -f pg_dump
# Delete the dump file
rm pg_dump
# Stop the server
pg_ctl -D /usr/local/var/postgres stop
# Start the server with launchctl
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
I played three different shows, with three different bands in 48 hours. So different playing for a handful of folks below the Loyola Red Line, in a crowded basement and on a giant stage. It was a hectic weekend, but ultimately, after the dust settled, I feel lucky to get to do all this.
Defiance, Ohio playing at the Fest, 2015. Photo by @jimmyvague (https://instagram.com/p/9mUK8Ast-n/)
“Rabbit Bucket” playing next to the Loyola Red Line. Photo by Roberta.
Defiance, Ohio playing at the Fest, 2015. Photo by @waxwingsmusic (https://instagram.com/p/9lpvX3C-yj/)
There’s been a lot of coverage of the mayor’s property tax increase, and some provisions to reduce the burden on low-to-moderate income homeowners. My first thought went to renters, though:
Dixon elaborated on the song, saying it’s about how “whiteness is centered in everything, how it taught me to hate myself for being black, how when I was a kid I used to pray to God that I could be white… how it scares me that white supremacy doesn’t even need white people to perpetuate it.”
Yesterday at work, my coworker needed to reshape a data table, from CSV. The data was a time series, with one row per date. He wanted to reshape the data so there was one row per day of the year with a column for the desired variable for each year. He observed that there were 93 distinct days of the year for each year and used some clever Excel functions and auto-fills to do this in about 5 minutes. I spend considerably more time figuring out how to do this in PostgreSQL, Python and R.
On Monday, July 13, 2015, Chicago Public Schools (CPS) released preliminary spending plans for the 2015-2016 school year. Many schools face significant budget cups. We made a simple [news app to let users explore how different school budgets changed](http://apps.chicagotribune.com/news/local/cps_school_budgets/).
Additional coverage:
* [CPS Budget: Deep Cuts For Neighborhood Schools, Cash Infusion For Charters](http://www.dnainfo.com/chicago/20150713/loop/cps-student-budgeting-holds-steady-but-schools-will-feel-pinch) (DNAinfo Chicago)
* [Chicago Public Schools’ budgets spend $500 million district doesn’t have](http://www.chicagotribune.com/news/local/breaking/ct-chicago-public-schools-budgets-20150713-story.html)