Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, intial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
@dmorosinotto
dmorosinotto / NodeOnOSX.sh
Created October 17, 2015 08:36
Install Node.js and NPM on Mac OsX handling global package without sudo //script by johnpapa
brew install node --without-npm mkdir "${HOME}/.npm-packages" echo NPM_PACKAGES="${HOME}/.npm-packages" >> ${HOME}/.bashrc echo prefix=${HOME}/.npm-packages >> ${HOME}/.npmrc curl -L https://www.npmjs.org/install.sh | sh echo NODE_PATH=\"\$NPM_PACKAGES/lib/node_modules:\$NODE_PATH\" >> ${HOME}/.bashrc echo PATH=\"\$NPM_PACKAGES/bin:\$PATH\" >> ${HOME}/.bashrc echo source "~/.bashrc" >> ${HOME}/.bash_profile source ~/.bashrc
function getFile(file) {
return new Promise(
(resolve,reject) => {
if (Math.random()>0.3) fakeAjax(file,resolve);
else reject('SOMETHING GO WRONG WITH '+file);
}
);
}
function Async(gen){
@dmorosinotto
dmorosinotto / controllerASctrl.ts
Created April 20, 2016 15:22
Angular Form Validation with generic textbox directive
export class FormController {
static $inject = ["XeApiSvc", "MsgboxSvc"];
constructor(private api: Services.XeApiSvc, private msg: Services.MsgboxSvc) {
this.inInsert = false;
}
public data: Models.IRegistration;
public toggleInsert() {
@dmorosinotto
dmorosinotto / rollup.config.js
Created September 21, 2016 13:56
Roolup configuration for Typescript + CommonJS + production Uglify
// Rollup plugins to install as npm --save-dev
import typescript from "rollup-plugin-typescript";//used for typescript compilation
import resolve from "rollup-plugin-node-resolve"; //used for enabel NPM modules +
import commonjs from "rollup-plugin-commonjs"; //with probably use commonjs
import replace from "rollup-plugin-replace"; //used for replacing ENV varible in code
import uglify from "rollup-plugin-uglify"; //used for production minification
// import angular from "rollup-plugin-angular"; //used for Angular2 application see https://www.npmjs.com/package/rollup-plugin-angular
// Rollup configuration inspired by https://www.youtube.com/watch?v=ICYLOZuFMz8
export default {
entry: "path/to/main.ts", //entrypoint to traverse app
@dmorosinotto
dmorosinotto / ES6detect.js
Created February 1, 2017 10:22
Detect ES6 support
//ES6detect - inspired by https://github.com/bevacqua/sixflix - Algorithm by Netflix
var detection = 'class ಠ_ಠ extends Array{constructor(j=`a`,...c){const q=(({u: e})=>{return {[`${c}`]:Symbol(j)};})({});super(j,q,...c)}}new Promise(f=>{const a=function*(){return "\u{20BB7}".match(/./u)[0].length===2||!0};for (let z of a()){const [x,y,w,k]=[new Set(),new WeakSet(),new Map(), new WeakMap()];break}f(new Proxy({},{get:(h,i) =>i in h ?h[i]:"j".repeat(0o2)}))}).then(t => new ಠ_ಠ(t.d))'
var result
module.exports = function () {
if (result === void 0) {
try {
eval(detection)
result = true
@dmorosinotto
dmorosinotto / obj_implement.js
Created May 20, 2017 13:32
Possible implementation of Object.implement
//CODE by Andrea Giammarchi - READ MORE: http://webreflection.blogspot.it/2009/06/wait-moment-javascript-does-support.html
Object.implement = function(o, constructor){
// Another WebReflection Insane Snippet
if(o instanceof constructor)
// nothing to check
// classical boring stuff
return true;
// let's check if things are OK
var k, b = true,
// take the instance constructor prototype
//inspired by https://github.com/bevacqua/fuzzysearch/blob/master/index.js
'use strict';
function fuzzysearch (what, inside) {
var l = inside.length;
var n = what.length;
if (n > l) {
return false;
}
if (n === l) {
@dmorosinotto
dmorosinotto / abstract-value-accessor.ts
Created July 19, 2017 12:55
Abastract VALUE used to custom component for Forms (implementing ControlValueAccessor)
// Code inspired by http://www.anasfirdousi.com/share-controlvalueaccessor-provider-creation-with-abstract-controlvalueaccessor-across-custom-form-enabled-angular-components.html
import { Component, Directive, Provider, forwardRef, Type } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
export abstract class AbstractValueAccessor<T> implements ControlValueAccessor {
private _value: T = '';
public get value(): T { return this._value; };
public set value(v: T) {
if (v !== this._value) {
this._value = v;
@dmorosinotto
dmorosinotto / ngrxintro.md
Created July 21, 2017 12:57 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents