Skip to content

Instantly share code, notes, and snippets.

View megahertz's full-sized avatar
:electron:

Alex Prokhorov megahertz

:electron:
  • Thailand
  • 03:54 (UTC +07:00)
View GitHub Profile
@megahertz
megahertz / slack-tray
Last active October 10, 2026 15:49
KDE Plasma 6: hide the Slack tray icon on weekends (Fri 17:00 – Mon 05:00)
#!/usr/bin/env bash
# slack-tray [show|hide] — without an argument: hidden from Fri 17:00 to Mon 05:00
set -euo pipefail
id=Slack_status_icon_1
read -r dow hour < <(date '+%u %-H')
if (( dow >= 6 || (dow == 5 && hour >= 17) || (dow == 1 && hour < 5) )); then
auto=hide
else
auto=show
@megahertz
megahertz / docker-gemini
Last active May 13, 2026 12:37
There's a `docker sandbox run gemini` command, but it requires Docker Desktop to be installed, which is pretty undesirable on Linux since it replaces Docker Engine with a VM environment. This simple script does similar things.
#!/usr/bin/env bash
set -e
image='docker-gemini'
case "$1" in
-h|--help)
echo 'Usage: docker-gemini [options] [command] [prompt]'
echo 'docker-gemini commands:'
@megahertz
megahertz / docker-codex
Last active May 13, 2026 12:37
There's a `docker sandbox run codex` command, but it requires Docker Desktop to be installed, which is pretty undesirable on Linux since it replaces Docker Engine with a VM environment. This simple script does similar things.
#!/usr/bin/env bash
set -e
image='docker-codex'
docker_args=()
case "$1" in
-h|--help)
echo 'Usage: docker-codex [options] [command] [prompt]'
@megahertz
megahertz / git-unbranch
Created January 21, 2026 02:19
Removes any local branches except for main/master and pulls the latest changes from the origin. It's helpful to run once a feature has been merged
#!/usr/bin/env sh
set -e
master_names='main|master'
branch_regexp='s/[^A-Za-z0-9_\/-]*//g'
master_branch="$(git branch | grep -E "${master_names}" | sed "${branch_regexp}" | head -n 1)"
branches="$(git branch | grep -v -E "${master_names}" | sed "${branch_regexp}")"
@megahertz
megahertz / docker-claude
Last active May 13, 2026 12:36
There's a `docker sandbox run claude` command, but it requires Docker Desktop to be installed, which is pretty undesirable on Linux since it replaces Docker Engine with a VM environment. This simple script does similar things.
#!/usr/bin/env bash
set -e
image='docker-claude'
docker_args=()
case "$1" in
-h|--help)
echo 'Usage: docker-claude [options] [command] [prompt]'
@megahertz
megahertz / mongo-url.sh
Created February 28, 2018 04:10
Parse MongoDB connection string in bash
#!/usr/bin/env bash
set -e
# Usage: parse_mongo_url URL
# It sets the following variables:
# MONGO_HOST
# MONGO_PORT
# MONGO_DATABASE
# MONGO_USER
# MONGO_PASSWORD
@megahertz
megahertz / MobxRnnProvider.js
Last active January 11, 2020 09:56
This is a provider which allows to use mobx-react Provider with wix/react-native-navigation.
import { Provider } from 'mobx-react/native';
const SPECIAL_REACT_KEYS = { children: true, key: true, ref: true };
export default class MobxRnnProvider extends Provider {
props: {
store: Object
};
context: {