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
# Run `docker-compose build` to build the images | |
# Run `docker-compose up` to run the containers | |
# Run `docker-compose down` to remove the containers | |
version: '3.5' | |
services: | |
mysql: | |
container_name: service_mysql | |
image: mysql:5.7 | |
volumes: | |
- ~/datadir/mysql:/var/lib/mysql |
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
# Run `docker-compose build` to build the images | |
# Run `docker-compose up` to run the containers | |
# Run `docker-compose down` to remove the containers | |
version: '3.5' | |
services: | |
mysql: | |
container_name: service_mysql | |
image: mysql:5.7 | |
volumes: | |
- ~/datadir/mysql:/var/lib/mysql |
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
interface MyCustomTypeA { | |
test: string; | |
} | |
interface MyCustomTypeB { | |
anything: boolean; | |
} | |
interface ReusableInterface3<T> { | |
entity: T; |
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
interface Book { | |
type: "book"; | |
isbn: string; | |
page: number; | |
} | |
interface Movie { | |
type: "movie"; | |
lengthMinutes: number; | |
} | |
let hobby: Movie = { type: "movie", lengthMinutes: 120 }; |
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
enum Weather { | |
Sunny, | |
Cloudy, | |
Rainy, | |
Snowy | |
} | |
let today: Weather = Weather.Cloudy; | |
let tomorrow: Weather = 200; | |
console.log("Today value", today); // Today value Cloud | |
console.log("Today key", Weather[today]); // Today key undefined |
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
function returnNever(i: number): never { | |
// Logic here | |
if (i === 0) { | |
throw Error("i is zero"); | |
} else { | |
throw Error("i is not zero"); | |
} | |
// Will never reach the end of the function | |
} |
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 arr: number[] = [1, 2, 3]; | |
arr.push(4); | |
const myObj: { x: number } = { x: 1 }; | |
myObj.x = 2; | |
let n2: string | undefined = Math.random() > 0.5 ? undefined : "test"; | |
// console.log(n2.substring(0, 1)); // Won't compile since can be null | |
if (n2 !== null) { |
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
function switchFunction(num: number) { | |
let b: string = "functionb"; | |
switch (num) { | |
case 1: { | |
let b: string = "case 1"; | |
break; | |
} // After break | |
case 2: | |
{ |
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
function switchFunction(num: number) { | |
let b: string = "functionb"; | |
switch (num) { | |
case 1: { | |
let b: string = "case 1"; | |
break; | |
} // After break | |
case 2: | |
{ |
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 request = require("request"); | |
var userDetails; | |
function initialize() { | |
return new Promise(function(resolve, reject) { | |
// Do async job | |
request.get("https://api.github.com/users/tkssharma", function(err,resp,body) { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(JSON.parse(body)); |