Skip to content

Instantly share code, notes, and snippets.

View BalmungSan's full-sized avatar
👨‍🏫
Learning & Teaching

Luis Miguel Mejía Suárez BalmungSan

👨‍🏫
Learning & Teaching
View GitHub Profile
@djspiewak
djspiewak / 0introduction.md
Last active November 28, 2023 15:03
Scala Collections Proposal

Collections Redesign Proposal

I'm going to start off by motivating what I'm doing here. And I want to be clear that I'm not "dissing" the existing collections implementation or anything as unproductively negative as that. It was a really good experiment, it was a huge step forward given what we knew back in 2.8, but now it's time to learn from that experiment and do better. This proposal uses what I believe are the lessons we can learn about what worked, what didn't work, and what is and isn't important about collections in Scala.

This is going to start out sounding really negative and pervasively dismissive, but bear with me! There's a point to all my ranting. I want to be really clear about my motivations for the proposal being the way that it is.

Problems

Generic Interfaces

@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 3, 2025 08:56
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@nadavmatalon
nadavmatalon / mapf.ino
Created October 12, 2016 15:13
ARDUINO: MAP FLOAT FUNCTION
double mapf(double val, double in_min, double in_max, double out_min, double out_max) {
return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@kekru
kekru / add CA cert on CentOS Debian Ubuntu.md
Last active December 30, 2024 09:31
Add CA cert to local trust store on CentOS, Debian or Ubuntu
  • Open a webpage that uses the CA with Firefox
  • Click the lock-icon in the addressbar -> show information -> show certificate
  • the certificate viewer will open
  • click details and choose the certificate of the certificate-chain, you want to import to CentOS
  • click "Export..." and save it as .crt file
  • Copy the .crt file to /etc/pki/ca-trust/source/anchors on your CentOS machine
  • run update-ca-trust extract
  • test it with wget https://thewebsite.org

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.

@Geoyi
Geoyi / install virtualenv ubuntu 16.04.md
Created September 16, 2017 12:19 — forked from frfahim/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
@Daenyth
Daenyth / MonadAndFs2Ops.md
Last active June 25, 2024 13:04
Cheat sheet for common cats monad and fs2 operation shapes
Operation Input Result Notes
map F[A] , A => B F[B] Functor
apply F[A] , F[A => B] F[B] Applicative
(fa, fb, ...).mapN (F[A], F[B], ...) , (A, B, ...) => C F[C] Applicative
(fa, fb, ...).tupled (F[A], F[B], ...) F[(A, B, ...)] Applicative
flatMap F[A] , A => F[B] F[B] Monad
traverse F[A] , A => G[B] G[F[A]] Traversable; fa.traverse(f) == fa.map(f).sequence; "foreach with effects"
sequence F[G[A]] G[F[A]] Same as fga.traverse(identity)
attempt F[A] F[Either[E, A]] Given ApplicativeError[F, E]
@smarter
smarter / fmap.scala
Last active November 18, 2019 08:55
Should work with 0.20.0-RC1
// Compiles with https://github.com/lampepfl/dotty/pull/4672
// ./bin/dotc -classpath "$(coursier fetch -p org.typelevel:cats-core_2.13:2.0.0)" out/fmap.scala
import cats._
import cats.implicits._
object Test {
val fmap: [A, B] -> (A => B) => [F[_]] -> F[A] => (given Functor[F]) => F[B] = [A, B] -> (f: A => B) => ([F[_]] -> (fa: F[A]) => (given ev: Functor[F]) => fa.map(f))
val addOne = fmap((x: Int) => x + 1)
@BalmungSan
BalmungSan / UTCZonedDateTimeMongoCodec.scala
Last active February 19, 2022 08:00
Custom MongoDB codec for reading/writing ZonedDateTime instances in UTC
import cats.effect.IO
import io.circe.Encoder
import io.circe.generic.semiauto.deriveEncoder
import io.circe.java8.time.encodeZonedDateTimeDefault
import io.circe.syntax.EncoderOps
import org.bson.{BsonReader, BsonType, BsonWriter}
import org.bson.codecs.{DecoderContext, Codec, EncoderContext}
import org.bson.codecs.configuration.{CodecConfigurationException, CodecRegistries}
import org.mongodb.scala.MongoClient
import org.mongodb.scala.bson.codecs.{DEFAULT_CODEC_REGISTRY, Macros}
@BalmungSan
BalmungSan / StreamAsJsonArrayEncoder.scala
Created August 19, 2018 14:23
Http4s EntityEncoder for returning Streams as JSONArrays using Circe.
import cats.Applicative
import cats.effect.IO
import fs2.Stream
import io.circe.Encoder
import io.circe.generic.semiauto.deriveEncoder
import io.circe.syntax.EncoderOps
import org.http4s.{EntityEncoder, MediaType}
import org.http4s.dsl.io._
import org.http4s.headers.`Content-Type`