- Programming using a series of transformations and aggregations, something I've been doing for years, is known as programming in the map/reduce style.
- The more abstract the type is, the greater its cardinality, and the smaller the set of operations it supports. So make use of universal quantifiers, particularly by implementing fully parametric functions. They guide you on how to implement their term-level definitions by narrowing down the number of possible implementations. In other words, the type system of Scala (or Haskell, for that matter) is not only great for capturing compile-time errors, but is also capable of leading you to the correct solution.
- You can encode union types by combining different Scala features such as type constructors, subtyping and implicits, and by taking advantage of the Curry-Howard Isomorphism and De Morgan's Laws for neg
| # I'll be doing another one for Linux, but this one will give you | |
| # a pop up notification and sound alert (using the built-in sounds for macOS) | |
| # Requires https://github.com/caarlos0/timer to be installed | |
| # Mac setup for pomo | |
| alias work="timer 60m && terminal-notifier -message 'Pomodoro'\ | |
| -title 'Work Timer is up! Take a Break 😊'\ | |
| -appIcon '~/Pictures/pumpkin.png'\ | |
| -sound Crystal" |
| <script setup lang="ts"> | |
| import { io } from 'socket.io-client' | |
| const connected = ref(false) | |
| onMounted(() => { | |
| const socket = io(); | |
| socket.on('connect', () => { | |
| connected.value = socket.connected |
Add the following configuration to your build.sbt:
// publish to github packages settings
publishTo := Some("GitHub <GITHUB_OWNER> Apache Maven Packages" at "https://maven.pkg.github.com/<GITHUB_OWNER>/<GITHUB_PROJECT>"),
publishMavenStyle := true,
credentials += Credentials(
"GitHub Package Registry",The following describes how you can publish artifacts for any sbt project using the GitHub Package Registry and the sbt-github-packages plugin.
In your GitHub account, go to Settings > Developer settings > Personal access tokens, then click on Generate new token (or click here). Fill in some sort of meaningful name (I chose Dev) and click on the write:packages checkbox:
Greg Beech wrote an article on Akka HTTP Entity Validation. This post is on the same topic, except we are going to use typeclass instances, as opposed to subtyping, for form validations.
To start with, let us suppose that we are working on some sort of user management service using Scala/Akka. However, here we are only going to focus on the registration part, in which the client is expected to send a user data, in JSON format; and the server needs to validate them, and save the user if the validations succeed, or reject the request with all the errors detected. That said, we should keep in mind that our validations may be used through out the entire codebase, not just in the user registration endpoint.
The rules for our validation are as follows:
TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.
If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)
A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/
The reason to avoid JWTs comes down to a couple different points:
- The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
See how a minor change to your commit message style can make a difference.
git commit -m"<type>(<optional scope>): <description>" \ -m"<optional body>" \ -m"<optional footer>"
| import slick.lifted.Rep | |
| import slick.ast.Ordering.Direction | |
| import slick.ast.Ordering | |
| import slick.lifted.Query | |
| import slick.lifted.ColumnOrdered | |
| import slick.lifted.Ordered | |
| import scala.util.control.NoStackTrace | |
| case class PageRequest(offset: Int, |
#The Problem We just described standard design issues you have when you start creating layers of services, DAOs and other components to implement an application. That blog/gist is here.
The goal is to think through some designs in order to develop something useful for an application.
#Working through Layers If you compose services and DAOs the normal way, you typically get imperative style objects. For example, imagine the following:
object DomainObjects {