- Notifications
You must be signed in to change notification settings - Fork0
alamak catches your errors and lets a pixel pal tell you all about it.
License
Unknown, MIT licenses found
Licenses found
gdagstn/alamak
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
alamak
catches your errors and lets a Pixel Pal (patent pending) tell you all about it.
The name comes from the Singlish/Malay expression"alamak!", which is an exclamation that follows a surprising/unsettling event, or a minor nuisance, according to the vibe.
As usual, install throughtdevtools
:
devtools::install_github("gdagstn/alamak")
You may think that in order to usealamak
you need to know how to code. The opposite is true: not knowing how to code will letalamak
shine in all its glory.
Wrap your call into a call toalamak()
. If a warning or an error occurs, a Pixel Pal (patent pending) appears on the screen and tells you what they think about you and your situation.
library(alamak)alamak(your_function(), pixelpal = "Jerry")
Alternatively, and if you are using R 4.0 and above, you can use the|>
(pipe) operator (or the%>%
magrittr
pipe for versions below). Note that sometimes the function call on the left has to be enclosed in parentheses to work:
sum(a, 3) |> alamak(pixpal = "Lenny")sum(a, 3) %>% alamak(pixpal = "Oniji")# This also works but needs parentheses(a + 3) |> alamak(pixpal = "Buster")
alamak()
displays compressed Pixel Pals by default. Compression saves space, but in some terminals it does not work well. You can disable it by addingcompress = FALSE
to thealamak()
arguments.
The Rstudio console default theme (TextMate) has a line height that doesn't render "pixels" properly. To fix this you can edit the .rstheme file by adding this element:
#rstudio_console_output { line-height: 1.2 !important;}
alamak
is quite dumb and should not be used in professional settings, unless that's your thing.
There are 5 Pixel Pals (patent pending) available:
Jerry, a parrot who doesn't like you very much:
Buster, a cool lemon:
Lenny, a supportive velociraptor who is also great with kids:
Oniji, an 18th century Japanese kabuki actor who only speaks in haiku:
E10N, a no-nonsense robot from the not so distant future
You can create another Pixel Pal (patent pending) yourself! If you have a 16x16 (can be bigger but may distort the text on the screen) PNG file with transparency you can load it. As a reference, consider that every "pixel" is actually two whitespaces with a colored background, so a 32x32 picture will take up 64 spaces in size in the terminal.
You only need to make a list with the following elements:
crayon
: the result of a call tomakePixelPal()
where the argument is the path to a PNG filemessages
: a nested list containing two other lists:Error
: a character vector of error messagesWarning
: a character vector of warning messages
You can choose whether you want the Pixel Pal to be compressed or not.
new_pixelpal = list("crayon" = makePixPal("path/to/picture.png", compress = TRUE), "messages" = list( "Error" = c("The first possible message", "The second possible message", "And so on", "You know the drill"), "Warning" = c("A warning message", "Another warning message") ) )
then use it withalamak
alamak(your_function(), new_pixelpal)
- Gábor Csárdi for the
crayon
package - Simon Urbanek for the
png
package - Trevor L. Davis for suggestions on compression using Unicode Blocks
About
alamak catches your errors and lets a pixel pal tell you all about it.