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)
//
@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'] = [];
@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()
@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 / 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
) {
@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.

@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."