Skip to content

Instantly share code, notes, and snippets.

@JeffJacobson
JeffJacobson / MapQuestInArcGisJSApi.html
Last active September 28, 2019 09:54
Demonstrates using MapQuest Open map service tiles with ArcGIS API for JavaScript.
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css" />
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.3compact" type="text/javascript"></script>
<style>
html, body, #map, map.container {
height: 100%;
@JeffJacobson
JeffJacobson / CsvToDictionaryList.cs
Last active December 16, 2015 07:38
Converts a Text Table file to Dictionaries.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Dict = System.Collections.Generic.Dictionary<string, object>;
/*
Licensed under the MIT license (http://opensource.org/licenses/MIT)
Copyright (c) 2013 Washington State Department of Transportation
@JeffJacobson
JeffJacobson / get-query-string-parameter.js
Created August 8, 2013 21:57
Gets a query string parameter.
/** Gets a query string parameter.
@returns {String|null} Returns the value of the query string parameter, or null if that parameter is not defined.
*/
function getQueryStringParameter(/** {String} */ key) {
var keyRe, match, output = null;
if (document.location.search.length) {
keyRe = new RegExp(key + "=([^\\&]+)", "i");
match = document.location.search.match(keyRe);
if (match) {
output = match[1];
@JeffJacobson
JeffJacobson / project-coordinate-arrays.js
Created January 30, 2014 20:51
Project arrays of coordinates using Proj4JS
// For use withhttp://proj4js.org/
/** @typedef {(string|proj4.Proj)} Projection
*
*/
/** @typedef {object} ThisProjectionInfo
* @property {?Projection} inPrj
* @property {?Projection} outPrj
*/
@JeffJacobson
JeffJacobson / JavaScript Date value to .NET DateTimeOffset.cs
Last active February 13, 2017 18:24
Convert a JavaScript date expressed in milliseconds into a .NET DateTimeOffset.
/// <summary>
/// Converts from a JavaScript Date value in milliseconds to a <see cref="DateTimeOffset"/>.
/// </summary>
/// <param name="milliseconds">Number of milliseconds since 1970-1-1T00:00:00</param>
/// <returns>Returns the <see cref="DateTimeOffset"/> equivalent of <paramref name="milliseconds"/>.</returns>
public static DateTimeOffset FromJSDateToDateTimeOffset(this double milliseconds)
{
return new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero).AddMilliseconds(milliseconds * 1000);
}
@JeffJacobson
JeffJacobson / google-analytics-honor-doNotTrack.js
Last active October 26, 2018 21:11
Google Analytics setup respecting navigator.doNotTrack.
// Setup Google Analytics, but not if user has specified that they don't want to be tracked.
(function (dnt, cookieDomain) {
var scriptTag, hostRe = new RegExp(cookieDomain.replace(".", "\\.") + "$");
if (dnt !== "yes" && dnt !== "1") {
window.ga = window.ga || function () { (ga.q = ga.q || []).push(arguments) }; ga.l = +new Date;
ga('create', 'YOUR-ID-HERE', hostRe.test(location.host) ? cookieDomain : "auto");
ga(function (tracker) {
tracker.set("appName", "Your app name here");
tracker.send('pageview');
});
@JeffJacobson
JeffJacobson / jsdoc.txt
Created March 27, 2014 17:16
Convert JSDoc property descriptions to C# properties using Regex search & replace in Visual Studio

Property Regex:

^\s*\*\s@property\s{(\w+)}\s(\w+)(?:\s*-\s*)?([^\r\n]+)\s*$

Captures

  1. type name
  2. property name
  3. property description

Replace:

/// $3\npublic $1 $2 { get; set; }

@JeffJacobson
JeffJacobson / JSON_UDL.xml
Last active August 29, 2015 14:03
Notepad++ User Defined Languages
<NotepadPlus>
<UserLang name="JSON" ext=".json" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments"></Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@JeffJacobson
JeffJacobson / pills.md
Last active August 29, 2015 14:12
Pill Organizer

Don't wait until the end of the week to refill the pill organizer.

  • Starting on Tuesday, start refilling the pillbox for the next week.
  • Leave a blank day before the current day to avoid confusion (e.g., forgetting what day it is and taking the next day's dose).

Sunday

Sun. Mon. Tue. Wed. Thu. Fri. Sat.
Take 💊 💊 💊 💊 💊 💊 💊
@JeffJacobson
JeffJacobson / extractattachments.py
Created February 4, 2015 00:06
Extract attachments from a file geodatabase
"""Extracts attachments from a file geodatabase.
"""
import os, re
from os.path import join, exists
from arcpy import da
def extract_attachments(gdb, attachment_dir="images"):
"""Extract attachments from a geodatabase to the filesystem.
"""
attach_table_name_re = re.compile(r"^\w+(?=__ATTACH$)", re.IGNORECASE)