Skip to content

Instantly share code, notes, and snippets.

@sliceofbytes
sliceofbytes / 0_reuse_code.js
Created April 4, 2016 04:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sliceofbytes
sliceofbytes / group-effects.ts
Created April 19, 2018 21:15
Is this stupid?
import { Action } from '@ngrx/store';
import { Effect, Actions } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import * as group from '../actions/group';
import { CourseService, Group, TreeItem } from '../../shared';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/startWith';
@sliceofbytes
sliceofbytes / course-events.ts
Created April 20, 2018 15:12
Course events
import { Action } from '@ngrx/store';
import { Effect, Actions } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import * as course from '../actions/course';
import { CourseService, Course } from '../../shared';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/startWith';
@sliceofbytes
sliceofbytes / course-events.ts
Created April 20, 2018 15:12
Course events
import { Action } from '@ngrx/store';
import { Effect, Actions } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import * as course from '../actions/course';
import { CourseService, Course } from '../../shared';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/startWith';
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
if (someCondition) {
this.router.navigate(['not-allowed']);
return false;
}
return true;
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('d3'), require('d3-selection-multi')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'd3', 'd3-selection-multi'], factory) :
(factory((global.KnobModule = {}),global.core,global.d3));
}(this, (function (exports,core,d3) { 'use strict';
var Ng2KnobDirective = /** @class */ (function () {
function Ng2KnobDirective(el) {
this.el = el;
this.valueChange = new core.EventEmitter();
import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';
if (environment.production) {
enableProdMode();
}
@sliceofbytes
sliceofbytes / weird-right-join.sql
Created May 21, 2018 18:59
SQL Syntax I haven't seen before
SELECT *
FROM BaseTable b
RIGHT JOIN (
SomeTable s
INNER JOIN OtherTable o ON o.ID = s.ID
INNER JOIN MoreTable m ON m.ID = f.ID
) ON b.ID = s.ID
@sliceofbytes
sliceofbytes / style-desaturate.css
Created July 18, 2018 14:08 — forked from internoma/style-desaturate.css
Desaturate & saturate css3
.desaturate {
filter: grayscale(100%); /* Current draft standard */
-webkit-filter: grayscale(100%); /* New WebKit */
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%); /* Not yet supported in Gecko, Opera or IE */
filter: url(resources.svg#desaturate); /* Gecko */
filter: gray; /* IE */
-webkit-filter: grayscale(1); /* Old WebKit */
}
@sliceofbytes
sliceofbytes / coolarray.js
Created August 30, 2018 19:04
Cool way to populate array.
[...Array(31).keys()] === [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]