Skip to content

Instantly share code, notes, and snippets.

View DrJume's full-sized avatar

Julian Meinking DrJume

View GitHub Profile
#!/bin/bash
pmset -g custom | sed -nE -e '/Battery Power/,/AC Power/p' | sed -e '1d' -e '$d' | sort > battery.pmset
pmset -g custom | sed -nE -e '/AC Power/,$p' | sed '1d' | sort > ac.pmset
sdiff <(echo "Battery Power:"; cat battery.pmset) <(echo "AC Power:"; cat ac.pmset)
@DrJume
DrJume / karabiner_complex_mods_drjume.json
Last active February 10, 2022 14:18
DrJume Karabiner-Elements complex modifications
{
"title": "DrJume Karabiner-Elements complex modifications (v2.1)",
"rules": [
{
"description": "Spacebar: Hold and combine with HJKL for vi movement keys",
"manipulators": [
{
"conditions": [
{
"name": "spacebar pressed",
@DrJume
DrJume / avit-lambda.zsh-theme.patch
Created October 29, 2021 23:31
OhMyZsh avit theme with git remote status & lambda
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 1e20d8f9..4bcd54a0 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -5,12 +5,19 @@ 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} $(git_prompt_info) $(ruby_prompt_info)
@DrJume
DrJume / update.sh
Last active October 29, 2021 07:53
Interactive update script
#!/bin/bash
last_check=''
skip_next_confirm="false"
function skipNextConfirm {
skip_next_confirm="true"
return 0
}
@DrJume
DrJume / Set_DNS_servers_for_active_network_interface.bat
Last active October 14, 2021 12:04
Windows set/reset DNS servers for active network interface
@echo off
FOR /F "tokens=* USEBACKQ" %%F IN (`powershell "Get-NetRoute -DestinationPrefix '0.0.0.0/0', '::/0' | Sort-Object -Property { $_.InterfaceMetric + $_.RouteMetric } | Select-Object -First 1 | %% {$_.ifIndex}"`) DO (
SET mainIfIndex=%%F
)
ECHO %mainIfIndex%
powershell "Set-DNSClientServerAddress -InterfaceIndex %mainIfIndex% -ServerAddresses ('1.1.1.1','1.0.0.1')"
powershell "Set-DNSClientServerAddress -InterfaceIndex %mainIfIndex% -ServerAddresses ('2606:4700:4700::1111','2606:4700:4700::1001')"
ipconfig /flushdns
@DrJume
DrJume / delete-traefik-acme-certificates.sh
Last active November 26, 2024 13:40
Select domains from traefik's acme.json to delete
#!/bin/bash
# tested with traefik v2.4.8
ACME_FILE="acme.json"
# get jq from https://stedolan.github.io/jq/
SELECTED_DOMAINS=$(jq -r '.letsencrypt.Certificates[].domain.main' "$ACME_FILE" | fzf -m --height '40%' --reverse --border)
if [[ -z "$SELECTED_DOMAINS" ]]; then
@DrJume
DrJume / cloudflare-zone-settings-overview.sh
Last active November 26, 2024 13:40
Cloudflare zone settings overview as table
#!/bin/bash
# parameters
CF_API_EMAIL=
CF_API_KEY=
# specify the id for a zone (domain)
# get it via the Cloudflare Dashboard
# of via flarectl: https://github.com/cloudflare/cloudflare-go/tree/master/cmd/flarectl
CF_ZONE=
@DrJume
DrJume / api-proxy-factory.js
Created May 17, 2021 16:29
JavaScript Proxy object for translating object property accesses to API call urls
/**
* @typedef API
* @property {object} users
* @property {()} users.getById
* @property {()} users.getByName
*/
/** @returns {API} */
function ProxyFactory() {
return Proxy({}, handler)
@DrJume
DrJume / applescript_open_terminal.md
Created December 10, 2020 05:58
AppleScript open terminal snippets
tell application "Terminal"
	do script "echo Hello world"
end tell
tell application "iTerm"
	set newWindow to (create window with default profile)
	tell current session of newWindow
@DrJume
DrJume / install-docs-apk.sh
Created November 7, 2020 08:20
Alpine script using ncurses dialog which helps with installing missing *-doc packages from apk
#!/bin/sh
[ ! -x "$(command -v dialog)" ] && ( apk add dialog || exit)
installed_pkgs=$(apk list -I -q | awk '{ print $1 }' | sed -E 's/(.+)(-[[:digit:]]).+/\1/')
installed_pkgs_doc=$(echo "$installed_pkgs" | grep "\-doc")
installed_pkgs_without_doc=$(echo "$installed_pkgs" | grep -v '\-doc')
installed_pkgs_append_doc=$(echo "$installed_pkgs_without_doc" | awk '{ print $0"-doc" }')