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
/** | |
* Starts collecting a flow when the lifecycle is started, and **cancels** the collection on stop. | |
* This is different from `lifecycleScope.launchWhenStarted { flow.collect{...} }`, in which case | |
* the coroutine is just suspended on stop. | |
*/ | |
inline fun <reified T> Flow<T>.collectWhileStarted( | |
lifecycleOwner: LifecycleOwner, | |
noinline action: suspend (T) -> Unit | |
) { | |
object : DefaultLifecycleObserver { |
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
/** | |
Create pagebreaks in exported Obsidian PDFs. | |
Example: | |
# Heading 1 | |
Lorem Ipsum is simply dummy text of the printing and typesetting industry. | |
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, | |
when an unknown printer took a galley of type and scrambled it to make a type |
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
#!/bin/bash | |
# ------------------------------------------------------------------------------------------------ | |
# Installs Ruby using rbenv/ruby-build - can be used multiple times, to install different versions | |
# | |
# Download and run locally: | |
# wget git.io/inst_ruby -O install_ruby.sh && chmod a+x install_ruby.sh | |
# ./install_ruby.sh 2.6.6 | |
# | |
# Run from the web: |
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
set myBibFile to "/Users/zhope/Dropbox/Sundry/Library.bib" | |
if myBibFile exists then | |
set currentBibs to do shell script "/usr/local/bin/pandoc-citeproc --bib2json " & quoted form of myBibFile & " | /usr/local/bin/jq -r ' .[] | \"\\(.id)\"'" | |
set currentBibs to paragraphs of currentBibs | |
end if | |
set bibFile to POSIX file myBibFile | |
my write_to_file("", bibFile, true) |
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
(* EXPORT SELECTED NOTES TO THE CLIPBOARD | |
(no longer) requires hackademic URL handler from github user smargh | |
entirely rewritten to take advantage of Skim's built-in templating | |
2019-03-10 by derickfay | |
*) | |
property LF : (ASCII character 10) |
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
(* EXPORT ALL SKIM NOTES TO THE CLIPBOARD | |
(no longer) requires hackademic URL handler from github user smargh | |
entirely rewritten to take advantage of Skim's built-in templating | |
2016-06-26 by derickfay | |
2019-02-09 updated to group notes by color | |
*) | |
property LF : (ASCII character 10) |
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
tell application "Bookends" | |
set theIDs to «event ToySRUID» "Selection" | |
repeat with theID in paragraphs of theIDs | |
tell front library window | |
try | |
set myRefs to (publication items whose id is theID) | |
set myItem to first item of myRefs | |
set thePath to path of attachment items of myItem |
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
tell application "Bookends" | |
tell front library window | |
set theIDs to get id of publication items of group item "Unlinked Attachments" | |
repeat with theID in theIDs | |
try | |
set myRefs to (publication items whose id is theID) | |
set myItem to first item of myRefs | |
set {theKey, thePath, theAuthor, theEditor, theTitle} to {citekey, path of attachment items, authors, editors, title} of myItem | |
if theAuthor = "" then set theAuthor to theEditor | |
set theRIS to format myItem using "RIS.fmt" |
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
set theFolder to (path to home folder as text) & "Library:Mobile Documents:iCloud~com~sonnysoftware~bot:Documents" | |
set BEList to {} | |
set orphanList to {} | |
set FinderList to {} | |
set pathList to {} | |
set od to AppleScript's text item delimiters | |
tell application "Finder" | |
-- create a list of the name of every file in the folder you've set | |
set FinderList to every file of folder theFolder as alias list |
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
/** | |
* Used as a wrapper for data that is exposed via a LiveData that represents an event. | |
*/ | |
open class Event<out T>(private val content: T) { | |
var hasBeenHandled = false | |
private set // Allow external read but not write | |
/** | |
* Returns the content and prevents its use again. |
NewerOlder