Skip to content

Instantly share code, notes, and snippets.

@zsedem
zsedem / akka-retry-flow.scala
Created June 30, 2021 10:38
A pure akka-streams implementation for retry dynamodb partial failures
trait DynamoWriteItem {
def id: String
}
trait DynamoService {
def writeBatch(dynamoWriteItems: List[DynamoWriteItem]): Future[Either[List[DynamoWriteItem], Done]]
}
object DynamoWriteStream {
def batchedFlow[PassThrough](
@zsedem
zsedem / AkkaConnectionMonitoringServer.scala
Last active September 12, 2019 10:04
An akka http server, which keeps track of opened connections and requests
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.{ArrayBlockingQueue, ThreadPoolExecutor, TimeUnit}
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Keep, Sink}
@zsedem
zsedem / prototype output
Created April 12, 2018 10:59
Output from the prototype of an fingerprint driver
Prototype version 15
Found device 138a:0097
step 1
usb write:
0000 01
usb read:
0000 00 00 f0 b0 5e 54 a4 00 00 00 06 07 01 30 00 01
0010 00 00 61 13 88 35 41 9d 00 23 00 00 00 00 01 00
0020 00 00 00 00 00 07
@zsedem
zsedem / snapshot.sh
Last active June 7, 2022 13:48
NixOS with Btrfs
# I have 3 btrfs subvolume /root, /home, /nix-store and these are used as the name suggest
# Now, when i create new nixos configuration i can make a snapshot of root and home, before i switch to a new config.
CURRENT_GENERATION=`readlink /nix/var/nix/profiles/system | cut -d'-' -f2`; echo Determined current generation: $CURRENT_GENERATION
sudo mkdir -p /btrfs
# the / is not mounted in my btrfs filesystem by default, because my filesystem root is the /root subvolume
sudo mount /dev/mapper/NixOS /btrfs
sudo btrfs subvolume snapshot /btrfs/root /btrfs/root-$CURRENT_GENERATION-snapshot
# I also make a snapshot of home, because i use gnome or KDE, which contains a lots of config and cache, which can broke by a rollback.
sudo btrfs subvolume snapshot /btrfs/home /btrfs/home-$CURRENT_GENERATION-snapshot