Skip to content

Instantly share code, notes, and snippets.

@raykendo
raykendo / index.html
Last active September 23, 2016 15:47
Mapillary JS + ArcGIS JavaScript API 3.x
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mapillary-JS + ArcGIS JSAPI 3.x example</title>
<link rel="stylesheet" href="https://unpkg.com/mapillary-js@1.7.1/dist/mapillary-js.min.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
<script type="text/javascript">
dojoConfig = {
async: true,
@raykendo
raykendo / swt_linkedin1.md
Last active August 23, 2016 21:40
Saving you some embarrassment on LinkedIn with this console tip

Browser console tips

LinkedIn - People I don't know

Current date: 2016-08-23

I'm one of those people who still holds on to the hope that LinkedIn is a good idea. I check in daily and check all the areas I've been trained to look at on most social media sites.

The thing that annoys me about LinkedIn is the "People you may know" page. That long list of your contacts' third cousins, college buddies, and other total strangers. They've designed the page so that you'll accidentally click on one of those strangers, causing an embarrasing incident.

"I'm not really interested in hiring a life-coach at my company right now. Sorry to get your hopes up."

@raykendo
raykendo / caesar.py
Created August 10, 2016 15:41
Caesar Cypher
#!/usr/bin/python
import string
import sys
def caesar(value):
for i in range(0, 26):
#print(value.translate(str.maketrans(myAlphabet, myAlphabet[i:] + myAlphabet[:i])))
print(value.translate(str.maketrans(string.ascii_letters, string.ascii_lowercase[i:] + string.ascii_lowercase[:i] + string.ascii_uppercase[i:] + string.ascii_uppercase[:i])))
@raykendo
raykendo / app.js
Created March 30, 2016 18:17
Formatting Dates Only in ArcGIS Online web map popups.
require(["esri/arcgis/utils"], function (arcgisUtils) {
//...
// functionality to fix dates
var oneDay = 24 * 60 * 60 * 1000;
function timeFix(value) {
var dateShift, val;
if (value === undefined || value === null) {
return value;
}
@raykendo
raykendo / example.js
Created March 30, 2016 17:17
Quick and Dirty show Date from feature
require(["esri/map", "esri/layers/FeatureLayer", "esri/tasks/query"], function (map, FeatureLayer, query) {
var features = [/* assume a list of feature graphics will be assigned here soon */];
// do stuff to assign maps, feature layers, etc.
// do stuff to assign features as a list of search results from a feature layer
var importantDates = features.map(function (feature) {
if (feature.attributes["ImportantDate"] !== null) {
return new Date(feature.attributes["ImportantDate"]);
}
});
@raykendo
raykendo / UTCToMyDateTime.js
Last active March 29, 2016 15:48
UTC to current time zone converter
/*
* Dojo AMD helper function to convert dates stored as UTC milliseconds from January 1, 1970 to a date/time format more fitting
* for current location.
* Reason: ArcGIS Server stores dates without times as midnight UTC. When those times are translated into real dates,
* the browser often corrects the date for time zone differences, moving the date back several hours in the U.S.
*/
/* globals define */
define(function () {
var oneDay = 24 * 60 * 60 * 1000;
/**
@raykendo
raykendo / LayerListModified.js
Last active March 24, 2016 14:48
ArcGIS JSAPI Hack: LayerList fixes
define([
"dojo/_base/declare",
"dojo/_base/array",
"dojo/query",
"put-selector/put",
"esri/dijit/LayerList"
], function (declare, arrayUtils, dojoQuery, put, LayerList) {
return declare([LayerList], {
@raykendo
raykendo / Gruntfile.js
Last active March 17, 2016 19:31
Grunt Work: Generic Grunt setup for my ArcGIS JSAPI Applications (work in progress)
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['Gruntfile.js', 'src/**/*.js'],
options: {
browser: true,
'-W083': true, // don't form functions within loops (hard when calling Array.prototype.forEach inside another Array.prototype.forEach)
scripturl: true, // no script URL (I sometimes use javascript:void(0); instead of # when I have routes)
@raykendo
raykendo / PointWithin.js
Created February 1, 2016 16:29
Finding a point within a geometry for ArcGIS JavaScript API using client-side processing
define([
"dojo/_base/array",
"esri/geometry/Polygon",
"esri/geometry/Polyline",
"esri/geometry/Point",
"esri/geometry/geometryEngine"
], function (arrayUtils, Polygon, Polyline, Point, geometryEngine) {
/**
* Finds a point on a polyline
@raykendo
raykendo / UrlSearchParameters.js
Created January 18, 2016 17:00
Dojo plugin to parse URL parameters and translate them to a where clause for an ArcGIS JavaScript API Query
/**
* A dojo plugin that extracts possible query parameters from the URL.
* @module search/UrlSearch
*/
define(["esri/urlUtils"], function (urlUtils) {
// regex for parameter names to ignore
var ignoreParameters = [
/^appid$/i, // ArcGIS Online uses appid parameter to define application id
/^folderid$/i, // ArcGIS Online uses folderid to define folder hash where webmap is stored
/^webmap$/i // ArcGIS Online uses webmap property to define the map to use in the application