Skip to content

Instantly share code, notes, and snippets.

View leegee's full-sized avatar

Lee Goddard leegee

View GitHub Profile
@icantrap
icantrap / git-proxy.sh
Created October 26, 2010 20:25
How to Github and Gitorious over HTTP proxy

You could always use Smart HTTP.

For read-only (git:) urls, install corkscrew.

  1. Download git-proxy.sh. Put it somewhere and make it executable.

  2. Run git config --global core.gitproxy '/usr/local/bin/git-proxy.sh'

To clone, push, pull over ssh, add the contents of ssh_config to your ~/.ssh/config file.

@repeatingbeats
repeatingbeats / nodeunit_example.js
Created January 27, 2011 20:07
Example structure for nodeunit tests with nested groups and setUp/tearDown functions
/**
* Example structure for nodeunit tests with nested groups and setup/teardown
* functions. Run | nodeunit nodeunit_example.js | to see a printout of
* function names in the order that they are called. There aren't any actual
* tests here.
*/
process.env.NODE_ENV = 'test';
var testCase = require('nodeunit').testCase;
@bonyiii
bonyiii / gist:822123
Created February 11, 2011 09:24
PostgreSQL BEFORE INSERT trigger with function
# Function returns user.login, current year, the primary_key which is the id, in 5 length (Example: 00045)
string format
# http://developer.postgresql.org/pgdocs/postgres/functions-formatting.html
# to_char(5,'00000') results the same number format
CREATE OR REPLACE FUNCTION "public"."function_name" () RETURNS trigger AS
'
BEGIN
NEW.title = (SELECT login FROM users WHERE id = NEW.author) || to_char(NOW(),\'YYYY\') || lpad(NEW.id::char, 5, \'0\');
RETURN NEW;
END
@springmeyer
springmeyer / create_index.js
Created August 10, 2011 23:41
create an sqlite rtree spatial index using node-sqlite3 and node-mapnik
/*
wget http://dl.dropbox.com/u/342088/10m-us-parks-area.sqlite
ogr2ogr -f SQLite parks.sqlite ParkPly_900913.shp
dane$ ogr2ogr -f SQLite parks.sqlite ~/Documents/MapBox/cache/2976a0c1-10m-us-parks-area/2976a0c1-10m-us-parks-area.shp
*/
@neolitec
neolitec / Color.js
Created November 7, 2011 10:19
Javascript Color Class
var Color = function() {
this.r = this.g = this.b = 0;
this.h = this.s = this.l = 0;
this.a = 1;
};
/** RGB */
Color.prototype.cssRGB = function() {
return "rgb("+Math.round(255*this.r)+","+Math.round(255*this.g)+","+Math.round(255*this.b)+")";
};
Color.prototype.cssRGBA = function() {
@bmcbride
bmcbride / postgis_geojson.php
Created February 26, 2012 05:43
PHP PostGIS to GeoJSON
<?php
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*
* @param string $fields Fields to be returned *OPTIONAL (If omitted, all fields will be returned)* NOTE- Uppercase field names should be wrapped in double quotes
* @param string $parameters SQL WHERE clause parameters *OPTIONAL*
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@drawcode
drawcode / oracle_check_column_exists.sql
Last active March 23, 2023 08:18
Check if column exists on table in PGSQL
select table_name from user_tab_columns
where table_name = myTable and column_name = myColumn;
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@matt-baker
matt-baker / select-centroid-polygon-as-latlong
Last active February 17, 2023 10:01
Select lat/long centroid from a polygon in PostGIS.
-- SELECT polygon centroid as latitude/longitude in PostGIS
SELECT
st_x(st_transform(ST_Centroid(the_geom),4326)) as lat,
st_y(st_transform(ST_Centroid(the_geom),4326)) as long
FROM table;