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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DOM manipulation with jQuery</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript" src="jquery_example.js"></script> | |
</head> |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
first_name = "Nathan" | |
last_name = "Sass" | |
age = 24 |
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 Drawer | |
attr_reader :contents | |
# Are there any more methods needed in this class? | |
def initialize | |
@contents = [] | |
@open = true | |
end |
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
override fun getDocumentAndAudiobook(docId: Int): Single<AudioData.LoaderResult> { | |
val licenseRequest = audioApi.getLicense(docId).toObservable() | |
val documentRequest = documentLoaderObservable(docId) | |
val requests = mutableListOf(licenseRequest, documentRequest) | |
return Observable.zip(requests, | |
Function<Array<Any>, CombinedResult> { | |
return@Function resolve(it) | |
}) | |
.flatMap(Function<CombinedResult, Observable<Pair<ScribdDocument, FindawayApi.PlayListResponse>>> { | |
val playlistRequest = audioApi.getPlaylist( |
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
private suspend fun handleTypeAhead(dataSource: Flow<String>, onChange: (results: List<String>) -> Unit) { | |
// if a user is typing quickly wait for a pause before collecting most recent update. Ignore anything less then 3 characters. | |
val resultsFromUser = dataSource.debounce(500).filter { it.length > 3 } | |
// make an api call to get results for each user's query | |
// transformLatest will cancel an older api call if a newer arrives first | |
// this ensures a user will not see typeahead results for an out of date query | |
val apiCalls = resultsFromUser.transformLatest { | |
emit(getResultsAsync(it)) |
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 kotlinx.coroutines.delay | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.collect | |
import kotlinx.coroutines.flow.debounce | |
import kotlinx.coroutines.flow.filter | |
import kotlinx.coroutines.flow.flow | |
import kotlinx.coroutines.flow.transform | |
import kotlinx.coroutines.flow.transformLatest | |
import kotlinx.coroutines.runBlocking | |
import org.junit.Test |