Skip to content

Instantly share code, notes, and snippets.

@mattmc3
mattmc3 / optparsing_demo.zsh
Last active July 13, 2026 23:45
Zsh option parsing example
# Manual opt parsing example
#
# Features:
# - supports short and long flags (ie: -v|--verbose)
# - supports short and long key/value options (ie: -f <file> | --filename <file>)
# - supports short and long key/value options with equals assignment (ie: -f=<file> | --filename=<file>)
# - does NOT support short option chaining (ie: -vh)
# - everything after -- is positional even if it looks like an option (ie: -f)
# - once we hit an arg that isn't an option flag, everything after that is considered positional
function optparsing_demo() {
@zachlagden
zachlagden / error_handling.py
Last active December 9, 2022 21:55
pycord - Error handling useful code, because noone can remember everything :)
"""
Copyright (c) 2022, Zach Lagden
All rights reserved.
"""
import discord
from discord.ext import commands
from datetime import datetime
import coloredlogs

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@eddy-22
eddy-22 / ve.sh
Last active June 14, 2021 02:15 — forked from erszk/ve.sh
[VE.sh] virtualenv wrapper in bash #virtualenv #shell
# -*- mode: sh -*-
# vim: syn=sh
# check to make sure virtualenv installed
if ! command which -s virtualenv; then
>&2 echo "You don't have virtualenv installed in your path. To install it:"
>&2 echo "pip install virtualenv"
return 1
fi
@aelk00
aelk00 / remove-likes.md
Last active March 1, 2024 00:58
Remove all your facebook likes
@br3ndonland
br3ndonland / github-actions-notes.md
Last active May 30, 2026 00:06
Getting the Gist of GitHub Actions
@bynect
bynect / bot.py
Last active April 17, 2025 22:34
Simple and effective example of bot and cogs made with discord.py (rewrite).
"""
This example bot is structured in multiple files and is made with the goal of showcasing commands, events and cogs.
Although this example is not intended as a complete bot, but as a reference aimed to give you a basic understanding for
creating your bot, feel free to use these examples and point out any issue.
+ These examples are made with educational purpose and there are plenty of docstrings and explanation about most of the code.
+ This example is made with Python 3.8.5 and Discord.py 1.4.0a (rewrite).
Documentation:
@htr3n
htr3n / macos-ramdisk.md
Last active July 15, 2026 14:34
Creating RAM disk in macOS

Built-in

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://XXXXX`

where XXXXX is the size of the RAM disk in terms of memory blocks.

Notes:

@bzerangue
bzerangue / json-to-ndjson.md
Last active July 20, 2026 02:52
JSON to NDJSON

NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.

  • Each line is a valid JSON value
  • Line separator is ‘\n’

1. Convert JSON to NDJSON?

cat test.json | jq -c '.[]' > testNDJSON.json
@yiminglin-ai
yiminglin-ai / install_zsh.sh
Last active April 8, 2026 00:16
compile zsh from scratch
# Installs Zsh with Oh-My-Zsh without root privileges
#
# Instructions
# 1) bash install_zsh.sh
# 2) edit .zshrc and add the path to your Zsh binary to the PATH variable
# 3) add `set-option -g default-shell <path to zsh>/bin/zsh` to `~/.tmux.conf`
#
# References: https://www.drewsilcock.co.uk/compiling-zsh
#
# ## Ncruses