Skip to content

Instantly share code, notes, and snippets.

Avatar

Oded Arbel guss77

View GitHub Profile
@guss77
guss77 / sevenboom2.cpp
Created Aug 7, 2021
"Improved" seven boom by `hasSeven()` being a one op and only the first digit tracking divisibility
View sevenboom2.cpp
#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 / sevenboom.cpp
Last active Aug 7, 2021
Seven boom game by tracking each decimal digit separately instead of looking at the actual number and computing
View sevenboom.cpp
#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 / azure-rest-api-auth.sh
Last active Apr 19, 2021
Create a shared key for Azure storage REST API
View azure-rest-api-auth.sh
#!/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)
}
View certbot-do-hook.sh
#!/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 / Makefile
Created Sep 22, 2020
MariaDB update table with UUID
View Makefile
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
@guss77
guss77 / build-ffmpeg.Dockerfile
Created Jul 4, 2020
Build alternative FFMPEG for Jellyfin
View build-ffmpeg.Dockerfile
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 / reset-tb
Last active Mar 27, 2021
Script to reset the XHCI of a Thunderbolt connection in case the kernel stops it
View reset-tb
#!/bin/bash
# As described in https://bugs.launchpad.net/bugs/1766076
### Installation Instructions:
# 1. Install file into `/usr/local/bin/reset-tb`
#
# 2. Optional: allow password less sudo by creating a file `/etc/sudoers.d/allow-reset-tb` with the following content:
# ----8<-----
# <your username> ALL = NOPASSWD: /usr/local/bin/reset-tb
# ----8<-----
#
@guss77
guss77 / VertxBufferOutputStream.java
Created Sep 20, 2018
An output stream implementation over a Vert.x `Buffer` instance - like `ByteArrayOutputStream` but a bit Vert.xified.
View VertxBufferOutputStream.java
import java.io.IOException;
import java.io.OutputStream;
import io.vertx.core.buffer.Buffer;
public class VertxBufferOutputStream extends OutputStream {
private Buffer buffer;
public BufferOutputStream() {
this.buffer = Buffer.buffer();
View google-group-import.sh
#!/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 / Futures.java
Created Mar 26, 2018
CompletableFuture helper class
View Futures.java
package tech.greenfield.util.concurrent;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import java.util.function.Function;
public class Futures {
static class Thrower {
static Throwable except;