Skip to content

Instantly share code, notes, and snippets.

View quentin41500's full-sized avatar

Quentin Colle quentin41500

View GitHub Profile
/**
* Execute [block] and operate [predicate] on returned value. Each retries can be separated by
* [delay] if necessary.
*
* @param count Number of tries before failing.
* @param delay Delay between retries
* @param block Code to execute
* @param predicate Predicate to execute.
*/
suspend fun <T> retryWithPredicate(
@quentin41500
quentin41500 / CartManager.kt
Last active June 8, 2021 12:28
Using Sealed class and LiveData to handle network request through the repository layer.
/**
* Observable manager for saving the [Cart]'s resource information.
*/
class CartManager : LiveData<Resource<Cart?>>() {
init {
value = Success(null)
}
/**
@quentin41500
quentin41500 / slack-pr.js
Last active June 9, 2025 17:49
Slack PR
javascript:!function (text) {
var node = document.createElement('textarea');
var selection = document.getSelection();
var prTitle = document.querySelectorAll('.js-issue-title')[0].textContent;
var repoName = document.querySelectorAll('.AppHeader-context-item-label')[1].textContent.trim();
repoName = repoName[0].toUpperCase() + repoName.slice(1);
var str = `:pr: ${repoName} | ${prTitle} \n${document.URL}`;
node.textContent = str;
document.body.appendChild(node);
selection.removeAllRanges();