Magic words:
psql -U postgresIf run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).
Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*
| class FlattenArray | |
| def self.flattify(array,init=[]) | |
| array.each do |a| | |
| if a.class==Array | |
| flattify(a,init) | |
| else | |
| init << a | |
| end | |
| end | |
| init |
| # Sami’s spaceship crashed on Mars! She sends sequential SOS messages to Earth for help. | |
| # Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal | |
| # received by Earth as a string, S , determine how many letters of Sami’s SOS have been changed by radiation. | |
| # Input Format | |
| # There is one line of input: a single string, S . | |
| # Note: As the original message is just SOS repeated n times, S ’s length will be a multiple of 3 . | |
| # Constraints | |
| # 1 ≤ |S| ≤ 99 |
| # Julius Caesar protected his confidential information by encrypting it in a cipher. Caesar’s cipher rotated every letter | |
| # in a string by a fixed number, K , making it unreadable by his enemies. Given a string, S , and a number, K , | |
| # encrypt S and print the resulting string. | |
| # Note: The cipher only encrypts letters; symbols, such as − , remain unencrypted. | |
| # Input Format | |
| # The first line contains an integer, N , which is the length of the unencrypted string. | |
| # The second line contains the unencrypted string, S . | |
| # The third line contains the integer encryption key, K , which is the number of letters to rotate. | |
| # Constraints | |
| # 1 ≤ N ≤ 100 |
| import { Directive, HostBinding, HostListener } from '@angular/core'; | |
| @Directive({ | |
| selector: '[rbDropdown]' | |
| }) | |
| export class DropdownDirective { | |
| private isOpen = false; | |
| @HostBinding('class.open') get opened(){ | |
| return this.isOpen; |
| import { Directive, ElementRef, Renderer } from '@angular/core'; | |
| @Directive({ | |
| selector: '[autoGrow]', | |
| host: { | |
| '(focus)' : 'onFocus()', | |
| '(blur)' : 'onBlur()' | |
| } | |
| }) | |
| export class AutoGrowDirective { |
| 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"); |
| import { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({ | |
| name: "excerpt" | |
| }) | |
| export class ExcerptPipe implements PipeTransform{ | |
| transform(text: string, limit?: number){ |
| 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: { |
| 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`); |