Skip to content

Instantly share code, notes, and snippets.

@abenrob
abenrob / localdev.md
Created January 10, 2014 08:28
apache+php+postgresql(postgres.app)+mavericks

download php...

tar -jxvf php-5.5.7.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.5.7 /usr/include/php
cd /usr/include/php/php-5.5.7
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
cd ext/pdo_pgsql
@abenrob
abenrob / README.md
Last active December 28, 2015 17:39 — forked from mbostock/.block

This donut chart is constructed from a CSV file storing the populations of various age groups. The chart employs a number of D3 features:

@abenrob
abenrob / git copy to server root
Last active December 28, 2015 01:59
git copy to server root
## assumes sibling dirs gitcode, export. commands run in gitcode dir post commit/pull
# need to clear out exports and server dir if files removed from repo
sudo rm -r /var/www/<target app>/*
rm -r ../export/*
# create archive of repo, pipe to ../export
git archive HEAD | (cd ../export && tar -xvf -)
# copy contents of ../export to /var/www/<target app>
--FROM http://blog.mackerron.com/2012/06/01/postgis-2-ubuntu-12-04/
mkdir -p src
# First install PostgreSQL 9.2, plus contributed packages and any missing prerequisites
# ===
# add the Postgres PPA
echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' \
@abenrob
abenrob / PosgresSQL start stop restart
Created November 11, 2013 23:45
PosgresSQL start/stop/restart
start
/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
stop
/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data
restart
/usr/local/pgsql/bin/pg_ctl restart -D /usr/local/pgsql/data
@abenrob
abenrob / git scenarios.md
Last active June 9, 2017 12:18
Git scenarios

gh-pages from CLI

in project repo

git checkout --orphan gh-pages

now in un-linked gh-pages repo...

git add --all
git commit -a -m "commit message here..."

git push origin gh-pages

import json
from functools import wraps
from flask import redirect, request, current_app
def support_jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
function MercatorToLatLon(mercX, mercY) {
var rMajor = 6378137; //Equatorial Radius, WGS84
var shift = Math.PI * rMajor;
var lon = mercX / shift * 180.0;
var lat = mercY / shift * 180.0;
lat = 180 / Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180.0)) - Math.PI / 2.0);
return { 'Lon': lon, 'Lat': lat };
}
function LatLonToMercator(lat, lon) {
var rMajor = 6378137; //Equatorial Radius, WGS84
var shift = Math.PI * rMajor;
var x = lon * shift / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * shift / 180;
return {'X': x, 'Y': y};
}