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 express = require('express'); | |
const app = express(); | |
// cookie parser | |
// body parser | |
// cors | |
// if applicable | |
app.use('/api/user', userRoute(express.Router())) |
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
class Adapter(private var hospitalList: ArrayList<MapsHospital>, | |
private var listener: OnItemClickListener) | |
: RecyclerView.Adapter<MapsHospitalAdapter.ViewHolder>() { | |
interface OnItemClickListener { | |
fun onItemClick(hospital: MapsHospital) | |
} | |
override fun onBindViewHolder(holder: ViewHolder?, position: Int) { | |
holder?.bindView(hospitalList[position], listener) |
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
private fun httpRequestBuilder(url: String, request: Int): HttpsURLConnection { | |
val connection = URL(url).openConnection() as HttpsURLConnection | |
connection.readTimeout = 10000 | |
connection.connectTimeout = 15000 | |
connection.setRequestProperty("Authorization", "Bearer 234567834567") | |
when (request) { | |
GET -> { | |
connection.requestMethod = "GET" | |
connection.connect() | |
} |
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
// example with Google Maps | |
// https://developers.google.com/maps/documentation/distance-matrix/intro | |
// format : origins=place_id:ChIJ3S-JXmauEmsRUcIaWtf4MzE | |
companion object { | |
const val googleApiKey = "123" | |
const val distanceURL = "https://maps.googleapis.com/maps/api/distancematrix/json?" | |
} | |
doAsync { | |
val placeID = "123" | |
val location = Uri.encode("3.041803,101.793075") |
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
//creating promise | |
// more on https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-promise-27fc71e77261 | |
function exampleFunc(value) { | |
return new Promise((resolve, reject) => { | |
http.get(option, (res) => { | |
let body = ''; | |
res.on('data', (d) => { | |
body += d; | |
}); // store each response chunk | |
res.on('end', () => { |
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
let action = 'a' | |
const actionHandler = { | |
'a': () => {}, | |
'b': () => {} | |
}; | |
actionHandler[action](); |
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
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController, AVAudioPlayerDelegate{ | |
var audioPlayer: AVAudioPlayer! | |
@IBAction func notePressed(_ sender: UIButton) { | |
playSound("note\(sender.tag)") | |
} |