Skip to content

Instantly share code, notes, and snippets.

View funkyfisch's full-sized avatar

Ioannis Gkikas funkyfisch

  • Gothenburg, SE
View GitHub Profile
# get local ip address provided by either DHCP or static setting
ifconfig enp4s0 | grep 'inet ' | awk '{print $2}'
blueprint:
domain: automation
name: Low battery detection & notification for all battery sensors
description: >-
Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action.
***Blueprint Revision:*** *7 / 2023-01-04*
source_url: https://gist.github.com/itn3rd77/2cc639b6b903844e03bf6b58f2959795
input:
@funkyfisch
funkyfisch / run-query.sh
Created February 13, 2021 22:16
Storing readable requests in text files and consuming them with curl
#!/bin/bash
curl $(tr --delete '\n' < sample-request.txt) -o response.html

Commands

cd $(git rev-parse --show-toplevel) # navigates to the root directory of a repo/submodule.
cd $(git rev-parse --git-dir) # navigates to the .git directory.
cd $(git rev-parse --show-superproject-working-tree) # if in a submodule, navigates to the root of the parent.

Aliases

# given a remote branch (for a PR or MR) check it out locally and track it
@funkyfisch
funkyfisch / push_1to1.sh
Created April 19, 2020 22:07
How to push 1-1 local-remote branches for pull/merge requests
#!/bin/bash
git push origin $(git rev-parse --abbrev-ref HEAD)
@funkyfisch
funkyfisch / delete_local_branches.sh
Created April 19, 2020 22:01
How to delete all local git branches apart from master
#!/bin/bash
git checkout master \
&& git for-each-ref --format='%(refname:short)' refs/heads/ \
| grep -v "^master$" \
| xargs git branch -D
@funkyfisch
funkyfisch / migrate-docker-volume.sh
Last active January 16, 2024 12:01
Migrate a docker volume from one host to another
#!/bin/bash
# Environment check
# If migrating from localhost, set this to localhost
if [[ ! $SOURCE_HOST_ADDRESS ]]
then
echo "Please set the current host address in SOURCE_HOST_ADDRESS"
exit 1
fi
@funkyfisch
funkyfisch / change_notify_watchers.sh
Created February 23, 2019 15:32
ENOSPC resolution for file watchers
#!/bin/sh
# Change the maximum amount of watchers and persist the setting
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
# Arch Linux alternative command
# echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.d/99-sysctl.conf
# Details: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details