This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# /opt/scripts/tree-gitignore.sh | |
# Author: Nestor Urquiza | |
# Date: 20240220 | |
# Description: A tree wrapper to show contents of a git project respecting .gitignore | |
# Usage: cd git-project && /opt/scripts/tree-gitignore.sh | |
cmd="tree -a -I '.git'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# clichatgpt.py | |
# | |
# A CLI script to interact with ChatGPT via API | |
# | |
# Nestor Urquiza 20230512 | |
# | |
import sys | |
import openai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let us consider the following typical mysql backup script: | |
mysqldump --routines --no-data -h $mysqlHost -P $mysqlPort -u $mysqlUser -p$mysqlPassword $database | |
# It succeeds but stderr will get: | |
# Warning: Using a password on the command line interface can be insecure. | |
# You can fix this with the below hack: | |
credentialsFile=/mysql-credentials.cnf | |
echo "[client]" > $credentialsFile | |
echo "user=$mysqlUser" >> $credentialsFile | |
echo "password=$mysqlPassword" >> $credentialsFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# ubuntu-install-xrdp.sh | |
# Tested in Ubuntu 20.04: Bidirectional clipboard does work. | |
# | |
# One line installer (change ubuntu by the username that you want to remotely login): | |
# curl -L https://gist.github.com/nestoru/fee24a59804d60ccba1a/raw | sudo bash -s ubuntu | |
# | |
START=$(date +%s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# mongo-collection-to-csv.sh | |
# | |
# description: Exports all field from any mongodb collection to CSV | |
# author: Nestor Urquiza | |
# date: 20210218 | |
# env vars | |
password=$MONGODB_PWD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
smarthost=mail.sample.com | |
user=me | |
alertlist=alert@mail.sample.com | |
/opt/csw/bin/gsed -i "s/^DS[\s]*.*/DS $smarthost/g" /etc/mail/submit.cf | |
/opt/csw/bin/gsed -i "s/^DS[\s]*.*/DS $smarthost/g" /etc/mail/sendmail.cf | |
/opt/csw/bin/gsed -i "/$user:/d" /etc/mail/aliases | |
echo "$user:$alertlist" >> /etc/mail/aliases | |
/opt/csw/bin/gsed -i "/root:/d" /etc/mail/aliases | |
echo "root:$alertlist" >> /etc/mail/aliases | |
newaliases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir=$1 | |
while true; do sleep 5; [ ! -z "$(ls $dir)" ] && date && ls -alrt $dir; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mongo 3 | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv BC711F9BA15703C6 | |
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3-4.list | |
sudo apt-get update | |
sudo apt-get install -y mongodb-org=3.0.16 mongodb-org-server=3.0.16 mongodb-org-shell=3.0.16 mongodb-org-mongos=3.0.16 mongodb-org-tools=3.0.16 | |
echo "mongodb-org hold" | sudo dpkg --set-selections | |
echo "mongodb-org-server hold" | sudo dpkg --set-selections | |
echo "mongodb-org-shell hold" | sudo dpkg --set-selections | |
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections | |
echo "mongodb-org-tools hold" | sudo dpkg --set-selections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo systemd-resolve --flush-caches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# One liner to find processes that have been running for over any amount of seconds | |
SECONDS=$1 | |
ps -e -o "pid,etimes,command" | awk '{if($2>$SECONDS) print $0}' | |
: ' | |
Explanation: | |
=========== | |
ps: process snapshot command | |
-e: list all processes | |
-o: include only specified columns |
NewerOlder