Skip to content

Instantly share code, notes, and snippets.

View apolopena's full-sized avatar
💭
We live to learn!

Apolo Pena apolopena

💭
We live to learn!
View GitHub Profile
@apolopena
apolopena / life_wisdom_poem.js
Last active March 24, 2022 05:33
Life Wisdom: A compilable programatic poem in Javascript by Apolo Pena
/* -------------------------------------------------------------------------------------------
* ----Life Wisdom: A compilable programatic poem in Javascript by Apolo Pena, March 23rd 2019-----
----------------------------------------------------------------------------------------------- */
const/*antly*/ life= /*is a*/ new Array( /*of*/ Math.Infinity );
let Life = true, always=(do_no_harm)=>{with(life){return ['always rememberring LOVE']};};
const antly_be_as_IS = 'forever living in the present moment.';
let love_of_life={Be:('rich'&'meaningful'),abundant:(''&'prosperous'),
and:'remember.',
In:{life:{always:'',breathe:'consciously',in:(''&'out!')}}},
and; var iably; let consciousness=/*be an*/Array.from(love_of_life), when =()=>{}, forward = true;
@apolopena
apolopena / is_long_option.sh
Created March 21, 2022 22:34
Bash function to validate a long option
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2022 Apolo Pena
### is_long_option ###
# Description:
# Validates a long option using the below rules
# Returns 0 if $1:
# Starts with double dashes followed by any number of uppercase or lowercase letters or integers
@apolopena
apolopena / capture-lolcat-raw-colors.md
Last active November 23, 2024 01:22
Capture a raw dump of lolcat colorized output (for a script or a command) that includes the ANSI escape sequences for the colors.

The Need

  • You need a raw dump of lolcat colorized output that includes the ANSI escape sequences for the colors.
  • You need this dump saved to a file.

The Solution

Pipe your output through lolcat, use the --force flag and then redirect the output to a file.

Examples

  1. Capture a raw dump of the output of a bash script piped through lolcat to the file colors.txt
  • bash my-script.sh | lolcat --force > colors.txt
@apolopena
apolopena / gitpod_gpg.sh
Last active February 4, 2022 20:47
Enable, configure and optionally trust a GPG key for signing git commits
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2022 Apolo Pena
#
# gitpod_gpg.sh
# Description:
# Enable, configure and optionally trust a GPG key for signing git commits
#
# Notes:
@apolopena
apolopena / badips.sh
Last active August 19, 2021 01:29
Dump or report on unauthorized server access attempts. Requires sudo.
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
#
# File: badips.sh
# Author: Apolo Pena
# Description:
# Dumps a unique list of unauthorized ips to a file,
# or reports information to stdout about the unauthorized attempts
@apolopena
apolopena / tmux-named-sessions.sh
Created August 6, 2021 22:10
Creates new (or attaches to existing) tmux sessions using an '.icon' file. This script can be called from inside or outside of tmux
#!/bin/bash
#
# SPDX-License-Identifier: MIT
# Copyright © 2021 Apolo Pena
#
# tmux-named-sessions.sh
# Description:
# Creates new tmux sessions using an '.icon' file
# The .icon file is an text file next to this script with an emoji in it
# This script can be called from inside or outside of tmux
@apolopena
apolopena / tmux-fortunes-poc.sh
Created August 6, 2021 20:15
tmux proof of concept for opening up a split pane window session with a series of synchronized commands
#!/bin/bash
#
# proof of concept: scripted tmux
# opens a 2 pane tmux session with rainbows fortunes
# marks the window status red because the panes are synchronized
# and then closes it all down
main() {
tmux new-session \;\
setw -g window-status-current-format '#{?pane_synchronized,#[bg=red],}#I:#W' \;\
@apolopena
apolopena / new-repo-from-repo.sh
Last active February 4, 2022 21:26
Create a new repository from an existing repository. Wipes out git history.
# shellcheck shell=bash
# shellcheck disable=2001
#
# If using this as zsh function snippet, remove the .sh file extension
#
# Creates a new repository from an existing repository
# All git history is removed
# $1: git url of the original repository to use to create a new repository from
# $2: name of the new repository including the github user name. This repository must already exist in github.
# For example: apolopena/gitpod-laravel-starter
@apolopena
apolopena / new-repo-from-branch.sh
Last active February 4, 2022 21:34
Create a new repository from the branch of an existing one. Wipe out git history.
# shellcheck shell=bash
# shellcheck disable=2001
#
# If using this as zsh function snippet, remove the .sh file extension
# Creates a new repository from the branch of an existing repository
# All git history is removed
# $1: git url of the original repository to use to create a new repository from
# $2: branch name of the original repository to use
# $3: name of the new repository including the github user name. This repository must already exist in github.
@apolopena
apolopena / new-lgs-from-branch
Last active April 23, 2021 15:57
zsh function snippet to setup a local and remote github repository from a branch using `gitpod-laravel-starter` as the starting point
# zsh function snippet
#
# Creates a new project from a branch of the repo https://github.com/apolopena/gitpod-laravel8-starter
# Assumes that you already have a blank repo for this project created in your github account
# Assumes that you want to use https instead of ssh
# $1: branch name to clone from
# $2: new repo name to clone into and push to remote (the default branch will be called main)
# new repo name must match the name of the blank repo you have created in github for this project.
# $3: GitHub username