Skip to content

Instantly share code, notes, and snippets.

View CDRussell's full-sized avatar

Craig Russell CDRussell

View GitHub Profile

Alias to show open PRs, allow one to be selected, checked out and see PR status checks

Only PRs assigned to me

gh alias set co --shell 'id="$(gh pr list -L100 --assignee @me| fzf | cut -f1)"; [ -n "$id" ] && gh pr checkout "$id" && gh pr checks'

All PRs

gh alias set coall --shell 'id="$(gh pr list -L100 | fzf | cut -f1)"; [ -n "$id" ] && gh pr checkout "$id" && gh pr checks'
@CDRussell
CDRussell / .zshrc
Last active December 22, 2021 11:28
# Git branch in command prompts
autoload -Uz vcs_info
precmd() {vcs_info}
setopt PROMPT_SUBST
# the last part of this command dictates what is shown for git info, referenced later by the prompt command.
# here, showing branch name %b in color 38 (blue) and the repo name %r in color 226 (yellow)
zstyle ':vcs_info:git:*' formats '%F{38}%b%f %F{226}(%r)%f'
# can set both the left (PROMPT) and right (RPROMPT) prompts
suspend fun delete(tab: TabEntity) {
withContext(Dispatchers.IO + NonCancellable) {
deleteTabImagePreview(tab)
tabsDao.deleteTab(tab)
}
}
class TabSwitcherActivity : CoroutineScope by MainScope() {
fun onTabDeleted(tab: TabEntity) {
launch { viewModel.onTabDeleted(tab) }
}
}
@CDRussell
CDRussell / New Activity.kt
Created February 10, 2020 23:02
New setup of Activity and ViewModel
class TabSwitcherActivity : Activity(), CoroutineScope by MainScope() {
override fun onNewTabRequested() {
viewModel.onNewTabRequested()
}
}
@CDRussell
CDRussell / Previous Activity.kt
Last active February 10, 2020 23:07
Previous setup of Activity and ViewModel
class TabSwitcherActivity : Activity(), CoroutineScope by MainScope() {
override fun onNewTabRequested() {
launch { viewModel.onNewTabRequested() }
}
}

Keybase proof

I hereby claim:

  • I am cdrussell on github.
  • I am craigrussell (https://keybase.io/craigrussell) on keybase.
  • I have a public key ASAwzwBl24APkvnhgiGw_6n8QyqucsBJWVxmHIi6qoP0JAo

To claim this, I am signing this object:

class ExampleViewModel(private val logger: Logger) : ViewModel() {
fun handleError() {
viewModelScope.launch(Dispatchers.IO) {
heavyOperation()
logger.logErrorEvent()
}
}
}
class ExampleViewModel(private val logger: Logger) : ViewModel() {
@VisibleForTesting
var job: Job? = null
fun handleError() {
job = viewModelScope.launch(Dispatchers.IO) {
heavyOperation()
logger.logErrorEvent()
}
class ErrorHandler(private val logger: Logger) {
fun handleError() {
GlobalScope.launch(Dispatchers.IO) {
heavyOperation()
logger.logErrorEvent()
}
}