Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@eduardo-matos
eduardo-matos / analytics.js
Last active June 13, 2016 14:48
Loading Google Analytics using Dojo Toolkit (1.8+)
require([
'dojo/request/script'
], function(
script
) {
'use strict';
var _gaq = window._gaq = window._gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
@odoe
odoe / IndexedDBStore.js
Last active December 25, 2015 03:39
IndexedDBStore and PouchDBStorefor holding ArcGIS Features.
/*global define */
/*jshint browser:true, laxcomma:true, newcap:false*/
/** Heavily influenced by https://github.com/pjekel/indexedDB **/
define([
'dojo/Deferred',
'dojo/_base/declare',
'dojo/_base/array',
'dojo/store/util/QueryResults',
'dojo/store/util/SimpleQueryEngine'
], function (Deferred, declare, array, QueryResults, SimpleQueryEngine) {
@brianarn
brianarn / oneweirdtrick.md
Last active October 22, 2020 23:04
One Weird Trick to never missing a console.log's output

One Weird Trick to never missing a console.log's output

Friends! Have you ever been developing, littered your code with console statements, and then realized you couldn't find what you were looking for? Have you ever wondered, "How can I make this console.log statement stand out in a crowd?"

WONDER NO MORE!

You can provide a special %c prefix to your logged string, and then all magical and printf-like, you can then provide some CSS to style up that line!

Here's a couple of examples that I was JUST using!

@raykendo
raykendo / ArcGIS-JSAPI-MapClickByQueryHack.md
Last active July 6, 2018 20:29
ArcGIS-JSAPI: Clicking on a webmap without clicking on a webmap

Clicking on a map without clicking on a map

An ArcGIS JavaScript API hack

Purpose: I have a map application with a list of results from a query. When I click on one of the items in the result list, I wanted the map to zoom to the associated feature, and trigger a click that shows the result in a popup.

Library: ArcGIS JavaScript API

Version: tested on versions 3.9-3.13.

@raykendo
raykendo / arcgis-jsapi-ondrawbegin.js
Last active August 29, 2015 14:21
ArcGIS-JSAPI: DrawingToolbar hack for onDrawBegin
/*
* Making up for a missing "draw-begin" or "draw-start" event for the ArcGIS JavaScript API Drawing toolbar
*
* Problem: While the drawing toolbar in the ArcGIS JavaScript API has a "draw-end" and a "draw-complete"
* event, it doesn't have a "draw-start" or "draw-begin" event.
*
* Solution: Use a dojo/on pausable event that is only unpaused after the draw-end event.
*/
require(["esri/map", "dojo/on", "esri/toolbars/draw"], function (Map, dojoOn, Draw) {
var map = new Map("mapdiv", {});
@raykendo
raykendo / arcgis-jsapi-map-zoom-in-closer.js
Created May 29, 2015 21:08
ArcGIS JSAPI: Map with ESRI basemap zooming in closer than basemap allows.
require(["esri/Map"], function (Map) {
var map = new Map("mapdiv", {
basemap: "streets",
center: [-15.469, 36.428]
lods: [
//{
// level: 0,
// resolution: 156543.033928,
// scale: 591657527.591555
//},
@kaito834
kaito834 / urllib-request_basicAuth.py
Last active October 26, 2022 17:52
Python 3.x snippet code for Basic Authentication HTTP request by urllib.request
#!/usr/bin/env python
#
# I tested by Python 3.4.3 on Windows 8.1
# Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
import urllib.request
import getpass
# If you access to url below via Proxy,
# set environment variable 'http_proxy' before execute this.
@raykendo
raykendo / customMeasurementDijit.js
Last active August 29, 2015 14:23
ArcGIS JSAPI: Measurement + Popup Combo
/*
* Custom Measurement Widget extension that connects to Popup dijit (esri/dijit/Popup),
* retrieves the selected feature, then passes the geometry to be measured by the Measurement Dijit.
*/
define("custom.Measurement",
[
"dojo/_base/declare",
"dojo/_base/lang",
"esri/dijit/Measurement",
"dojo/query",
@raykendo
raykendo / BigQueryTask.js
Last active February 12, 2022 00:21
ArcGIS JSAPI Hack - Getting around the 1000 results limit for queries
/** globals define */
define([
"dojo/_base/declare",
"dojo/Deferred",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/request"
], function (
declare, Deferred, Query, QueryTask, esriRequest
) {