Skip to content

Instantly share code, notes, and snippets.

View Softsapiens's full-sized avatar

Daniel Pous Montardit Softsapiens

View GitHub Profile
@Softsapiens
Softsapiens / Example.kt
Created May 18, 2023 13:46 — forked from nomisRev/Example.kt
StackOverflow Question
import arrow.core.Nel
import arrow.core.raise.Raise
import arrow.core.raise.recover
import arrow.fx.coroutines.parZipOrAccumulate
object ApplicationError
object UserLegalId
object User
object DepartmentCode
object Department
@Softsapiens
Softsapiens / Example.kt
Created April 6, 2023 15:01 — forked from nomisRev/Example.kt
Stacksafe Mono Reactor
import reactor.core.publisher.Mono
import java.util.concurrent.Executor
fun noTrampolining(): Mono<Int> {
var initial = Mono.just(0)
(0..5000).forEach { i ->
initial = initial.map { i }
}
return initial

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@Softsapiens
Softsapiens / export-cognito-users.sh
Created February 15, 2021 08:45 — forked from chrisdiana/export-cognito-users.sh
Export AWS Cognito User Pool
# Export as Text Table
aws --region XXXXXXXXX cognito-idp list-users --user-pool-id XXXXXXXXXXXXX --output table > ~/users.txt
# Export as JSON
aws --region XXXXXXXXX cognito-idp list-users --user-pool-id XXXXXXXXXXXXX --output json > ~/users.json
# Export User Pool with more than 60 users (pagination)
aws --region XXXXXXXXX cognito-idp list-users --user-pool-id XXXXXXXXXXXXX --pagination-token INCREDIBLYLONGSTRINGHERE --output json > ~/users-2.json
use std::{
fs::File,
io::{Read, Write},
time::Instant,
};
use tokio::task::{self, JoinHandle};
async fn compute() {
let handles: Vec<JoinHandle<_>> = (0..1000)
.map(|_| {
@Softsapiens
Softsapiens / goroutines.go
Created February 12, 2021 09:09 — forked from niklaskorz/goroutines.go
Threading Performance Comparison
package main
import (
"fmt"
"os"
"runtime"
"sync"
"time"
)
@Softsapiens
Softsapiens / reflections_cats_test.go
Created February 12, 2021 08:42 — forked from shannonwells/reflections_cats_test.go
Reflections in Go, For Cats
package reflect_cats_test
import (
"encoding/json"
"net/url"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@Softsapiens
Softsapiens / predef.scala
Created December 16, 2019 11:39 — forked from mpilquist/predef.scala
Ammonite REPL predef for use with fs2
// Save as ~/.ammonite/predef.sc
// To use fs2 from ammonite repl, type `load.fs2` from repl prompt.
// You'll get all fs2 & cats imports, ContextShift and Timer instances
// for IO, and a globalBlocker
import $plugin.$ivy.`org.typelevel:::kind-projector:0.11.0`
if (!repl.compiler.settings.isScala213)
repl.load.apply("interp.configureCompiler(_.settings.YpartialUnification.value = true)")
@Softsapiens
Softsapiens / nvim-qt-commands.adoc
Created April 12, 2019 09:51
nvim-qt font management
:GuiFont Iosevka Term:h15
@Softsapiens
Softsapiens / pwd-random-generator.sh
Created April 11, 2019 08:08
A shell script to generate random secure passwords
</dev/urandom tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c 13 ; echo