Skip to content

Instantly share code, notes, and snippets.

View megahertz's full-sized avatar
:electron:

Alex Prokhorov megahertz

:electron:
  • Thailand
  • 06:16 (UTC +07:00)
View GitHub Profile
@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 January 14, 2026 09:48
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
docker run --init -it --rm \
-v "$(pwd):$(pwd)" -w "$(pwd)" \
-v "$HOME/.claude:/home/agent/.claude" \
-v "$HOME/.claude.json:/home/agent/.claude.json" \
-e GIT_AUTHOR_NAME="$(git config user.name)" \
-e GIT_AUTHOR_EMAIL="$(git config user.email)" \
-e TERM=xterm-256color \
-e COLORTERM=truecolor \
@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: {