Skip to content

Instantly share code, notes, and snippets.

@uniomni
uniomni / gist:779194
Created January 14, 2011 04:56
Geoserver REST command examples

REST commands, generated by Risk-in-a-Box and known to work

Upload shapefile + associated style. Then activate style and make it default.

PUT -H "Content-type: application/zip" "http://localhost:8080/geoserver/rest/workspaces/exposure/datastores/AIBEP_schools/file.shp" --data-binary "@AIBEP_schools.zip"
POST -H "Content-type: text/xml" "http://localhost:8080/geoserver/rest/styles" --data-ascii "<style>AIBEP_schoolsAIBEP_schools.sld</style>"
PUT -H "Content-type: application/vnd.ogc.sld+xml" "http://localhost:8080/geoserver/rest/styles/AIBEP_schools" --data-binary "@AIBEP_schools.sld"
PUT -H "Content-type: text/xml" "http://localhost:8080/geoserver/rest/layers/AIBEP_schools" --data-ascii "AIBEP_schoolstrue"

@remy
remy / trim-canvas.js
Last active September 9, 2024 21:52
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,
@stevenou
stevenou / GeolocationModule.mm
Created February 14, 2012 21:15
Geofencing in Titanium
// this file located in /Library/Application Support/Titanium/mobilesdk/osx/{version_number}
// add the following methods to GeolocationModule.mm
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES),@"success",[NSDictionary dictionaryWithObjectsAndKeys:NUMDOUBLE(region.center.latitude),@"lat",NUMDOUBLE(region.center.longitude),@"lng",NUMDOUBLE(region.radius),@"radius",region.identifier,@"identifier",nil],@"region",nil];
if ([self _hasListeners:@"enteredRegion"])
{
[self fireEvent:@"enteredRegion" withObject:event];
@matsadler
matsadler / project.js
Created October 7, 2012 20:29
JavaScript mercator projection
/*jslint vars: true */
// adapted from http://wiki.openstreetmap.org/wiki/Mercator#JavaScript
(function () {
var project = {};
if (typeof exports === "object") {
module.exports = project;
} else {
this.project = project;
@rampicos
rampicos / social.js
Last active January 10, 2019 10:10
Social.js is the Appcelerator Titanium's Alloy Widget at first it is used to connect with Twitter only, though twitter and linkedin uses OAuth for its authentication I made some changes on Social.js for multi-purpose to connect Twitter and LinkedIn
function hex_sha1(s) {
return binb2hex(core_sha1(str2binb(s), s.length * chrsz));
}
function b64_sha1(s) {
return binb2b64(core_sha1(str2binb(s), s.length * chrsz));
}
function str_sha1(s) {
return binb2str(core_sha1(str2binb(s), s.length * chrsz));
@nutiteq
nutiteq / GetFeatureInfoListener.java
Created March 4, 2013 10:10
How to have GetFeatureInfo URL for Nutiteq SDK
@Override
public void onMapClicked(double x, double y, boolean longClick) {
// your activity should have getter for the MapView
MapView map = ((TesterMap3DActivity) mapActivity).getMapView();
float zoom = map.getZoom();
double worldSize = 360.0; // for EPSG3857: Math.PI * 6378137.0f * 2.0f;
double tileSizeHalf = worldSize / Math.pow(2,zoom) / 2.0;
double wgsX = (new EPSG3857()).toWgs84(x, y).x;
@aaronksaunders
aaronksaunders / TiParse.js
Last active December 3, 2017 11:46
UPDATED PROJECT: http://bit.ly/1p61VRC Tested w/ latest version of parse "parse-1.2.18.js" I took a look at the latest Parse update to the APIs and they have made it even more complex to integrate Appcelerator and Facebook since they have integrated the FB Javascript API into the Parse Module directly.this hack just overrides the FB functions th…
/**
*
* Aaron K. Saunders
* twitter: @aaronksaunders
* last updated may 23, 2014
*
* See more Appcelerator Information on Clearly Innovative Blog
*
* www.clearlyinnovative.com
* blog.clearlyinnovative.com
@antoniolocandro
antoniolocandro / WGS-Area-km2
Created December 5, 2013 15:50
Calculate area of polygon in GCS WGS 84 in Km2 using POSTGIS ST_Area
-- Calculate Km2 of a polygon stores in GCS WGS84
-- by default ST_Area returns the calculation in meters so the appropriate conversion was applied
-- fir_area_20131205 was the example table used
-- the spatial data was in a geom field so geom::geography was added
SELECT ST_Area(geom::geography)/1000000 as sqKM from fir_area_20131205
@geobabbler
geobabbler / GlobalMercator.cs
Created February 20, 2014 18:26
C# implementation of GlobalMercator class from globalmaptiles.py
/*
GlobalMercator.cs
Copyright (c) 2014 Bill Dollins. All rights reserved.
http://blog.geomusings.com
*************************************************************
Based on GlobalMapTiles.js - part of Aggregate Map Tools
Version 1.0
Copyright (c) 2009 The Bivings Group
All rights reserved.
Author: John Bafford