This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://gist.github.com/raw/554178/601c25f8ed6e84715dc36804efad915b4a62956d/XMLSerializer.js | |
var xmlString = ''; | |
try { | |
// this works for Firefox, Chrome, Safari | |
xmlString = new XMLSerializer().serializeToString( clickResult ); | |
} catch (e) { | |
// this works for IE6+ | |
xmlString = clickResult.xml; | |
} | |
alert(xmlString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebStorm Search and Replace newline with backslash and newline | |
Text to find: \n | |
Replace with: \\\\\n | |
Regex on. | |
Results: | |
var xml = '<node1>\ | |
<node2></node2>\ | |
</node1>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTTPS in ExpressJS 3.0 | |
// Exec these 3 lines to generate your PEM files (Linux, OSX with OpenSSL installed) | |
//> openssl genrsa -out privatekey.pem 1024 | |
//> openssl req -new -key privatekey.pem -out certrequest.csr | |
//> openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem | |
//Express app.js, HTTPS on port 3443 | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before you install a specific version of a package you need it's complete version. | |
This will be displayed when you run: | |
apt-cache showpkg <package name> | |
e.g. | |
apt-cache showpkg subversion-tools | |
> Package: subversion-tools | |
> Versions: | |
> 1.3.2-5~bpo1(/var/lib/dpkg/status) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/postgresql/9.1/main/ | |
/var/lib/postgresql/9.1/main | |
/usr/share/postgresql/9.1/contrib/postgis-2.1/ (postgis.sql) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find myForm in myIframe | |
var $myForm = $('#myIframe').contents().find('#myForm'); | |
// set inputField value in $myForm | |
$('input[name="inputField"]', $myForm).val(JSON.stringify(inputField)); | |
// check checkbox value in $printForm | |
$('input[name="myCheckbox"]', $myForm).val() === 'on' | |
// without jQuery | |
document.myForm.myCheckbox.checked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var olDeleteControl = new OpenLayers.Control.SelectFeature( layerToDrawOn, { | |
clickout: false, toggle: false, | |
multiple: true, hover: false, | |
toggleKey: "ctrlKey", // ctrl key removes from selection | |
multipleKey: "shiftKey", // shift key adds to selection | |
box: true | |
}); | |
olDeleteControl.events.on({ | |
'boxselectionend': function(layers){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OpenLayers.Geometry.LinearRing.prototype.getRadius = function() { | |
//http://gis.stackexchange.com/questions/20982/how-to-get-the-radius-of-a-circle-in-openlayers | |
//Use the formula for the area of a regular polygon. | |
//With a radius of r and k vertices (where in practice k typically varies from 4 through 360), | |
//the area now is A = r^2 * k Sin(360 / k) / 2. Solving for r yields r = Sqrt(2 A / (k Sin(360/k))). | |
//For k = 40 that's r = 0.565352 * Sqrt(A). | |
var area = Math.abs( this.getArea() ); | |
var polygonSides = 100; | |
var radius = Math.sqrt( 2*area/(polygonSides*Math.sin(2*Math.PI/polygonSides)) ); | |
return radius; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Given a resolutionArray | |
* resolutionArr[0] = 100 | |
* [1] = 50 | |
* [2] = 25 | |
* [3] = 12.5 | |
* | |
* getClosestResolutionIdx(resolutionArray, 51) === 1 // round down to 50 | |
* getClosestResolutionIdx(resolutionArray, 76) === 0 // round up to 100 | |
* getClosestResolutionIdx(resolutionArray, 10) === 3 // round up to 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mapProto = OpenLayers.Map.prototype; | |
mapProto.initialize = function (div, options) { | |
//your map initialization code here | |
}; | |
mapProto.CLASS_NAME = 'OpenLayers.Map_Custom'; | |
OpenLayers.Map_Custom = OpenLayers.Class( mapProto ); |
OlderNewer