Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
sebastiancarlos / sed-commands-cheat-sheet.csv
Last active July 3, 2023 05:14
GNU sed commands cheat sheet
Command Output Stream Pattern Space Hold Space Jump to
= print line number
a TEXT queue printing TEXT after the default print
r FILENAME queue printing content of FILENAME after the default print
R FILENAME queue printing a line of FILENAME after the default print
i TEXT print TEXT
c TEXT print TEXT delete end-of-cycle
d delete end-of-cycle
D delete first line beginning of cycle (or end-of-cycle if 'Pattern Space' is empty)
e run 'Pattern space' as shell command and replace with output
@sebastiancarlos
sebastiancarlos / get_authors.sed
Last active June 8, 2023 05:38
Sample sed script
#n <- run sed in -n mode
# This sed script operates on a list of books in the format:
# Title
# Author
# Rating (1 to 5 asterisks)
# --- (separator)
# Is returns every author who has written a book with 'the'
@sebastiancarlos
sebastiancarlos / library.txt
Created June 8, 2023 05:39
Sample to be used with the sed script get_authors.sed
Moby Dick
Herman Melville
****
---
The Da Vinci Code
Dan Brown
***
---
Puns and Paronomasias
Albert Winesthein
@sebastiancarlos
sebastiancarlos / wiobe_index.csv
Last active June 10, 2023 16:25
WIOBE Index - June 2023 - A measure of popularity of programming languages by their Wikipedia page size (in kilobytes). Generated with https://gist.github.com/sebastiancarlos/e49ae62f9e1ca97f1b2e4ecfe78fd261
Size of Wikipedia Page (Kilobytes) Programming Language Wikipedia Page Link
612 PHP https://en.wikipedia.org/wiki/PHP
576 Python https://en.wikipedia.org/wiki/Python_(programming_language)
524 COBOL https://en.wikipedia.org/wiki/COBOL
476 Rust https://en.wikipedia.org/wiki/Rust_(programming_language)
452 PowerShell https://en.wikipedia.org/wiki/PowerShell
432 APL https://en.wikipedia.org/wiki/APL_(programming_language)
428 Scala https://en.wikipedia.org/wiki/Scala_(programming_language)
428 Perl https://en.wikipedia.org/wiki/Perl
424 JavaScript https://en.wikipedia.org/wiki/JavaScript
@sebastiancarlos
sebastiancarlos / wiobe_index.sh
Last active June 10, 2023 16:24
Script to generate the world-famous WIOBE Index of programming languages.
#! /usr/bin/env bash
# WIOBE Index - Memeing the TIOBE Index since June 2023
# - A measure of popularity of programming languages by their Wikipedia page size (in kilobytes)
# - Find the WIOBE Index here: https://gist.github.com/sebastiancarlos/4940d24af353fdf3a2f59aed49314048
# Blocklist: a list of programming languages that we dont want to include
# - because their linked wikipedia page is not actually for the language itself but for the platform that includes it.
# - because they are duplicates from other language with the same page.
# - because they are not programming languages.
@sebastiancarlos
sebastiancarlos / color_popd.sh
Last active January 7, 2024 12:52
Add colors to pushd, popd, and dirs bash commands! 🧑🏻‍🎨
# All my gist code is licensed under the terms of the MIT license.
# Copy this into your .bashrc or something like that.
# custom dirs
# - default to 'dirs -v' format and colorize the output
function dirs () {
# if no arguments, or single argument is -v or -c, then colorize
if [ $# -eq 0 ] || { [ $# -eq 1 ] && { [ "$1" = "-v" ] || [ "$1" = "-c" ]; }; }; then
# if argument is -c, run it (clear stack)
@sebastiancarlos
sebastiancarlos / localenv.sh
Last active January 7, 2024 12:51
localenv - print only the variables defined in your current shell
# All my gist code is licensed under the terms of the MIT license.
# put this in your .bashrc or something like that
# localenv
# print only the environment variables that were added
# since the shell was started
function localenv () {
# this is done by comparing the output of 'set' in the current
# shell with the output of 'set' in a new shell.
@sebastiancarlos
sebastiancarlos / color-shopt.sh
Last active August 23, 2023 12:05
Fix column output on bash's shopt, and add color
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=bNITSDWht6w
# add to your .bashrc or something like that
# custom shopt
# It pipes into column -t if there are no arguments,
# because the default with broken lines is not very readable.
# And while I'm at it, make 'on' green and 'off' red.
@sebastiancarlos
sebastiancarlos / shelloptions.sh
Last active December 15, 2024 18:42
shelloptions - combine output of "set -o" and "shopt", thereby showing all Bash options in one place
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=eN4_nmREzCQ
# copy this to your .bashrc or something like that
# shelloptions
# combine output of "bind -V", "set -o" and "shopt", thereby showing all shell
# options in one place. Display nicely with color and column alignment.
#
@sebastiancarlos
sebastiancarlos / color-stty.sh
Last active August 23, 2023 12:03
Custom version of stty with table output and color
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/shorts/7rEHZPfJwYU
# custom stty
# - color and table formatting
function stty () {
# only proceed if called with:
# - no arguments
# - only -a