Skip to content

Instantly share code, notes, and snippets.

public myForm: FormGroup
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.myForm = this.formBuilder.group({
enabledControl: ['hello'],
disabledControl: [{
value: 'world',
disabled: true
@ackuser
ackuser / setting-up-babel-nodemon.md
Created September 11, 2018 09:19 — forked from sam-artuso/setting-up-babel-nodemon.md
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@ackuser
ackuser / font-awesome-4.7.0.json
Created September 20, 2018 16:09 — forked from zwinnie/font-awesome-4.7.0.json
JSON Of All Font Awesome 4.7.0 Icons
{
"4.7.0": [
"fa-500px",
"fa-address-book",
"fa-address-book-o",
"fa-address-card",
"fa-address-card-o",
"fa-adjust",
"fa-adn",
"fa-align-center",
@ackuser
ackuser / es7AsyncAwaitParallel.js
Created September 27, 2018 10:29 — forked from johntran/es7AsyncAwaitParallel.js
ES7 multiple async/await functions in parallel execution.
//old: productReviews.js - lines 121 - 125
async function productReviewsByProductAllGet(request, response) {
try {
const { productId } = request.params;
// get all reviews for a product id
const reviews = await productReviewsQuery.selectAllByProductId(productId);
const result = [];
// Loop from beginning of reviews array to reviews
for(let i = 0; i < reviews.length; i++) {
@ackuser
ackuser / async-foreach.js
Last active October 1, 2018 11:42 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@ackuser
ackuser / random_color_array.js
Created November 15, 2018 12:26 — forked from mucar/random_color_array.js
Javascript Random Color Array
var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6',
'#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D',
'#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A',
'#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC',
'#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC',
'#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399',
'#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680',
'#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933',
'#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3',
'#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF'];
@ackuser
ackuser / terminal-git-branch-name.md
Created December 11, 2018 16:18 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@ackuser
ackuser / aggregate.js
Created December 21, 2018 13:12
Aggregate data from MongoDB with Node.js and mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//Database connection
var uristring = 'mongodb://localhost/test';
var mongoOptions = { };
mongoose.connect(uristring, mongoOptions, function (err, res) {
if (err) {
console.log('Error when connecting to: ' + uristring + '. ' + err);
@ackuser
ackuser / Enum.es6.js
Created December 31, 2018 18:56 — forked from stefanwalther/Enum.es6.js
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
import { Injectable } from '@angular/core';
@Injectable()
export class CookieService {
constructor() {
}
set(key: string, value: string): void;
set(key: string, value: string, expires: Date): void;