Skip to content

Instantly share code, notes, and snippets.

View zstumgoren's full-sized avatar

Serdar Tumgoren zstumgoren

View GitHub Profile
@dannguyen
dannguyen / compjour-2016-WARN-pdfs-pdfplumber.md
Last active March 17, 2021 20:41
COMPJOUR examples of using pdfplumber on California WARN data

Using the pdfplumber library to extract tabular data from California's WARN Act data documents

(this writeup supplements a computational journalism assignment)

Jeremy Singer-Vine has been working on a new PDF-to-text/spreadsheet library native to Python: pdfplumber

The California WARN Act PDFs can be found at:

@briantjacobs
briantjacobs / storytelling_from_space.md
Last active August 28, 2024 07:14
Storytelling from Space

Storytelling from Space: Tools/Resources

This list of resources is all about acquring and processing aerial imagery. It's generally broken up in three ways: how to go about this in Photoshop/GIMP, using command-line tools, or in GIS software, depending what's most comfortable to you. Often these tools can be used in conjunction with each other.

Acquiring Landsat & MODIS

Web Interface

  • Landsat archive
@jeremyjbowers
jeremyjbowers / varnish
Last active December 20, 2015 15:09
Basic Varnish configuration for /etc/default/varnish
# Oh, wow. So those other configuration files
# looked pretty readable. This one, though,
# looks OOOOOLLLD. It is old. And so it's
# less readable. But let's talk about it.
# Run on startup? Yes.
START=yes
# Set the number of files this daemon can
# touch. We need los of them because each
@jeremyjbowers
jeremyjbowers / varnish.vcl
Last active December 20, 2015 15:09
Basic Varnish configuration for Inspections project.
# Okay, so, let's start by setting up a backend.
# Varnish needs to know where to send requests
# that fail to find an object in the cache.
# We'll send requests back to Nginx on port 8001.
backend default {
.host = "127.0.0.1";
.port = "8001";
}
# Varnish has some subfunctions (subroutines?) that start
@jasonbartz
jasonbartz / geo_no_db.py
Created April 1, 2013 20:34
Geo without a database
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.gdal.geometries import Point
# Get the DC voting districts shape (from the Census Bureau)
ds = DataSource('/path/to/my/shapefiles/tl_2012_11_vtd10/tl_2012_11_vtd10.shp')
# Grab the layer that contains all of the shape data
layer = ds[0]
def get_shape_contains(layer, geometry):
# Iterate over every shape
@jeremyjbowers
jeremyjbowers / my_app.conf
Created December 31, 2012 01:29
This is an upstart configuration file to execute uWSGI as a daemon on Ubuntu-recent (10.x, 12.x). For more info on upstart: http://upstart.ubuntu.com/getting-started.html. This file would live in /etc/init/ and you'd need to do sudo initctl reload-configuration on the initial file creation and then sudo service my_app start/restart/stop to contr…
description "uWSGI server for electris CMS"
start on runlevel [2345] # start on all runlevels.
stop on runlevel [!2345] # stop when shutting down.
respawn # respawn if job crashes or is stopped ungracefully.
env DEPLOYMENT_TARGET=production # set any environment variables you like here.
env DJANGO_SETTINGS_FILE=conf/settings.py # more environment variables if you like.
env PYTHONPATH=/home/ubuntu/apps/my_app:/home/ubuntu/.virtualenv/my_app
@jeremyjbowers
jeremyjbowers / nginx.conf
Created December 31, 2012 01:22
A standard Nginx configuration for a uWSGI/Python application.
worker_processes 2; # sets two workers. might need 4 in a very high-traffic environment.
user www-data; # user to run nginx as.
pid /var/run/nginx.pid; # you'll have to create this pidfile or else things won't work.
events {
worker_connections 1024; # connections each worker can take.
use epoll; # epoll is vastly superior to other alternatives.
}
http {
@wrburgess
wrburgess / gist:2187164
Created March 24, 2012 19:37
Setting up a Rails has_many :through relationship with meaningful relationship table #rails #activerecord #relations

##References

##Create Models

Create tables:

rails g model Location
rails g model User
rails g model Checkin

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

"""
A few notes:
* Lines starting with "#" signs are standard Python code comments
* Multi-line comments can be wrapped in triple-quotes (""")
"""
from itertools import islice, product
import calendar
from BeautifulSoup import BeautifulSoup
import requests