Skip to content

Instantly share code, notes, and snippets.

View ca0v's full-sized avatar

Corey Alix ca0v

  • Greenville, SC
View GitHub Profile
@ca0v
ca0v / async.js
Created November 13, 2013 15:14
async plugin specifically for google maps. example: require(["plugins/async!http://maps.google.com/maps/api/js?v=3&sensor=false"], function () {// can use google.maps now});
/**
* Dojo AMD Google Maps Loader Plugin
*/
define([
"dojo/_base/kernel",
"dojo/topic"
], function (kernel, topic) {
var w = kernel.global;
var cb ="_googleApiLoadCallback";
@ca0v
ca0v / reloadManager.js
Last active December 29, 2015 17:18
Reloads modules and widgets when corresponding AMD module is modified on the server. Uses SignalR Hub for notification. Facilitates development of widgets and singletons without the need to refresh the browser. State is captured during "unload".
define(["dojo/dom-construct", "dijit/registry"], function (domConstruct, registry) {
return function (myHub) {
myHub.client.reload = function (mid) {
var mods = mid.split(",");
// call unload on old modules
require(mods, function () {
var factories = Array.prototype.slice.apply(arguments);
var state = mods.map(function (mid, i) {
@ca0v
ca0v / grass.sld.d.ts
Created December 5, 2013 17:24
First attempt at creating a typescript interface for the GeoServer "grass" SLD. Notice "Grass" is in the definition!
interface IGrassTestStyledLayerDescriptor {
version: string;
namedLayers: {
Grass: {
userStyles: Array<{
defaultsPerSymbolizer: boolean;
rules: Array<{
symbolizer: {
Polygon: {
fill: boolean;
@ca0v
ca0v / poly_landmarks.d.ts
Created December 5, 2013 18:52
Here's a typescript interface definition generated from poly_landmarks.sld then modified to eliminate the layer name from the definition.
///<reference path="../../ref.d.ts"/>
interface IStyleLayerDescriptorFilter {
type?: string;
property?: string;
value?: string;
filters?: Array<IStyleLayerDescriptorFilter>;
}
// TODO: requires id to be optional for validation to succeed..report as TS defect?
interface IStyledLayerDescriptorRule {
@ca0v
ca0v / ogc.d.ts
Last active December 30, 2015 16:19
First shot at describing OGC interfaces in json
// converted from ol readers
declare module ogc {
module wms {
export interface ContactPersonPrimary {
ContactPerson: string;
ContactOrganization: string;
}
@ca0v
ca0v / howToBestMapQueryResults.js
Last active January 2, 2016 20:59
Any thoughts on how to do this better? In 0.9.5 this fails because the callback does not return an HTMLElement:
// Fails because return value is not HTMLElement
query(".symbolBuilderPane").map(node => registry.byNode(node));
//NodeList isn't really an array so this also fails:
array.map(query(".symbolBuilderPane"), node => registry.byNode(node));
//No type of node so this fails:
array.map(<any>query(".symbolBuilderPane"), node => registry.byNode(node));
// leaving me here:
@ca0v
ca0v / dojotypescript.js
Last active March 24, 2016 07:36
How to extend a dojo class using a typescript class?
///<reference path="../ref.d.ts"/>
import declare = require("dojo/_base/declare");
import lang = require("dojo/_base/lang");
import ContentPane = require("dijit/layout/ContentPane");
class LayerStylePane extends ContentPane {
constructor(options: any, container?: HTMLElement) {
this.baseClass = "layerStylePane";
options.content = "<b>HELLO</b>";
super(options, container);
@ca0v
ca0v / gist:061dcd71bd95014b6006
Last active August 29, 2015 14:09
ArcGIS Javascript API Debugging Configuration
<html>
<head>
<title>ArcGIS Javascript API Debugging Configuration</title>
<link rel="stylesheet" href="http://localhost:84/arcgis_js_api/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
@ca0v
ca0v / gist:c9504ef893015a7dce39
Created November 14, 2014 14:30
typescript definition for json schema
declare module 'interfaces/json-schema' {
interface IDependencyDescriptor {
[s: string]: string;
}
interface IPropertyDescriptor {
[s: string]: {
'$ref'?: string;
type?: string;
@ca0v
ca0v / MyContentPane
Created December 4, 2014 17:35
Typescript Hack to extend ContentPane
import Deferred = require('dojo/Deferred');
import ContentPane = require("dijit/layout/ContentPane");
import _WidgetBase = require("dijit/_WidgetBase");
/*
dijit/layout/ContentPane wrapper as native typescript class
Constructor replaces itself with the underlying ContentPane
*/
class MyContentPane implements ContentPane {