Skip to content

Instantly share code, notes, and snippets.

View wizardnet972's full-sized avatar
:octocat:
Angularing...

Shlomi Levi wizardnet972

:octocat:
Angularing...
View GitHub Profile
var score_poker_hand = (function () {
// This program creates and uses two enumeration objects:
// rank_value and score_prefix.
// The score_poker_hand function takes a hand (an array of cards). The hand
// can contain between 5 and 9 cards, within which it will find the best five
// card poker hand. A hand is an array of objects containing rank and suit
// properties. The order of the cards is not significant. The hand is not
// modified.
@wizardnet972
wizardnet972 / gist:36c5d412295b0b791e9f757e3fd5ab0d
Created January 9, 2017 16:07
JavaScript, Inheritance: John Resig Simple Inheritance
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;

@ngrx/store v3

Problems:

  • Users want to compose reducer tree across modules
  • Idea of a single reducer function makes it difficult for the library to dynamically augment the shape of the state tree
  • Turning control over to the library to build the root reducer limits the use of meta-reducers
  • Feature modules may inadvertently collide with the state of the root module
  • Library authors may want to leverage @ngrx/store in their projects and provide an easy way
@wizardnet972
wizardnet972 / *.md
Created March 5, 2017 06:17
Component versus Directive in AngularJS

Component versus Directive in AngularJS

.component()

Components are not "helper" methods, they are the best change in Angular 1.x since I've been using it.

What is the role of .component()?

  • Declares new HTML via a template or templateUrl
  • Should be used to create Components as part of a Component architecture
This file has been truncated, but you can view the full file.
{
"status": "ok",
"results_time": "12.0041 sec.",
"results_count": 701,
"results": [
{
"key": "baby clothes",
"cmp": 0.9990850304818497,
"cpc": 1.188172,
"sv": 110000,
router.all('/incaseoferror', async(req, res, next) => {
const promise = await new Promise(function (resolve, reject) {
setTimeout(function () {
reject(new Error('this is a test err'));
}, 3000);
});
require('zone.js/dist/zone-node');
Zone.current.fork({
onHandleError:
(parentZoneDelegate, currentZone, targetZone,
error) => {
console.log('should be error here', error);
// return parentZoneDelegate.handleError(targetZone, error);
}
helper.ts:
export const HelperMethod = () => {
return {};
};
app.ts:
import { HelperMethod } from './helper';
default-image.directive.ts:
import { Directive, Input, HostListener, ElementRef } from '@angular/core';
@Directive({
selector: 'img[default]',
})
export class DefaultImageDirective {
@Input() default: string;
sudo apt-get update
sudo apt-get install libssl-dev g++ make
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
. ~/.nvm/nvm.sh
nvm install node