Skip to content

Instantly share code, notes, and snippets.

@TheBryanMac
TheBryanMac / ArcPy_SDE_and_Versions.py
Created October 1, 2018 19:55
Python ArcPy Connect to SDE and versions
#Name: Python ArcPy Connect to SDE and versions
#Author: Bryan McIntosh
#Description: An approach to connect to SDE, create a new version, and change
# to the new version - inside a python script.
import arcpy, datetime, os, tempfile, shutil
#Create a string of the date to append to version name (to keep unique)
now = datetime.datetime.now()
strDate = str(now.year) + str(now.month) + str(now.day) + str(now.hour) + str(now.minute) + str(now.second)
#Create a temp directory using tempfile module to store SDE connection files
sdeTempPath = tempfile.mkdtemp()
@TheMapSmith
TheMapSmith / flights.js
Last active March 17, 2024 15:51
Fetching flight info
var fs = require('fs');
var request = require('request-promise');
var moment = require('moment')
// Globals
global.timestamp = moment().unix()
global.allPlaybacks = [];
global.geojson = {};
global.geojson['type'] = 'FeatureCollection';
global.geojson['features'] = [];
@odoe
odoe / layerlist.js
Created November 6, 2016 19:22
Ghetto JSAPI layerlist toggle in JavaScript
function layerList(layers) {
const list = layers.reduce((ul, layer) => {
const li = document.createElement('li');
const toggle = document.createElement('input');
toggle.type = 'checkbox';
toggle.checked = layer.visible;
layer.watch('visible', () => toggle.checked = layer.visible);
toggle.addEventListener('change', () => layer.visible = !layer.visible);
const label = document.createElement('span');
label.innerHTML = layer.title;
@maptastik
maptastik / notepaddycakes.js
Created August 24, 2016 03:15
A bookmarklet to turn a browser into a notepad
javascript:(function()%7Blocation.assign(%22data%3Atext%2Fhtml%2C%20%3Chtml%20contenteditable%3E%22)%7D)()
@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 / 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 / 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 / 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
@raykendo
raykendo / UniqueComboBox.js
Last active December 8, 2015 23:17
David Walsh's Display Unique Combobox (https://davidwalsh.name/unique-combobox) updated for AMD
/**
* An update on David Walsh's Unique Combobox
* Updated for Dojo AMD (tested at v. 1.10)
* Originally posted: https://davidwalsh.name/unique-combobox
*/
define("davidwalsh.form._UniqueComboBoxMenu",
["dojo/_base/declare", "dojo/_base/array", "dijit/form/_ComboBoxMenu"],
function (declare, arrayUtils, _ComboBoxMenu) {
return declare([_ComboBoxMenu], {
createOptions: function (results, dataObject, labelFunc) {