Skip to content

Instantly share code, notes, and snippets.

View tkssharma's full-sized avatar
🎯
only JS

codewithtkssharma tkssharma

🎯
only JS
View GitHub Profile
# 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
# 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
interface MyCustomTypeA {
test: string;
}
interface MyCustomTypeB {
anything: boolean;
}
interface ReusableInterface3<T> {
entity: T;
interface Book {
type: "book";
isbn: string;
page: number;
}
interface Movie {
type: "movie";
lengthMinutes: number;
}
let hobby: Movie = { type: "movie", lengthMinutes: 120 };
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
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
}
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) {
function switchFunction(num: number) {
let b: string = "functionb";
switch (num) {
case 1: {
let b: string = "case 1";
break;
} // After break
case 2:
{
function switchFunction(num: number) {
let b: string = "functionb";
switch (num) {
case 1: {
let b: string = "case 1";
break;
} // After break
case 2:
{
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));