Skip to content

Instantly share code, notes, and snippets.

View achavez's full-sized avatar

Andrew Chavez achavez

View GitHub Profile
@achavez
achavez / README.md
Last active January 10, 2018 19:31
Installing an old version of a Homebrew formula

Installing an old version of a Homebrew formula

Let's say, like me, you accidentally upgraded PostgresQL or PostGIS or something super important and now you need to go back in time and install the previous version.

  1. Find the commit of the old version that you want to install by looking through the Formula/ directory in the homebrew-core repo: https://github.com/Homebrew/homebrew-core/commits/master/Formula/ (If the above doesn't work, you'll need to clone the homebrew-core repo to your machine and run git log master -- Formula/<formula name>.rb).

  2. Unlink the existing (newer) version:

    $ brew unlink <formula_name>
@achavez
achavez / README.md
Last active February 25, 2017 17:25

ONA DFW coding exercises

HTML exercise 1

Format the article below with HTML.

<html>
	<head>
		<title></title>
@achavez
achavez / custom.js
Created November 28, 2016 15:33
First attempt at using our Mapbox-style vector tiles with D3
var layers = ['water', 'road'];
window.renderTiles = function(d) {
var svg = d3.select(this);
this._xhr = d3.request("http://maps.dallasnews.com/" + d[2] + "/" + d[0] + "/" + d[1] + ".pbf").responseType('arraybuffer').get(function(error, json) {
if(error) return console.error(error);
var tile = new VectorTile( new Pbf( new Uint8Array(json.response) ) );
var extents = 4096;
@achavez
achavez / custom.js
Created November 28, 2016 15:33
First attempt at using our Mapbox-style vector tiles with
var layers = ['water', 'road'];
window.renderTiles = function(d) {
var svg = d3.select(this);
this._xhr = d3.request("http://maps.dallasnews.com/" + d[2] + "/" + d[0] + "/" + d[1] + ".pbf").responseType('arraybuffer').get(function(error, json) {
if(error) return console.error(error);
var tile = new VectorTile( new Pbf( new Uint8Array(json.response) ) );
var extents = 4096;
@achavez
achavez / __init__.py
Last active May 3, 2016 17:26
Python class method call logger
import inspect
import datetime
class ClassToLog(object):
pass
def logging_decorator(fn, fn_name):
def logging_method(*args, **kwargs):
@achavez
achavez / README.md
Last active July 11, 2019 14:52
Development machine setup

Prerequisites

  1. Run all of the OS updates that are available
  2. Install Homebrew and tap the casks we'll need (brew tap homebrew/cask-fonts, brew tap homebrew/cask-versions)

Shell setup

  • install ZSH - brew install zsh
  • set ZSH as the default shell by 1) adding the output of which zsh to /etc/shells and 2) changing the default shell with chsh -s $(which zsh)
  • add autocompletion to ZSH brew install zsh-autosuggestions (be sure to follow the instructions output by brew to update your ~/.zshrc)
  • later, after installing Node install a cool command prompt like spaceship (more here) - npm install -g spaceship-prompt
@achavez
achavez / README.md
Last active October 15, 2015 16:34
Download fire maps from USDA Forest Services on an interval
  1. Install requests: pip install requests
  2. Set the INTERVAL
  3. Create the output directory mkdir maps
  4. python main.py
@achavez
achavez / tocsv.sh
Created October 8, 2015 14:14
Convert a folder of Excel files to CSVs
#!/usr/bin/env bash
which xlsx2csv || pip install xlsx2csv
for file in *.xlsx
do
echo "Converting $file"
xlsx2csv --ignoreempty --date="%Y-%m-%d" "$file" "$file.csv"
done

Keybase proof

I hereby claim:

  • I am achavez on github.
  • I am achavez (https://keybase.io/achavez) on keybase.
  • I have a public key whose fingerprint is A204 9AB3 2FFD A454 14B0 3200 0329 8791 5060 3499

To claim this, I am signing this object:

@achavez
achavez / window-downloader.sh
Created February 2, 2015 22:19
Download all Texas expenditures from comptroller
#!/bin/bash
###########################################
# Download full year files and unzip them #
###########################################
year_files=(
"2009"
"2010"
"2011"