Skip to content

Instantly share code, notes, and snippets.

View bcabanes's full-sized avatar

Benjamin Cabanes bcabanes

View GitHub Profile
@bcabanes
bcabanes / ssr.server.ts
Last active March 11, 2022 19:30
Angular SSR for Nx workspace
import 'zone.js/node';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
import { AppServerModule } from './main.server';
import { APP_BASE_HREF } from '@angular/common';
import { existsSync } from 'fs';
@bcabanes
bcabanes / main.ts
Created October 16, 2019 21:38
SSR NodeJs server
import 'zone.js/dist/zone-node';
import { enableProdMode } from '@angular/core';
// Express Engine
import { ngExpressEngine } from '@nguniversal/express-engine';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
import * as express from 'express';
import { join } from 'path';
// Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode();
@bcabanes
bcabanes / nx-ssr-schematic-main.ts__tmpl__
Created September 27, 2019 17:55
Nx schematic adding universal capabilities to an Nx application
import 'zone.js/dist/zone-node';
import { enableProdMode } from '@angular/core';
// Express Engine
import { ngExpressEngine } from '@nguniversal/express-engine';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
import * as express from 'express';
import { join } from 'path';
@bcabanes
bcabanes / nx-ssr-schematic-schema.json
Created September 27, 2019 17:54
Nx schematic adding universal capabilities to an Nx application
{
"$schema": "http://json-schema.org/schema",
"id": "universal-app",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Application name to add SSR feature"
}
},
@bcabanes
bcabanes / nx-ssr-schematic-index.ts
Last active October 16, 2019 21:34
Nx schematic adding universal capabilities to an Nx application
import {
apply,
chain,
externalSchematic,
mergeWith,
move,
Rule,
template,
Tree,
url
@bcabanes
bcabanes / interview.md
Created May 7, 2019 22:12
Interview questions Angular

Frontend interview questions

First, you should ask for his/her Github username and check public repositories.

Note: Keep in mind that many of these questions are open-ended and could lead to interesting discussions that tell you more about the person's capabilities than a straight answer would.

General

  • What Javascript Frameworks do you know? Which one do you like? Why?
  • What is the atomic design?

Coined by Brad Frost, Atomic Design is a methodology that involves breaking a website layout down into its basic components, which are then reused throughout the site. You have Atoms => Molecules => Organisms => Templates => Pages.

  • Can you name two programming paradigms important for JavaScript app developers?
@bcabanes
bcabanes / counter.component.spec.ts
Last active May 15, 2018 22:25
Angular component testing - isolated, shallow, integrated
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { Router } from '@angular/router';
// app
import { CounterComponent } from './counter.component';
import { MenuComponent } from './menu.component';
/**
@bcabanes
bcabanes / cordovaListFileEntries.js
Created December 10, 2015 16:07
Cordova/PhoneGap: List all files entries in directories provided.
/**
* Starter vars.
*/
var index = 0;
var i;
/**
* Need cordova.file plugin.
* $ cordova plugin add org.apache.cordova.file
*
@bcabanes
bcabanes / angular-sticky-container.js
Last active September 26, 2015 23:13
Angular sticky container
/**
* Angular sticky directive
* The directive is used by attribute [sticky].
*/
(function (angular) {
'use strict';
angular
.module('sticky', [])
.directive('sticky', directive);
@bcabanes
bcabanes / eatClickIf.directive.js
Last active August 29, 2015 14:23
Angular directive conditional click: eactClickIf
(function(angular) {
'use strict';
angular
.module('app')
.directive('eatClickIf', directive);
directive.$inject = [
'$parse',
'$rootScope'