Skip to content

Instantly share code, notes, and snippets.

View erikvanoosten's full-sized avatar

Erik van Oosten erikvanoosten

View GitHub Profile
@erikvanoosten
erikvanoosten / update-immich.sh
Last active January 20, 2024 18:44
Update Immich
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
CURRENT_VERSION=$(grep IMMICH_VERSION= .env | awk -F= '{print $2}')
echo "Getting latest version of Immich..."
LATEST_VERSION=$(curl -s --include https://github.com/immich-app/immich/releases/latest | grep 'location:' | awk -F/ '{print $NF}')
# Remove DOS line end
LATEST_VERSION=${LATEST_VERSION//[$'\t\r\n ']}
package zio.kafka.example
import io.github.embeddedkafka.{ EmbeddedK, EmbeddedKafka, EmbeddedKafkaConfig }
import org.apache.kafka.clients.producer.ProducerRecord
import zio._
import zio.kafka.consumer.Consumer.AutoOffsetStrategy
import zio.kafka.consumer.{ Consumer, ConsumerSettings, OffsetBatch, Subscription }
import zio.kafka.producer.{ Producer, ProducerSettings }
import zio.kafka.serde.Serde
import zio.logging.backend.SLF4J
package test
import zio._
import zio.stream.ZStream
import zio.internal.ExecutionMetrics
object MinimalReproducer extends ZIOAppDefault {
/**
* A runtime layer that can be used to run everything on the thread of the caller.
@erikvanoosten
erikvanoosten / RuntimeReproducer.scala
Created April 8, 2023 05:47
Reproduces problem where a ZIO taks runs on another thread than expected
import zio.internal.ExecutionMetrics
import zio.{Executor, Runtime, RuntimeFlag, RuntimeFlags, Scope, Task, Trace, Unsafe, ZIO, ZIOAppArgs, ZIOAppDefault, ZLayer}
object RuntimeReproducer extends ZIOAppDefault {
override def run: ZIO[Any with ZIOAppArgs with Scope, Any, Any] =
for {
runtime <- ZIO.runtime[Any]
_ <- ZIO.attempt {
println("main thread id" + Thread.currentThread().getId)

Keybase proof

I hereby claim:

  • I am erikvanoosten on github.
  • I am erikvanoosten (https://keybase.io/erikvanoosten) on keybase.
  • I have a public key ASAGx3KiQYeMb9TXRsaSLpS2XNt6-W2zd-d9XV1nT72G2Ao

To claim this, I am signing this object:

@erikvanoosten
erikvanoosten / Parboiled2CsvParser.scala
Created September 23, 2015 11:37 — forked from maciej/Parboiled2CsvParser.scala
Parboiled2 CSV parser
/* based on comments in https://github.com/sirthias/parboiled2/issues/61 */
case class Parboiled2CsvParser(input: ParserInput, delimeter: String) extends Parser {
def DQUOTE = '"'
def DELIMITER_TOKEN = rule(capture(delimeter))
def DQUOTE2 = rule("\"\"" ~ push("\""))
def CRLF = rule(capture("\n\r" | "\n"))
def NON_CAPTURING_CRLF = rule("\n\r" | "\n")
val delims = s"$delimeter\r\n" + DQUOTE
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.*;
import com.yammer.metrics.reporting.GraphiteReporter;
import com.yammer.metrics.reporting.SocketProvider;
import com.yammer.metrics.stats.Snapshot;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
#!/bin/sh
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
wget www.scala-lang.org/files/archive/scala-2.10.3.deb
sudo dpkg -i scala-2.10.3.deb
sudo apt-get update
TIMECAPSULE_IP="" # e.g. "192.168.1.100"
TIMECAPSULE_VOLUME="/Time Capsule" # also try "/Data"
export PASSWD='YOURPASSWORDHERE' # No need to escape anything (except "'")
MOUNT_POINT="/mnt/timecapsule" # no need to create the directory
IS_MOUNTED=`mount 2> /dev/null | grep "$MOUNT_POINT" | cut -d' ' -f3`
TIMECAPSULE_PATH="//$TIMECAPSULE_IP$TIMECAPSULE_VOLUME"
if [[ "$IS_MOUNTED" ]] ;then
umount $MOUNT_POINT
@erikvanoosten
erikvanoosten / gist:3604873
Last active October 10, 2015 00:38
Sentries example usage
class DoItAllService extends nl.grons.sentries.support.SentrySupport {
val dbSentry = sentry("mysql:localhost:3366") withMetrics withFailLimit(failLimit = 5, retryDelay = 500 millis)
val twitterApiSentry = sentry("twitter") withMetrics withFailLimit(failLimit = 5, retryDelay = 500 millis) withConcurrencyLimit(3)
def loadTweetFromDb(id: Long): Tweet = dbSentry {
database.load(id)
}
def getFromTwitter(id: Long): Tweet = twitterApiSentry {