Skip to content

Instantly share code, notes, and snippets.

//copied from https://github.com/jayphelps/core-decorators
const { defineProperty, getOwnPropertyDescriptor,
getOwnPropertyNames, getOwnPropertySymbols } = Object;
export function isDescriptor(desc) {
if (!desc || !desc.hasOwnProperty) {
return false;
}

angular/angular#11228 (comment)

@Component({
  ...
  providers: [MyService],
  template: '<router-outlet></router-outlet>'
})
export class MyNavWrapperComponent {
 // Must inject to instantiate service for all child routes.
# https://stackoverflow.com/a/45101030/1585068
docker rmi -f $(docker images -q)
@tytskyi
tytskyi / difference-object.js
Created July 12, 2017 22:37 — forked from sospedra/difference-object.js
Lodash objects difference
_.fromPairs(_.differenceBy(_.entries(original), _.entries(target), ([key, val]) => val))
/**
* Copyright (c) Matan Shukry
* All rights reserved.
*/
import { UrlSegment, UrlSegmentGroup, Route } from '@angular/router';
// export type UrlMatchResult = {
// consumed: UrlSegment[]; posParams?: { [name: string]: UrlSegment };
// };
@tytskyi
tytskyi / 2x-audio.js
Created September 7, 2016 10:18
Listen HTML5 audio book 2x faster.
var __$$play = HTMLAudioElement.prototype.play;
HTMLAudioElement.prototype.play = function () {
this.playbackRate = 2;
return __$$play.apply(this, arguments);
};
var gulp = require('gulp')
var concat = require('gulp-concat')
var sourcemaps = require('gulp-sourcemaps')
var uglify = require('gulp-uglify')
var ngAnnotate = require('gulp-ng-annotate')
gulp.task('js', function () {
gulp.src(['src/**/module.js', 'src/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
var createObject = (function () {
function Object() {}
return function createObjectF(obj) {
Object.prototype = obj;
obj = new Object();
Object.prototype = null;
return obj;
}
}());
// Easy way to parse raw URL without regex.
var locator = document.createElement('a');
locator.href = 'http://google.com/?search=true&other=isnt#anchor'
console.log(locator.protocol);
console.log(locator.host);
console.log(locator.search);
console.log(locator.hash);