Skip to content

Instantly share code, notes, and snippets.

View mattmazzola's full-sized avatar

Matt Mazzola mattmazzola

View GitHub Profile
@mattmazzola
mattmazzola / customEnableCorsAttribute
Created April 2, 2014 17:55
WebAPI CORS Regex support for origin.
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public class SubdomainWildcard : Attribute, ICorsPolicyProvider
{
private static List<string> AcceptableDomainPatterns = new List<string>()
{
@"mattmazzola([-\w]+)\.sharepoint\.com"
};
public async Task<CorsPolicy> GetCorsPolicyAsync(HttpRequestMessage request, CancellationToken token)
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@mattmazzola
mattmazzola / classless.md
Last active August 29, 2015 14:08 — forked from mpj/classless.md

The future is here: Classless object-oriented programming in JavaScript.

Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.

Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.

I think it's really, really sleek, and this is what it looks like:

function dog(spec) {
@mattmazzola
mattmazzola / deparam.js
Created November 4, 2014 21:33
deparam
(function(global){
global.deparam = function( params, coerce ) {
var obj = {},
coerce_types = { 'true': !0, 'false': !1, 'null': null };
// Iterate over all name=value pairs.
//$.each( params.replace( /\+/g, ' ' ).split( '&' ), function(j,v){
params.replace( /\+/g, ' ' ).split( '&' ).forEach(function(v, j){
var param = v.split( '=' ),
key = decodeURIComponent( param[0] ),
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function insertNumberAtEachIndex(a, xs) {
@mattmazzola
mattmazzola / gist:174d7e71aae090058e63
Created April 29, 2015 01:01
Sequential Promises (No Generators)
let log = (x) => {
console.log(x);
return x;
};
let delayedPromise = (value, delay) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(value);
@mattmazzola
mattmazzola / gist:abae3e7ed16309b5cea0
Created June 27, 2015 17:43
Questions about 'metaprogramming-in-es6-symbols' article

On the section about Symbols not being truly private:

assert.deepEqual(Object.getOwnPropertySymbols(x), [Symbol(size)]); I was expecting: assert.deepEqual(Object.getOwnPropertySymbols(x), [size]);

Is it required to call Symbol(size) to have proper comparison even though size is already an instace of Symbol?

On the section about Symbol.match:

@mattmazzola
mattmazzola / index.html
Last active August 31, 2015 06:01 — forked from mbostock/.block
Zoomable Area
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
svg {
font: 10px sans-serif;
}
@mattmazzola
mattmazzola / _.md
Created September 1, 2015 06:03
mattmazzola
@mattmazzola
mattmazzola / _.md
Created September 1, 2015 06:14
mattmazzola