Skip to content

Instantly share code, notes, and snippets.

View netconstructor's full-sized avatar
💭
pushing pixels

Christian Hochfilzer netconstructor

💭
pushing pixels
View GitHub Profile
@andrewxhill
andrewxhill / bounding circle on cartodb
Created February 23, 2012 16:27
Creates a bounding circle from the_geom_webmercator on cartodb
WITH inp as ( SELECT ST_Centroid(ST_Collect(ST_envelope(the_geom_webmercator))) as centroid,
ST_ConvexHull(ST_Collect(ST_Envelope(the_geom_webmercator))) as hull
FROM table_name GROUP BY some_column)
SELECT ST_Buffer(centroid,
ST_Length( ST_LongestLine(centroid, hull))) as the_geom_webmercator
FROM inp;
@deyvin
deyvin / inspectElement.js
Created February 29, 2012 13:19
Inspect Element With javaScript
function inspect(obj, maxLevels, level)
{
var str = '', type, msg;
// Start Input Validations
// Don't touch, we start iterating at level zero
if(level == null) level = 0;
// At least you want to show the first level
if(maxLevels == null) maxLevels = 1;
@tcabrol
tcabrol / yahoo_geocoder.py
Created March 5, 2012 22:24
Yahoo Geocoder
#!/usr/bin/env python
# encoding: utf-8
"""
geocoder.py
Created by Thomas Cabrol on 2012-02-08.
"""
import codecs
import simplejson
@netconstructor
netconstructor / location.php
Created March 17, 2012 11:07 — forked from thisislawatts/location.php
Advanced Custom Field - Location (+Search)
<?php
/*
* Advanced Custom Fields - New field template
*
* Create your field's functionality below and use the function:
* register_field($class_name, $file_path) to include the field
* in the acf plugin.
*
* Documentation:
@andrewxhill
andrewxhill / density_grid.sql
Created March 19, 2012 14:50
Create a density grid from geometries. For use in CartoDB
CREATE TYPE CDB_DensityGridPair AS (
geom GEOMETRY,
val FLOAT
);
CREATE OR REPLACE FUNCTION CDB_DensityGrid(table_name TEXT, geom_name TEXT, dimension FLOAT)
RETURNS SETOF CDB_DensityGridPair AS $$
DECLARE
BEGIN
RETURN QUERY
EXECUTE 'SELECT ST_Envelope(GEOMETRYFROMTEXT(''LINESTRING(''||(st_xmax(geom)+(seed/2))||'' ''||(st_ymax(geom)+(seed/2))||'', ''||(st_xmin(geom)-(seed/2))||'' ''||(st_ymin(geom)-(seed/2))||'')'',3857)) as geom, val FROM (SELECT '||dimension||' as seed, count(*)::float as val,
@netconstructor
netconstructor / density_grid.sql
Created March 19, 2012 16:28 — forked from andrewxhill/density_grid.sql
Create a density grid from geometries. For use in CartoDB
CREATE TYPE CDB_DensityGridPair AS (
geom GEOMETRY,
val FLOAT
);
CREATE OR REPLACE FUNCTION CDB_DensityGrid(table_name TEXT, geom_name TEXT, dimension FLOAT)
RETURNS SETOF CDB_DensityGridPair AS $$
DECLARE
BEGIN
RETURN QUERY
EXECUTE 'SELECT ST_Envelope(GEOMETRYFROMTEXT(''LINESTRING(''||(st_xmax(geom)+(seed/2))||'' ''||(st_ymax(geom)+(seed/2))||'', ''||(st_xmin(geom)-(seed/2))||'' ''||(st_ymin(geom)-(seed/2))||'')'',3857)) as geom, val FROM (SELECT '||dimension||' as seed, count(*)::float as val,
@springmeyer
springmeyer / install-tilemill-latest.sh
Last active April 7, 2022 20:00
install bleeding edge tilemill, nodejs, and mapnik
# First, clear out any old mapnik or node.js installs that might conflict
sudo apt-get purge libmapnik libmapnik-dev mapnik-utils nodejs
# Also clear out any old ppa's that might conflict
sudo rm /etc/apt/sources.list.d/*mapnik*
sudo rm /etc/apt/sources.list.d/*developmentseed*
sudo rm /etc/apt/sources.list.d/*chris-lea*
# add new ppa's
echo 'yes' | sudo apt-add-repository ppa:chris-lea/node.js
@cantremember
cantremember / nginx_vhost_example.conf
Created March 23, 2012 05:56
nginx vhost example
server {
include extra/proxy.conf;
include mime.types;
listen 80;
server_name blog.DOMAIN.NAME;
access_log logs/LOGFILE-access.log;
###error_log logs/LOGFILE-error.log debug;
@netconstructor
netconstructor / fixed-image-cropper.js
Created March 28, 2012 16:35 — forked from janfabry/fixed-image-cropper.js
WordPress Fixed Image Cropper
// pxi: pixels in image scale
// pxc: pixels in crop scale
// Helper function to create an element with optional attributes
// Doesn't jQuery already have this?
Monkeyman_FixedImageCroppper_createElement = function(tagName, attr)
{
if (!attr) {
attr = {};
}
@jcanfield
jcanfield / wp-modifydb.php
Created March 29, 2012 17:06
Serialized PHP Search and Replace
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.