This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exec = require('child_process').exec; | |
exec("open https://facebook.com"); | |
exec('ls', function(err, stdout){ | |
if(err) | |
console.log(err) | |
console.log("Listing finished..") | |
console.log(stdout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Basic events functionality | |
// const EventEmitter = require('events'); | |
// const emitter = new EventEmitter(); | |
// emitter.on('messageLogged', function(args){ | |
// console.log(`${args.name} : ${args.age}`) | |
// console.log("Listener called"); | |
// }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline'); | |
const rl = readline.createInterface(process.stdin, process.stdout); | |
const realPerson = { | |
name: "", | |
sayings: [] | |
}; | |
rl.question("Who is real person? ", function(answer){ | |
realPerson.name = answer; | |
rl.setPrompt(`What would ${realPerson.name} say? `); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var readline = require('readline'); | |
var waitTime = 3000; | |
var currentTime = 0; | |
var waitInterval = 500; | |
var percentageWaited = 0; | |
function writeWaitingPercentage(p){ | |
readline.clearLine(process.stdout); | |
readline.cursorTo(process.stdout, 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const questions = [ | |
"What is your name?", | |
"What is fav hobby?", | |
"What is your fav programming language?" | |
]; | |
const answers = []; | |
function ask(i){ | |
process.stdout.write(`\n\n ${questions[i]} \n\n`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require("mongoose"); | |
mongoose.connect("mongodb://localhost/playground", { useNewUrlParser: true }) | |
.then(() => console.log("Mongo db is connected!")) | |
.catch((err) => console.error("Could not connect to db ...", err)); | |
const courseSchema = new mongoose.Schema({ | |
name: { type: String, required: true }, | |
author: { type: String, required: true, minlength: 3, maxlength: 255 }, | |
category: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: "excerpt" | |
}) | |
export class ExcerptPipe implements PipeTransform{ | |
transform(text: string, limit?: number){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const MongoClient = require('mongodb').MongoClient; | |
const bcrypt = require('bcrypt'); | |
const users = require('./users'); | |
function seedCollection(collectionName, initialRecords){ | |
MongoClient.connect(process.env.DB_CONN, (err, db) => { | |
console.log("connected to mongo db"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, ElementRef, Renderer } from '@angular/core'; | |
@Directive({ | |
selector: '[autoGrow]', | |
host: { | |
'(focus)' : 'onFocus()', | |
'(blur)' : 'onBlur()' | |
} | |
}) | |
export class AutoGrowDirective { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, HostBinding, HostListener } from '@angular/core'; | |
@Directive({ | |
selector: '[rbDropdown]' | |
}) | |
export class DropdownDirective { | |
private isOpen = false; | |
@HostBinding('class.open') get opened(){ | |
return this.isOpen; |