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
| fun main() { | |
| user { | |
| name = "Teyyihan" | |
| age = 22 | |
| tweet { | |
| title = "Hi" | |
| body = "body" | |
| timestamp = 1231231L | |
| } |
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
| ARG JAR_FILE=foo/bar.jar | |
| COPY ${JAR_FILE} |
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
| func main() { | |
| d := make(map[int]int) | |
| t0 := time.Now() | |
| fmt.Println(fib(40)) | |
| t1 := time.Now() | |
| fmt.Println(memoFib(40,d)) | |
| t2 := time.Now() | |
| fmt.Println("It took ",t1.Sub(t0).Nanoseconds()," nanoseconds to calculate without memoization") | |
| fmt.Println("It took ",t2.Sub(t1).Nanoseconds()," nanoseconds to calculate with memoization") | |
| } |
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
| func memoFib(num int, d map[int]int) int { | |
| if num <= 1 {return 0} | |
| if num == 2 {return 1} | |
| if val, ok := d[num]; ok { | |
| return val | |
| } | |
| d[num] = memoFib(num-1,d)+memoFib(num-2,d) | |
| return d[num] | |
| } |
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
| func fib(num int) int { | |
| if num <= 1 {return 0} | |
| if num == 2 {return 1} | |
| return fib(num-1) + fib(num-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
| suspend fun <T> Task<T>.awaitTask(): T? = suspendCoroutine { continuation -> | |
| this.addOnCompleteListener { task -> | |
| if (task.isSuccessful) { | |
| continuation.resume(task.result) | |
| } else { | |
| continuation.resumeWithException(task.exception!!) | |
| } | |
| } | |
| } |
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
| Dao{ | |
| @Query("SELECT * FROM users WHERE label LIKE :query") | |
| fun pagingSource(query: String): PagingSource<Int, User> | |
| } | |
| ViewModel{ | |
| Pager( | |
| config = PagingConfig( | |
| pageSize = NETWORK_PAGE_SIZE, | |
| ), |
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
| Users.watch().on('change',(change)=>{ | |
| console.log('Something has changed') | |
| io.to(change.fullDocument._id).emit('changes',change.fullDocument) | |
| }) |
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
| mongoose.connect('mongodb://localhost:27017/realtimeProject',{useNewUrlParser:true}, | |
| function(err){ | |
| if(err){ | |
| throw err | |
| } | |
| console.log('Database connected') | |
| io.on('connection',(socket)=>{ | |
| console.log('user connected') | |
| socket.on('joinRoom',(data)=>{ // data will look like => {myID: "123123"} |
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
| mongoose.connect('mongodb://localhost:27017/realtimeProject',{useNewUrlParser:true}, | |
| function(err){ | |
| if(err){ | |
| throw err | |
| } | |
| console.log('Database connected') | |
| }) |
NewerOlder