Skip to content

Instantly share code, notes, and snippets.

View cbruegg's full-sized avatar

Christian Brüggemann cbruegg

View GitHub Profile
@cbruegg
cbruegg / dropbox-differential-backup.sh
Last active November 12, 2024 19:18
Script to keep differential backups of your Dropbox with a maximum storage quota using rclone. Uses hardlinks to save space.
#!/bin/bash
# Configuration
RCLONE_REMOTE="dropbox:/" # Adjust this if you don't want the full Dropbox
BACKUP_DIR="/path/to/backups" # Adjust to your local backup directory
SNAPSHOT_LIMIT=500000 # Max usage in MB (500 GB)
# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
@cbruegg
cbruegg / compose-compat-on16_ModalBottomSheetCompat.kts
Last active November 2, 2024 23:02
Compose 1.6/1.7 Compatibility Layer
package composecompaton16
import composecompaton17.runningOnCompose16
// omitted androidx imports
@Composable
@ExperimentalMaterial3Api
fun ModalBottomSheetCompat(
contentWindowInsets: @Composable () -> WindowInsets = { BottomSheetDefaults.windowInsets },
// ...
@cbruegg
cbruegg / rewe-lieferservice-verfuegbarkeit.js
Last active July 31, 2024 21:22
Scriptable REWE Lieferservice Verfügbarkeit
let zipCode = "33100"
let widget = new ListWidget()
widget.setPadding(8, 8, 8, 8)
widget.url = "https://shop.rewe.de/"
await createWidget()
Script.setWidget(widget)
Script.complete()
interface SootEvent { }
class SomeSootEvent implements SootEvent { ... }
class Foo {
PublishSubject<SootEvent> eventSubject = PublishSubject.create();
void modifyState() {
// ... modify some state ...
eventSubject.onNext(new SomeSootEvent(...));
}
fun main(args: Array<String>) {
println(fib().take(5).toList())
}
fun fib() = sequence<Int> {
yield(1)
yield(1)
var prev = 1
var prevPrev = 1
package de.maxisma.allaboutsamsung
import android.content.Intent
import android.support.design.widget.Snackbar
import android.support.v4.app.Fragment
import com.squareup.moshi.JsonDataException
import com.squareup.moshi.JsonEncodingException
import kotlinx.coroutines.experimental.CancellationException
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Job
@cbruegg
cbruegg / calccorr.kt
Created September 2, 2017 11:06
Plot cryptocurrency difficulty correlations (quick and dirty)
package diffchecker
import org.jsoup.Jsoup
import java.net.URL
import java.util.*
private val currencies = arrayOf("bitcoin", "xmr", "ltc", "eth", "etc", "dash")
private fun urlFor(currency: String) = "https://bitinfocharts.com/comparison/$currency-difficulty.html"
private val dataRegex = Regex("\\[new Date\\(\"([0-9/]*)\"\\),([0-9.E+]*)]")
package edu.brown.cs.paneclient;
import java.io.IOException;
import java.net.InetAddress;
public class PaneSample {
private static final String PANE_CONTROLLER_HOSTNAME = "localhost";
private static final int PANE_CONTROLLER_PORT = 9000;
private static final String PANE_USERNAME = "username";
import psutil
import time
import collections
###
### Simply pipe the output of this program into a file
### to obtain CSV formatted data about the CPU, memory,
### network and disk. Press CTRL-C to stop writing.
###
Iteration 149
HashSkipNode{skipNode=SkipNode{running=true, id=2, bitstring='001000', neighbors=0:{[7, 10]}1:{[]}2:{[]}3:{[]}4:{[]}5:{[]}, internalMap={2=3, 4=5, 6=20}}
HashSkipNode{skipNode=SkipNode{running=true, id=7, bitstring='111010', neighbors=0:{[2, 10, 20]}1:{[10]}2:{[10]}3:{[]}4:{[]}5:{[]}, internalMap={8=4}}
HashSkipNode{skipNode=SkipNode{running=true, id=10, bitstring='110011', neighbors=0:{[2, 7]}1:{[7]}2:{[7]}3:{[]}4:{[]}5:{[]}, internalMap={1=2}}
HashSkipNode{skipNode=SkipNode{running=false, id=20, bitstring='001101', neighbors=0:{[2, 10]}1:{[2]}2:{[2]}3:{[2]}4:{[]}5:{[]}, internalMap={1=2}}
-----------------------------
Iteration 150
TEST: Join node 25 at node 2
HashSkipNode{skipNode=SkipNode{running=true, id=2, bitstring='001000', neighbors=0:{[7, 10]}1:{[]}2:{[]}3:{[]}4:{[]}5:{[]}, internalMap={2=3, 4=5, 6=20}}
HashSkipNode{skipNode=SkipNode{running=true, id=7, bitstring='111010', neighbors=0:{[2, 10, 20]}1:{[10]}2:{[10]}3:{[]}4:{[]}5:{[]}, internalMap={8=4}}