Skip to content

Instantly share code, notes, and snippets.

View akkerman's full-sized avatar

Marcel Akkerman akkerman

View GitHub Profile
@akkerman
akkerman / automatically git commit & branch.org
Created September 7, 2022 14:25
Scripts to to automatically commit changes and create branches in git branches triggered by cron.

Use these scripts in a cron job to automatically commit daily to a git repo and create a weekly Git branch.

Commit Daily

The following script will commit, pull and push changes when needed. It is used daily, or if wanted hourly.

filename: commit-daily.sh

#!/bin/sh
@akkerman
akkerman / jwt.js
Created March 11, 2022 07:19
Decode a Json Web Token and add dates that a human understands.
#!/usr/bin/env node
const jwt = require('jsonwebtoken')
const token = jwt.decode(process.argv[2])
const output = {
token,
issued: new Date(1000*token.iat).toLocaleString(),
expires: new Date(1000*token.exp).toLocaleString(),
}
@akkerman
akkerman / tpwd
Created November 13, 2021 18:20
start a tmux session in the current directory
#!/usr/bin/env bash
# start a tmux session in the current directory
dirname="$(basename $PWD)"
# tmux sessionname cannot contain a dot, replace with underscore
session="${dirname/./_}"
tmux_sessions=$(tmux ls -F '#{session_name}')
set -g prefix C-a
unbind C-b
bind C-a send-prefix # press C-a twice to send it through
bind r source-file ~/.config/tmux/tmux.conf \; display "tmux.conf Reloaded"
set -g mouse
set -as terminal-overrides ',st*:Ss@' # fix for crashes (st, tmux, nvim)
setw -g mode-keys vi
@akkerman
akkerman / docker wrapper.sh
Created June 12, 2021 07:10
Wraps the docker command to add some functionality
function docker() {
case "$1" in
ip)
command docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${@:2}"
;;
env)
command docker inspect --format '{{json .Config.Env}}' "${@:2}" | jq
;;
service)
if [ "$2" = env ]; then
# AKKERMAN ZSH Theme - initially based on AVIT
# vi: set ft=sh:
# settings
typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
PROMPT='
$(_user_host)${_current_dir} $(node_version) $(node_package) $(docker_context) $(git_prompt_info)
httpstatus () {
if [ -z $1 ]
then
w3m -dump -no-graph https://httpstatuses.com
else
w3m -dump -no-graph https://httpstatuses.com/$1 | sed -n '/-----/q;p' | ack -A 1000 'Status Code' | ack --passthru $1
fi
}
@akkerman
akkerman / NASA Picture-Of-The-Day Wallpaper Script
Last active October 16, 2024 05:21 — forked from curiousleo/NASA Picture-Of-The-Day Wallpaper Script
A BASH script to download NASA's picture of the day (http://apod.nasa.gov/apod/astropix.html) automatically saving and setting as wallpaper and saving optional description of image to text.
#!/bin/bash
# Copyright (c) 2011 Josh Schreuder
# http://www.postteenageliving.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@akkerman
akkerman / fp-recipes.js
Last active June 14, 2021 08:06
functional javascript recipes
// transform array of objects to a dictionary object
const dict = arr => arr.reduce((result, item) => ({ ...result, [item.id]: item }), {}) // empty object as start value
// flatten an array of arrays
const flattened = arr => arr.reduce((result, arr) => result.concat(arr), []) // empty array as start value
// check if all elements in an array are in a source array
const hasAll = source => arr => arr.every(item => source.includes(item))
// check if any element in an array is in a source array
@akkerman
akkerman / debounce.js
Last active April 4, 2018 09:25 — forked from nmsdvid/new_gist_file.js
Simple JavaScript Debounce Function
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
clearTimeout(timeout);