Skip to content

Instantly share code, notes, and snippets.

@mudpuddle
mudpuddle / MercatorToLatLon.js
Last active July 23, 2021 14:59
Convert Web Mercator to WGS 84 Lat/Long
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 };
}
@mudpuddle
mudpuddle / LatLonToMercator.js
Last active December 20, 2015 10:20
Convert WGS 84 Lat/Long to Web Mercator
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};
}
@mudpuddle
mudpuddle / indexOfPrototype.js
Created July 30, 2013 18:43
Needed to add indexOf functionality to older browsers including IE8
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) {
@mudpuddle
mudpuddle / Command Line MS SQL Server
Created October 29, 2013 21:47
SQL Server Stuff to Remember.
-- osql -U<username> -P<password> -S<server> -i<path to sql script> -o<output>
Excel Lookup
=INDEX(array of information you would like to have returned, MATCH(corresponding cell you would like to match to, array of matching info corresponding to the column of info you would like to have returned, 0))
@mudpuddle
mudpuddle / README.md
Last active December 27, 2015 11:59
launchd script to open webpage everyday at a certain time

The plist file goes one of 3 places:

  • System Tasks - /Library/LaunchDaemons/
  • If Any User Logged In - /Library/LaunchAgents/
  • Only If You Are Logged In - ~/Library/LaunchAgents/

The script can be anywhere, but it needs to be executable

chmod 755 --path to script file

In the LaunchAgent folder type the following...

@mudpuddle
mudpuddle / .hgignore
Created December 19, 2013 23:36
hgignore
syntax: glob
.DS_Store
log
.powenv
*.komodoproject
.komodotools
bin
bin/*.*
lib
lib/*.*
@mudpuddle
mudpuddle / .gitignore
Last active December 31, 2015 21:39
gitignore
.DS_Store
log
.powenv
*.komodoproject
.komodotools
bin
bin/*.*
lib
lib/*.*
include
@mudpuddle
mudpuddle / bash_profile
Last active August 29, 2015 13:57
.bash stuff
### Android SDK
export PATH=$PATH:/Users/jwegner/Library/Developer/Xamarin/android-sdk-mac_x86/platform-tools:/Users/jwegner/Library/Developer/Xamarin/android-sdk-mac_x86/tools
### Postgres
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
alias ll='ls -lahG'
alias gitlog='git log --pretty=format:"%h %s" --graph'
alias code='cd /Users/jwegner/jesse/code; ls'
alias trimble='cd /Users/jwegner/jesse/trimble; ls'
alias pyserver='python -m SimpleHTTPServer '
@mudpuddle
mudpuddle / getParameterByName.js
Last active August 29, 2015 14:05
Get url parameters by name using javascript.
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}