Skip to content

Instantly share code, notes, and snippets.

View guss77's full-sized avatar

Oded Arbel guss77

View GitHub Profile
@guss77
guss77 / build-ffmpeg.Dockerfile
Created July 4, 2020 18:51
Build alternative FFMPEG for Jellyfin
FROM debian:10
# install Debian dependencies
RUN apt-get update && \
apt-get install -qy subversion git gcc g++ cmake nasm pkg-config \
libgmp-dev gnutls-dev libass-dev libfreetype6-dev libbluray-dev libfribidi-dev libdrm-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libwebp-dev libx264-dev libx265-dev libzvbi-dev libva-dev && \
rm -rf /var/lib/apt
# Install NV codec support
WORKDIR /ffmpeg
@guss77
guss77 / Makefile
Created September 22, 2020 20:57
MariaDB update table with UUID
COMPOSE := docker-compose -p demouuid
start:
$(COMPOSE) up -d
sleep 3
while $(COMPOSE) ps | grep -q database; do \
$(COMPOSE) logs 2>/dev/null| grep -q 'MySQL init process done.' && break;\
$(COMPOSE) logs 2>/dev/null| grep -i error && break;\
$(COMPOSE) ps | grep -q Exit && break;\
done
#!/bin/bash -e
verbosity=info
tokfile="/tmp/tok-$$"
domlist_pfx="/tmp/doms-$$-"
doctl_tokens=(
# Place all your DO personal access tokens here in this array as simple text, preferably one per line
)
function log() {
@guss77
guss77 / azure-rest-api-auth.sh
Last active April 19, 2021 22:05
Create a shared key for Azure storage REST API
#!/bin/bash
# Based on https://docs.microsoft.com/en-us/azure/storage/common/storage-rest-api-auth
function GetCanonicalizedResource() {
local address="$1" storageAccountName="$2"
echo -n "/${storageAccountName}$(cut -d? -f1 <<<"$address")"
cut -d? -f2- <<<"$address" | tr '&' '\n' | (while IFS="=" read key val; do printf '\n%s:%s' "$key" "$val"; done)
}
@guss77
guss77 / sevenboom.cpp
Last active August 7, 2021 13:09
Seven boom game by tracking each decimal digit separately instead of looking at the actual number and computing
#include <memory>
#include <ranges>
#include <iostream>
class Digit {
unsigned char val, sevenCount;
std::unique_ptr<Digit> moreSignificant;
public:
Digit(unsigned char startVal) : val(startVal), sevenCount(startVal % 7) {}
void inc() {
@guss77
guss77 / sevenboom2.cpp
Created August 7, 2021 13:10
"Improved" seven boom by `hasSeven()` being a one op and only the first digit tracking divisibility
#include <memory>
#include <ranges>
#include <iostream>
class Digit {
unsigned char val;
std::unique_ptr<Digit> moreSignificant;
static unsigned int sevens;
public:
Digit(unsigned char startVal) : val(startVal) {}
@guss77
guss77 / vertx-hazelcast-cluster-on-fargate-ecs.md
Last active November 18, 2021 17:26
Vert.x Hazelcast Cluster on AWS Fargate

Introduction

I ran into a some problems trying to deploy a Vert.x based HTTP service, using Hazelcast as the cluster manager, on AWS ECS Fargate (a container orchestration service where you deploy docker containers without worrying about the underlying virtual machines - kind of like Kubernetes, but simpler perhaps?).

Some Problems

Hazelcast has good documentation on their website on using Hazelcast on AWS ECS, but all of it assumes that you are configuring the cluster with their YAML configuration language - which unfortunately doesn't

@guss77
guss77 / VertxFutureTest.java
Created August 14, 2022 16:30
Vert.x Future onSuccess/onFailure do not propagate errors
package testing;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
public class VertxFutureTest {
static Object waiter = new Object();
static boolean done = false;
@guss77
guss77 / RateLimiter.java
Last active July 19, 2023 06:47
Counter based rate limiter class for Java.
package coil.geek;
import java.util.concurrent.atomic.AtomicLong;
/**
* A token-based rate limiter, inspired by https://stackoverflow.com/a/55349487/53538
*
* The original implementation boasts an O(1) time complexity as well as O(1) space complexity, but controls
* concurrency using synchronization. This implementation uses atomic operations to offer lock-less concurrency
* and reentrancy.
@guss77
guss77 / read-plasma-wallpaper
Last active March 13, 2023 20:53
Bash script that reports the currently set KDE Plasma wallpaper, on the specified (or current) activity and screen. Supports the Image and Slideshow plugins and can complain correctly about the POTD plugin.
#!/bin/bash
##
# Helper to find the user configured name of an activity, by its ID
function getActivityName() {
qdbus org.kde.ActivityManager /ActivityManager/Activities \
org.kde.ActivityManager.Activities.ActivityName "$1"
}
##