Skip to content

Instantly share code, notes, and snippets.

View cmfcruz's full-sized avatar
:octocat:
Mostly at work

Carlo Miguel Cruz cmfcruz

:octocat:
Mostly at work
View GitHub Profile
@cmfcruz
cmfcruz / listening_ports.sh
Created September 1, 2021 14:29
Script to check for listening ports without using `netstat`
#!/bin/sh
# Source: https://staaldraad.github.io/2017/12/20/netstat-without-netstat/
awk 'function hextodec(str,ret,n,i,k,c){
ret = 0
n = length(str)
for (i = 1; i <= n; i++) {
c = tolower(substr(str, i, 1))
k = index("123456789abcdef", c)
@cmfcruz
cmfcruz / keybase.md
Created May 26, 2020 03:02
Keybase Proof

Keybase proof

I hereby claim:

  • I am cmfcruz on github.
  • I am cmfcruz (https://keybase.io/cmfcruz) on keybase.
  • I have a public key ASDypS-fpVtc8lOfdCeE_ns8idwFxBXt-qrN1FkhP6A6kgo

To claim this, I am signing this object:

@cmfcruz
cmfcruz / pre-commit.sh
Last active December 10, 2018 10:22
Automatically increment bugfix version in a version file within the code. Create a version file if non exists. This is to have a version reference separate from git branching.
#!/bin/bash
# This script automatically updates the version number in the version.txt file
# if there are updated files during the commit.
# Enable this script using the following command:
# mv -f pre-commit.sh .git/hooks/pre-commit && chmod u+x .git/hooks/pre-commit
version_file=build.info
if [ `git diff --cached --name-only | wc -l` -gt 0 ]
then
@cmfcruz
cmfcruz / prepare-for-ami.sh
Last active November 23, 2019 11:57 — forked from garlandkr/ami-clean.sh
Clean-up an Amazon Linux EC2 instance before creating an AMI
#!/bin/bash
# Run this script using the ec2-user with:
# sudo bash <(curl -s https://gist.github.com/cmfcruz/75b29d12740f8916006c10e48ea33bc1/raw/ami-clean.sh)
function print_green {
echo -e "\e[32m${1}\e[0m"
}
function print_red {