Skip to content

Instantly share code, notes, and snippets.

@diverted247
diverted247 / gulpfile.js
Created May 1, 2014 18:15
A Gulp + TypeScript + Component Build script
var gulp = require( 'gulp' ),
component = require( 'gulp-component' ),
tsc = require( 'gulp-typescript-compiler' );
gulp.task( 'default' , [ 'ts' ] , function (){
gulp.src( 'component.json' )
.pipe( component( {
standalone: true
} ) )
.pipe( gulp.dest( 'build' ) )
@eiximenis
eiximenis / 01_1Scope.js
Created November 27, 2014 10:04
Ejemplos de la charla Una tapa de EcmaScript. PPT http://www.slideshare.net/eduardtomas/una-tapa-de-ecmascript-6
(function() {
const a=10;
a=20;
let b=10;
b=20;
console.log("a-->" + a);
console.log("b-->" + b);
var s = true;
while (s) {
const ic = 10;
@michelsalib
michelsalib / timestampable.ts
Created April 22, 2015 15:52
Typescript @timestampable annotation
@timestampable
class Dog {
public name: string = 'Paul';
}
function timestampable(func) {
return <any>(function() {
var genericConstructor = () => {};
genericConstructor.prototype = func.prototype;
var instance = new genericConstructor();
@daoshengmu
daoshengmu / webgl-tpe-02-simpleWebVR03.html
Last active September 3, 2015 16:34
WebGL Taipei meetup #03: WebVR Oculus / Cardboard controls
<!DOCTYPE html>
<!--
WebGL Taipei meetup #02
author: daoshengmu, http://dsmu.me
date: 06/06/2015
-->
<html lang="en">
<head>
function Markdown(value) {
this.value = value || '';
this.length = this.value.length;
};
Markdown.prototype = new String;
// Instance methods
Markdown.prototype.toString = Markdown.prototype.valueOf = function(){return this.value};
Markdown.prototype.toHTML = function(){return Markdown.decode(this)};
/*
* Minimal classList shim
* Use with an Array.prototype.indexOf shim to support IE 8
* Derived from work by Devon Govett
* MIT LICENSE
*/
// NOT INTENDED FOR PRODUCTION USE.
@assertchris
assertchris / t.js
Created September 28, 2012 13:19 — forked from wayneashleyberry/t.js
simple templating
/**
* simple mustache-like templater
* http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/
* -----------------------------------------------------------------------------------------
* t('Hello, {{planet}}!', {'planet': 'World'});
* returns 'Hello, World!';
*/
function t(s,d){
for(var p in d)
s=s.replace(new RegExp('{{'+p+'}}','g'), d[p]);
if("undefined" === typeof document.currentScript){
(function(){
/***************************************************************************/
/* document.currentScript polyfill + improvements */
/***************************************************************************/
var scripts = document.getElementsByTagName('script');
document._currentScript = document.currentScript;
// return script object based off of src
var getScriptFromURL = function(url) {
@Ciantic
Ciantic / MyElement.ts
Last active January 28, 2016 18:25
CustomElement inheritance in TypeScript (before it's fixed)
import customelement = require('./customelement');
export class MyElement extends customelement.CustomHTMLElement {
public myTest() {
// "this" is fully qualified, includes all methods e.g. addEventListener, dispatchEvent
console.log("this", this);
console.dir(this);
}
}
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});