Skip to content

Instantly share code, notes, and snippets.

View nebtrx's full-sized avatar
🎈
out of the comfort zone

Omar García nebtrx

🎈
out of the comfort zone
View GitHub Profile
@gabro
gabro / crypto.scala
Created July 22, 2020 05:49
Read string into keyring
import org.bouncycastle.openpgp.{
PGPPublicKeyRing,
PGPPublicKeyRingCollection,
PGPUtil,
}
import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator
def readPGPPublicKeys(pubKeys: List[String]): PGPPublicKeyRingCollection = {
val fingerprintCalculator = new JcaKeyFingerprintCalculator()
val publicKeyRings = pubKeys.map { pubKey =>
@gmolveau
gmolveau / firefox_dark_background.md
Last active April 2, 2024 15:58
Firefox dark background / theme for new tab and loading screen

Firefox Dark Background

  • How to change the background on Firefox to a dark one on new tab / loading screen ?

Procedure

  • Type about:config in the URL bar
  • Search toolkit.legacyUserProfileCustomizations.stylesheets and double-click the field to set it to true
  • Type about:support in the URL bar
  • Look for Profile folder field and click on the open button next to it.
@jdegoes
jdegoes / fpmax.scala
Created July 13, 2018 03:18
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
object game {
case class Lens[S, A](set: A => S => S, get: S => A) { self =>
def >>> [B](that: Lens[A, B]): Lens[S, B] =
Lens[S, B](
set = (b: B) => (s: S) => self.set(that.set(b)(self.get(s)))(s),
get = (s: S) => that.get(self.get(s))
)
}
case class Prism[S, A](set: A => S, get: S => Option[A]) { self =>

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.

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@jkpl
jkpl / Main.scala
Last active February 5, 2024 08:29
Ways to pattern match generic types in Scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}
@markrendle
markrendle / explanation.md
Last active July 3, 2022 07:56
Why I was previously not a fan of Apache Kafka

Update, September 2016

OK, you can pretty much ignore what I wrote below this update, because it doesn't really apply anymore.

I wrote this over a year ago, and at the time I had spent a couple of weeks trying to get Kafka 0.8 working with .NET and then Node.js with much frustration and very little success. I was rather angry. It keeps getting linked, though, and just popped up on Hacker News, so here's sort of an update, although I haven't used Kafka at all this year so I don't really have any new information.

In the end, we managed to get things working with a Node.js client, although we continued to have problems, both with our code and with managing a Kafka/Zookeeper cluster generally. What made it worse was that I did not then, and do not now, believe that Kafka was the correct solution for that particular problem at that particular company. What they were trying to achieve could have been done more simply with any number of other messaging systems, with a subscriber reading messages off and writing