Skip to content

Instantly share code, notes, and snippets.

View hongbo-miao's full-sized avatar
❣️

Hongbo Miao hongbo-miao

❣️
View GitHub Profile

How to run nightly version of @ngrx/store along with new @ngrx/effects

Add new packages to your dependencies

Effects and store v2 are not on npm yet, so download them from my github.

"@ngrx/core": "1.0.0",
"@ngrx/store": "fxck/store#v2-test",
"@ngrx/effects": "fxck/effects",
@leebyron
leebyron / maybeFilter.js
Last active June 29, 2016 08:34
An array filter function which does not create a new array if no items are removed.
function maybeFilter(array, predicate) {
var newArray;
array.forEach((item, i) => {
if (predicate(item)) {
if (newArray) {
newArray.push(item)
}
} else if (!newArray) {
newArray = array.slice(0, i)
}
@toddmotto
toddmotto / *.js
Created September 19, 2016 19:41
Angular function arguments
(function(A,n,g,u,l,a,r){A.GoogleAnalyticsObject=r;A[l]=A[l]||function(){
(A[l].q=A[l].q||[]).push(arguments)},A[l].l=1*new Date();a=n.createElement(g),
r=n.getElementsByTagName(g)[0];a.async=1;a.src=u;r.parentNode.insertBefore(a,r)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-XX', 'auto');
ga('send', 'pageview');
/*
* Be sure to drink your Ovaltine
*
* If you are a JavaScript nerd supreme:
*/
/*
* ...should all output "true"
*
* bonus for avoiding for loops

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
expect(fn).toThrow(e);
expect(instance).toBe(instance);
expect(mixed).toBeDefined();
expect(mixed).toBeFalsy();
expect(number).toBeGreaterThan(number);
expect(number).toBeLessThan(number);
expect(mixed).toBeNull();
expect(mixed).toBeTruthy();
expect(mixed).toBeUndefined();
expect(array).toContain(member);
@devCrossNet
devCrossNet / app.component.html
Last active October 10, 2016 16:09
Content-Outlet for Angular 2 Applications. Change multiple components with the help of routing
./src/app/app.component.html
<md-sidenav-layout>
<md-toolbar color="primary">
<span>
Brand
</span>
<app-content-outlet [id]="'topnav'"></app-content-outlet>
<button md-icon-button (click)="sidenav.toggle()">
<md-icon>menu</md-icon>
@jhades
jhades / 01.ts
Last active October 25, 2016 20:08
Angular Universal
import * as gulp from 'gulp';
import {gulpPrerender} from '@angular/universal';
import {App} from './app';
gulp.task("prerender", () => {
return gulp.src(['index.html'])
.pipe(gulpPrerender({
directives: [App]
}));
});
@cusspvz
cusspvz / index.js
Created November 14, 2016 15:09
require-by-kind
const PREFIX = 'synaptic'
const NpmRegExp = /^@?[a-z0-9\-]*([a-z0-9\-])?$/
export default function requireByKind ( kind, given ) {
// Avoid access to specific files by restricting the `given`
if ( given.match( NpmRegExp ) ) {
throw new Error( `only alphanumeric names are valid` )
}
@arunoda
arunoda / notes.md
Created October 14, 2015 19:48 — forked from widged/notes.md
GraphQL links. Articles to read and code to check.