mkdir <project name>
cd <project name>
npm init -y
npm i -g typescript //install TS globally on your computer
// install express and dotenv globally
npm install express dotenv
//install type packages for express and node
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
| /* | |
| * Copyright 2004, 2005, 2006 Acegi Technology Pty Limited | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * https://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
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
| # | |
| # A fatal error has been detected by the Java Runtime Environment: | |
| # | |
| # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff9ce8e51f3, pid=30080, tid=20684 | |
| # | |
| # JRE version: Java(TM) SE Runtime Environment (17.0.4.1+1) (build 17.0.4.1+1-LTS-2) | |
| # Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0.4.1+1-LTS-2, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) | |
| # Problematic frame: | |
| # V [jvm.dll+0x7a51f3] | |
| # |
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
| server.port=8010 | |
| spring.application.name=discoveryservice | |
| eureka.client.register-with-eureka=false | |
| eureka.client.fetch-registry=false | |
| eureka.client.serviceUrl.defaultZone=http://localhost:8010/eureka | |
| eureka.instance.ip-address=true |
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
| Time Planner | |
| Implement a function meetingPlanner that given the availability, slotsA and slotsB, of two people and a meeting duration dur, returns the earliest time slot that works for both of them and is of duration dur. If there is no common time slot that satisfies the duration requirement, return an empty array. | |
| Time is given in a Unix format called Epoch, which is a nonnegative integer holding the number of seconds that have elapsed since 00:00:00 UTC, Thursday, 1 January 1970. | |
| Each person’s availability is represented by an array of pairs. Each pair is an epoch array of size two. The first epoch in a pair represents the start time of a slot. The second epoch is the end time of that slot. The input variable dur is a positive integer that represents the duration of a meeting in seconds. The output is also a pair represented by an epoch array of size two. | |
| In your implementation assume that the time slots in a person’s availability are disjointed, i.e, time slots in a person’s availability don’t overlap. Fu |
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
| /** | |
| Coding Step | |
| 1. Repeat the question in your own words | |
| 2. Do you know the input and output / How do you want to represent your data | |
| 3. Ask clarifying questions | |
| 4. What edge cases have you thought about | |
| 5. What is your approach (the first solution that comes to mind) ⇒ Write out the pseudocode & time & space complexity | |
| 6. What is your second approach, **if available** ⇒ Write out the pseudocode & time & space complexity | |
| 1. can you come up with something more efficient? | |
| 2. can you come up with a different way of solving the problem (doesn't have to be more efficient)? |
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
| //copy all values from source to destination | |
| let dest = JSON.parse(JSON.stringify(source)); |
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
| for (int i = 1; i < size; i++){ | |
| List<Integer> subArray = new ArrayList<>(); | |
| for(int j = 0; j < array.length; j++){ | |
| if (BigInteger.valueOf(i).testBit(j)){ | |
| subArray.add(Integer.parseInt(array[j])); | |
| } | |
| } | |
| System.out.println(subArray); | |
| } |
A quick guide on how to setup Node.js development environment.
nvm allows installing several versions of Node.js to the same system. Sometimes applications require a certain versions of Node.js to work. Having the flexibility of using specific versions can help.
- Open new Terminal window.
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 fs = require("fs"); | |
| //write to file sychronously | |
| const dataToWrite = "Hello there by injection"; | |
| fs.writeFileSync(`${__dirname}/data.txt`, dataToWrite, "utf-8"); | |
| //write to file asynchronously | |
| const dataToWriteAsync = "Hello there by injection async"; | |
| fs.writeFile(`${__dirname}/data.txt`, dataToWriteAsync, "utf-8", (err) => { | |
| if (!err) console.log("Done!"); |
NewerOlder