Skip to content

Instantly share code, notes, and snippets.

@mpriour
mpriour / AuthProvider.tsx
Created Oct 20, 2020
async reducer example
View AuthProvider.tsx
import { Context, createContext, h } from "preact";
import { useMemo } from "preact/hooks";
import { UserSession } from "@esri/arcgis-rest-auth";
import useLocalStorageState from "../hooks/useLocalStorageState";
import useAsyncReducer from "../hooks/useAsyncReducer";
interface IProviderProps {
children?:any
}
@mpriour
mpriour / settings.json
Created Mar 31, 2020
vscode color customization settings
View settings.json
"workbench.colorCustomizations": {
"editorLineNumber.foreground": "#cccccc",
"editor.findMatchBackground": "#f7d30766",
"editor.findMatchHighlightBackground": "#f7df0766",
"editor.background": "#000000",
"panel.background": "#000000",
"sideBar.background": "#000000",
"tab.activeBackground": "#000000",
"sideBar.border": "#4c4c4c",
"[Night Owl (No Italics)]": {
View designer.html
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<polymer-element name="my-element">
View designer.html
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
@mpriour
mpriour / float_equal.js
Created Jun 19, 2014
floating point equality in js
View float_equal.js
var eq = function(n1, n2, decimals) {
var equal = false;
if (decimals === undefined) {
decimals = 15;
}
if (decimals) {
var factor = Math.pow(10, decimals);
var a = Math.round(n1 * factor) / factor, b = Math.round(n2 * factor) / factor;
console.log(n1 + ' => ' + a + " :: " + n2 + ' => ' + b);
equal = a == b;
@mpriour
mpriour / snippets
Created Mar 21, 2014
snippets for debugging js api talk
View snippets
<script>
var map;
require(["esri/map", "dojo/domReady!"], function(Map) {
map = new Map("mapDiv", {
basemap: "topo",
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
map.on('load',function(evt){
@mpriour
mpriour / jsdocs-conf.json
Created Oct 22, 2013
My jsdoc configuration for esri js api & DocStrap templates
View jsdocs-conf.json
{
"tags" : {
"allowUnknownTags" : true
},
"plugins" : ["plugins/markdown"],
"source": {
"excludePattern": "(^|\\/|\\\\)\\."
},
"opts" : {
"template": "/Users/matt7238/projects/docstrap/template/",
@mpriour
mpriour / tables.md
Last active Dec 23, 2015
testing md tables
View tables.md

Regular Tables

Strict Table Markup

@mpriour
mpriour / requestWorker.js
Created Sep 11, 2013
a closure compiler compatible network request worker
View requestWorker.js
/**
* Takes a worker message with a request object as the data member, then sends and recieves result via XHR
* @param {Event} evt
*/
function sendRequest(evt) {
var args = evt.data;
var method = args.method;
var url = args.url;
var options = args.options;
var data = options.data;
@mpriour
mpriour / test.js
Created Sep 6, 2013
A set of tests for event listening & firing on esri.dijit._EventedWidget subclasses
View test.js
require(["dojo/_base/declare", "esri/dijit/_EventedWidget"],
function(declare, _EventedWidget) {
var MyWidget = declare([_EventedWidget], {
test: function() {
this.emit("ee");
}
});
var MyMappedWidget = declare([_EventedWidget], {
_eventMap: {
"data-ready": ["provider"]