Skip to content

Instantly share code, notes, and snippets.

View ca0v's full-sized avatar

Corey Alix ca0v

  • Greenville, SC
View GitHub Profile
// originally from https://dl.dropboxusercontent.com/u/52219470/Source/JSonPresentationFormatter.cs
public class JSonPresentationFormatter
{
public static string Format(string text)
{
if (string.IsNullOrEmpty(text)) return string.Empty;
text = text.Replace(System.Environment.NewLine, string.Empty).Replace("\t", string.Empty);
var offset = 0;
var output = new StringBuilder();
@ca0v
ca0v / gist:d186cdf3757fa4f84725
Created April 17, 2015 13:18
H8 ConfigTypes
declare module "H8/ConfigTypes" {
interface IMapDrawerDatasetsConfigElement {
DatasetsElement: IMapDrawerDatasetsElement;
PreferencesElement: IMapDrawerPreferencesElement;
DatasetGroupsElement: IMapDrawerDatasetGroupsElement;
DatasetLevelsElement: IMapDrawerDatasetsLevelsElement;
DatasetToolsElement: IMapDrawerToolsConfigElement;
TileCacheUrl: string;
JsMixin: string;
@ca0v
ca0v / proj4.d.ts
Last active August 22, 2016 15:43
proj4.d.ts
declare module "proj4" {
interface Transformer {
forward: (p: Point) => Point;
inverse: (p: Point) => Point;
}
class Point {
x: number;
y: number;
@ca0v
ca0v / Google Directions
Created March 4, 2015 20:18
Use Google Directions to render a route on a Google Map
import Deferred = require("dojo/Deferred");
class Navigation {
private _directions: google.maps.DirectionsResult;
private _ready: Deferred<Navigation>;
constructor(args: {
start?: any;
end?: any;
@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 {
@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 / 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 / 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 / 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 / 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;
}