Skip to content

Instantly share code, notes, and snippets.

View ABartelt's full-sized avatar

Arne ABartelt

View GitHub Profile
@ABartelt
ABartelt / clockodo.sh
Created March 4, 2024 15:07
Clockodo-CLI start and end working time bash script
#!/bin/bash
# Configuration under "My data" - Profile
API_KEY="efa7dd31.........."
USER_ID="[email protected]"
CLOCKODO_API="https://my.clockodo.com/api/v2"
# To find these start a clock and use developer in networking tab on POST request on /clock.
CUSTOMER_ID="27...."
SERVICES_ID="94...."
@ABartelt
ABartelt / lxc-snapshot-backup.sh
Last active April 8, 2020 17:37
Backup LXC Containers with pruning old snapshots
#!/usr/bin/env bash
#set -ex
BACKUP_DIR=/backup/containers/lxc
HOSTS=($(lxc-ls -1 -F NAME))
LOGFILE=/backup/scripts/lxc-snapshots.log
declare -i LASTBACKUPS=7
for HOST in "${HOSTS[@]}"
do
@ABartelt
ABartelt / 1_Laravel_state-machine.md
Created August 7, 2019 13:19 — forked from iben12/1_Laravel_state-machine.md
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.