Skip to content

Instantly share code, notes, and snippets.

View dmgcodevil's full-sized avatar
👽
coding

Roman Pleshkov dmgcodevil

👽
coding
  • Lost in the static
  • USA, NY
View GitHub Profile
@dmgcodevil
dmgcodevil / cf.scala
Last active September 11, 2024 02:13
object Main {
trait Executor {}
trait Context {
def data: String
}
type IO[T] = Executor ?=> T
type Result[T] = Context ?=> IO[T]
```java
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@Component
@dmgcodevil
dmgcodevil / Main.scala
Created November 21, 2023 22:41
RC,RE,RB1,RB2 calculator for Class A NPN Common-Emitter Amplifier
import scala.collection.mutable
// RC,RE,RB1,RB2 calculator for Class A NPN Common-Emitter Amplifier
object Main {
val I_DIVIDER_GAIN = 10 // I0 > IB
def main(args: Array[String]): Unit = {
val Vcc = 19.5
val inputs = List(
Roman Pleshkov
suggest a consensus algorithm that is doable to implement
One consensus algorithm that is relatively easy to implement is the Practical Byzantine Fault Tolerance (PBFT) algorithm. PBFT is a consensus algorithm that is used in distributed systems to ensure that all nodes in the network agree on the state of the system, even if some nodes are faulty or malicious.
The PBFT algorithm is designed to be fault-tolerant, meaning that it can handle failures of nodes in the network. It works by dividing the nodes in the network into three groups: a primary group, a backup group, and a client group. The primary group is responsible for proposing new transactions to be added to the blockchain, while the backup group acts as a safety net in case the primary group fails. The client group is responsible for sending transactions to the network.
In the PBFT algorithm, each node has a copy of the blockchain and a state machine that reflects the current state of the system. When a client sends a transaction to
private static final synthetic getA$lzycompute$1(scala.runtime.LazyInt arg0) { //(Lscala/runtime/LazyInt;)I
<localVar:index=0 , name=getA$lzy$1 , desc=Lscala/runtime/LazyInt;, sig=null, start=L1, end=L2>
TryCatch: L3 to L4 handled by L5: Type is null.
L1 {
aload0
dup
astore1
monitorenter
}
@dmgcodevil
dmgcodevil / Core.scala
Created September 13, 2020 19:00
Effect wrapper
package io.parapet.v2
import cats.effect.{Concurrent, ContextShift, IO, Timer}
import cats.free.Free
import cats.free.Free.liftF
import cats.{Monad, ~>}
import scala.concurrent.ExecutionContext
object Core {
@dmgcodevil
dmgcodevil / gist:22e50eb8f415602bb8d128fe28cdb209
Created December 28, 2019 03:48
Using UDP multicast for pods/peers discovery in Kubernetes

Java app: Publisher/Receiver

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@dmgcodevil
dmgcodevil / alacarte.scala
Last active March 26, 2021 06:07
alacarte
object alacarte {
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
@dmgcodevil
dmgcodevil / LaCarte.scala
Last active May 6, 2019 21:48
modular function eval that interprets expressions that are constructed using the a la carte ` technique
import cats.implicits._
import cats.{Functor, MonadError}
// links:
// [1] http://www.cs.nott.ac.uk/~pszgmh/alacarte.pdf
// [2] http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf
object LaCarte {
type ErrorOr[A] = Either[String, A]
public class MinimumWindowSubstring {
public static void main(String[] args) {
assertEquals("ba", minWindow("bba", "ab"));
assertEquals("b", minWindow("ab", "b"));
assertEquals("", minWindow("ab", ""));
assertEquals("bc", minWindow("abc", "bc"));
assertEquals("ab", minWindow("abc", "ab"));
assertEquals("b", minWindow("abc", "b"));