Skip to content

Instantly share code, notes, and snippets.

View guss77's full-sized avatar

Oded Arbel guss77

View GitHub Profile
@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 / cloud-formation-computed-variables.yaml
Last active February 18, 2022 15:45
Computed variables for CloudFormation using an identity function, as by @claude on StackOverflow (https://serverfault.com/a/812040/6438)
##
#
# Custom resource setup to provide an identity function that can be used to
# implement "custom variables".
# See: https://serverfault.com/a/812040/6438
#
# Usage:
#
# After deploying the below code to your stack, you can define computed
# variables thus:
@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 / mongo_db_recover_delete_record-2.4.py
Last active August 26, 2022 05:52
Try to recover deleted documents from a mongodb 2.4 data file. Based on https://gist.github.com/egguy/2788955 with help from https://yazadk.wordpress.com/2015/07/15/a-forensic-perspective-on-recovering-deleted-data-from-big-data-systems/#MongoDB . Make sure to change `decode_chunk` so it properly detects the objects you are trying to recover - i…
#!/usr/bin/python
"""A little script to recover deleted recording of a mongoDB db file
There's no optimization but it work and has saved me
"""
import struct
import bson
import pymongo
@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"
}
##
@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.
#!/bin/bash
function usage() {
(
echo "usage: $0 <auth-token> <group-address> <mbox-dir>"
echo "To generate an auth token go to https://developers.google.com/oauthplayground/ and get an access token for Google Groups migration"
) >&2
exit 5
}
@guss77
guss77 / lunar-base.list
Created September 19, 2023 11:11
Ubuntu lunar sources
deb http://archive.ubuntu.com/ubuntu lunar main restricted
deb-src http://il.archive.ubuntu.com/ubuntu/ lunar main restricted
deb http://archive.ubuntu.com/ubuntu lunar-updates main restricted
deb-src http://il.archive.ubuntu.com/ubuntu/ lunar-updates main restricted
deb http://archive.ubuntu.com/ubuntu lunar universe
deb-src http://il.archive.ubuntu.com/ubuntu/ lunar universe
deb http://archive.ubuntu.com/ubuntu lunar-updates universe
#!/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() {