Gnarly Learnings from April 2023
Tags: typescript, rails, github, css
Published: 2023-04-30 14:39:47

At the Gnar we are always reading, watching, and listening in order to keep our skills sharp and our perspectives fresh. Here are some of the resources we learned from this month.

## [CSS Supports Trigonometry Functions](https://www.zdnet.com/article/css-to-get-support-for-trigonometry-functions/)

Trig functions in CSS make it easier to rotate objects and let us avoid using magic numbers. For example, `sin(60 degrees)` expresses the developer's intent more clearly than `0.866025`.

## [Action Mailer Now Supports *_deliver Callbacks](https://github.com/rails/rails/pull/47630)

Three callbacks (`before_deliver`, `after_deliver`, `around_deliver`) have been added to Action Mailer. You may have strong feelings about callbacks and I probably tend to agree with you, but _sometimes_ they are the right tool to reach for. The described use cases for this include updating an Active Record model’s `delivered_at` (which is especially useful when dealing with async deliveries), handling delivery errors, and executing tasks that require a delivery provider’s `message_id`.

## [Useful Tips for Using GitHub Copilot](https://dev.to/github/a-beginners-guide-to-prompt-engineering-with-github-copilot-3ibp)

Like any other tool, GitHub Copilot has a learning curve. This article from GitHub developer advocate [Rizel Scarlett](https://blackgirlbytes.dev/about-me) gives us a few tips to quickly improve the quality of Copilot suggestions. One thing I didn’t realize: Copilot uses your open tabs to provide context for the questions you ask! That tip in and of itself really helped me make better use of the tool in my day-to-day work. 

## [CSS text-wrap: balance](https://developer.chrome.com/blog/css-text-wrap-balance/)

Chrome Canary now includes a new experimental CSS feature, `text-wrap: balance`, that evaluates line breaks to balance blocks of text. As developers, we often look for solutions that help to keep text consistent regardless of final font size, screen size, and language, which are often unknown. This property aims to mitigate those concerns, though it is not without its challenges. It is currently limited to four wrapped lines (and under) and presents some performance considerations due to the iterative technique used to perform the wrapping. 


## [TypeScript’s infer](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types)

TypeScript’s [Conditional types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) have allowed developers to build internal type logic based on types provided to the conditional—`Model<string>` might have subtle differences in signature from `Model<number>`. Now, TypeScript has given us `infer`, allowing us to identify and refer to dynamic type values from within a Conditional type. It _sounds_ like a lot - and it kind of is, the uses for this are pretty niche! - but once you wrap your head around it, you’ll have a powerful new TypeScript tool in your arsenal. 

## Contributors:

* [Alex Jarvis](github.com/alxjrvs)
* [Ethan Fertsch](https://github.com/efertsch)
* [Royce Threadgill](https://github.com/jrthreadgill)
* [Steve Zelaznik](https://github.com/zelaznik)

_Learn more about how The Gnar [builds software](https://www.thegnar.com/software-development)._