This file contains 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
{ "compilerOptions": { | |
/* Basic Options */ | |
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | |
// "lib": [], /* Specify library files to be included in the compilation. */ | |
// "allowJs": true, /* Allow javascript files to be compiled. */ | |
// "checkJs": true, /* Report errors in .js files. */ | |
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | |
// "declaration": true, /* Generates corresponding '.d.ts' file. */ | |
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ |
This file contains 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
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "ts-node src/config/server.ts", | |
"dev": "nodemon -x ts-node src/config/server.ts" | |
}, |
This file contains 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 express from 'express'; | |
const app = express() | |
const port : string|number= process.env.PORT || 5000; | |
app.use("*",(req, res) =>{res.send("<h1>Welcome to your server!</h1>")}) | |
//create a server object: | |
app.listen(port,() => console.log(`hosting @${port}`)); |
This file contains 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
git init . | |
git add . | |
git commit -m "init/heroku" |
This file contains 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
object Mailer { | |
@SuppressLint("CheckResult") | |
fun sendMail(email: String, subject: String, message: String): Completable { | |
return Completable.create { emitter -> | |
//configure SMTP server | |
val props: Properties = Properties().also { | |
it.put("mail.smtp.host", "smtp.gmail.com") | |
it.put("mail.smtp.socketFactory.port", "465") |
This file contains 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
//class | |
data class Person(val name:String,val age:Int) | |
//instantiate | |
val person = Person("ch8n", 25) | |
//access | |
val name = person.name | |
val age = person.age |
This file contains 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
//class | |
data class Person(val name:String,val age:Int) | |
//instantiate | |
val developer = Person("Ch8n", 25) | |
//access | |
val (name,age) = developer |
This file contains 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
//Data Class Destructuring | |
val person = Person(1, "Chetan", 25) | |
val(id, name, age) = person | |
//Collections Destructuring | |
//map | |
val map: HashMap<Int, Person> = HashMap() | |
map.put(1, person) |
This file contains 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
// Gotcha #1 | |
data class Items(val one: String, val two: String) | |
val items= Items("1","2") | |
val (one, two, three) = items //Destructuring declaration initializer of type Items must have a 'component3()' function |
This file contains 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
//example | |
data class Items(val one: String, val two: String) | |
val items= Items("1","2") | |
val (one, two) = items | |
//converts to | |
val one = items.component1 | |
val one = items.component2 |