Skip to content

Instantly share code, notes, and snippets.

View jbradach's full-sized avatar
🦦

James Bradach jbradach

🦦
View GitHub Profile
@jbradach
jbradach / Google API Driving Time
Last active January 3, 2016 00:19
Uses the Google Distance Matrix API to calculate driving times between the origin and destination values in a given file.Google requires that all use of this API be related to the display of information on a Google Map.
from sys import argv
import requests
import csv
from time import sleep
# https://gist.github.com/jbradach/8381802
def main():
script, filein, fileout = argv
@jbradach
jbradach / Sublime Text 3 Python Development
Created January 20, 2014 19:49
Sublime Text 3 settings for Python development.
{
"auto_complete": true,
"auto_indent": true,
"auto_match_enabled": false,
"bold_folder_labels": true,
"caret_extra_bottom": 1,
"caret_extra_top": 1,
"caret_extra_width": 1,
"caret_style": "solid",
"color_scheme": "Packages/User/Monokai Extended (SL).tmTheme",
@jbradach
jbradach / Flask uWSGI Stats
Created August 3, 2014 18:26
Connect to uWSGI Stats Server using Unix domain sockets in Flask.
@app.route('/uwsgistat/')
@app.route('/uwsgistat/<appchoice>')
def uwsgistat(appchoice = None):
if appchoice == None:
return redirect(url_for('index'))
statsocket = '/tmp/' + appchoice + '-stat.sock'
if os.path.exists(statsocket):
client = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM )
client.connect(statsocket)
data = client.recv(2048)
@jbradach
jbradach / phpMyAdmin Nginx Config
Created August 3, 2014 20:54
Nginx location block for phpMyAdmin using an alias.
location /yourlocation {
alias /usr/share/phpmyadmin;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-ssl.sock;
fastcgi_index index.php;
}
}
@jbradach
jbradach / Nginx Configuration for Flask
Created August 3, 2014 21:05
Nginx server block for deploying a Flask app using uWSGI.
server {
listen 80;
server_name $hostname;
root /srv/www/$hostname/myapp;
location = /favicon.ico {
alias /srv/www/$hostname/public_html/favicon.ico;
access_log off;
log_not_found off;
}
@jbradach
jbradach / Nginx Configuration for UWSGI Upstream
Created August 6, 2014 13:42
Nginx IPv6 server block and upstream for uWSGI apps.
upstream uwsgi_host {
server unix:/tmp/flaskapp.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
location ^~ /static/ {
alias /srv/www/flaskapp/app/static;
@jbradach
jbradach / Init Script for Redmine using Puma
Last active August 29, 2015 14:05
Init script for Redmine and Puma
#! /bin/sh
### BEGIN INIT INFO
# Provides: redmine
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts redmine with puma
# Description: Starts redmine from /home/redmine/redmine.
### END INIT INFO
@jbradach
jbradach / Puma Config for Redmine
Last active August 29, 2015 14:05
Puma configuration file for Redmine
#!/usr/bin/env puma
# https://gist.github.com/jbradach/6ee5842e5e2543d59adb
# start puma with:
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
application_path = '/home/redmine/redmine'
directory application_path
environment 'production'
@jbradach
jbradach / Nginx Config for Redmine using Puma
Last active August 29, 2015 14:05
Nginx config for Redmine using Puma
# https://gist.github.com/jbradach/31ad6d9c84c3be3b5730
upstream puma_redmine {
server unix:/home/redmine/redmine/tmp/sockets/redmine.sock fail_timeout=0;
#server 127.0.0.1:3000;
}
server {
server_name YOUR.SERVER.NAME;
listen 80;
@jbradach
jbradach / Nginx Config for WordPress Over SSL
Last active August 29, 2015 14:09
Nginx server block config for WordPress over SSL
# https://gist.github.com/jbradach/e0da911b02cd2c3fbd8b
server {
listen [::]:80;
listen 80;
server_name rudeotter.foo www.rudeotter.foo;
return 301 https://rudeotter.foo$request_uri;
}