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 / 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 / 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 / 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;
// 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:3b69ba5f1bd60affd9a5
Created May 8, 2015 13:52
deep-extend array merge when key values exist
function merge(key: string, ...arrays: Array<any>[]) {
// skip trivial arrays
arrays = arrays.filter(a => !!a && 0 < a.length);
var result = arrays.shift();
if (!arrays.length) return result;
var hash = {}; result.forEach((item, i) => hash[item.id] = i);
arrays.forEach(array => {
@ca0v
ca0v / alloyui-tests.ts
Last active October 14, 2015 01:18
liferay/yui/alloyui typescript definition
/*
create a class for every child namespace
create an typeof attribute to simulate an inner class.
*/
var YUI: Liferay.YUI;
var Y = YUI();
Y = YUI({
@ca0v
ca0v / layers_label.html
Created November 30, 2015 18:51
Modifies http://developers.arcgis.com/javascript/sandbox/sandbox.html?sample=layers_label to demonstrate that layers added after the label layer has been established appear above the labels.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<link rel="stylesheet" href="//js.arcgis.com/3.14/esri/css/esri.css">
<style>
html, body, #map {
height: 100%; width: 100%; margin: 0; padding: 0;
@ca0v
ca0v / fractal.ts
Created January 4, 2016 14:38
Fractal Generator
enum Move {
down = 0,
right = 1,
up = 2,
left = 3
}
class Fractal {
constructor(public points = [Move.down, Move.right, Move.up]) {
@ca0v
ca0v / decompress-geometry.ts
Last active January 4, 2016 18:38
Port of C# code published by ESRI
/*************************************************
* see http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esrinetworkanalyst/INACompactStreetDirection_CompressedGeometry.htm
*************************************************/
class DecompressGeometry {
public ExtractPointsFromCompressedGeometry(compresedGeometry: string)
{
// initialize result storage
let result = <Array<{x: number; y: number;}>>[],
nIndex = {ref: 0},
@ca0v
ca0v / ajax.ts
Created January 5, 2016 20:11
REST Proxy
/**
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
*/
class Ajax {
constructor (public url) {
}
// Method that performs the ajax request
private ajax(method, args?, url = this.url) {