Skip to content

Instantly share code, notes, and snippets.

View jose-neta's full-sized avatar

José Neta jose-neta

View GitHub Profile
#!/usr/bin/env python3
import asyncio
import time
import aiohttp
START = time.monotonic()
export const life=42
@jose-neta
jose-neta / sign.sh
Created March 1, 2022 09:12 — forked from ezimuel/sign.sh
Sign and verify a file using OpenSSL command line tool. It exports the digital signature in Base64 format.
#!/bin/bash
# Sign a file with a private key using OpenSSL
# Encode the signature in Base64 format
#
# Usage: sign <file> <private_key>
#
# NOTE: to generate a public/private key use the following commands:
#
# openssl genrsa -aes128 -passout pass:<passphrase> -out private.pem 2048
# openssl rsa -in private.pem -passin pass:<passphrase> -pubout -out public.pem
@jose-neta
jose-neta / markdown-to-email
Created February 23, 2022 14:34 — forked from cleverdevil/markdown-to-email
markdown-to-email A simple script to send beautifully formatted emails that you write in Markdown. The email will have an HTML payload and a plain-text alternative, so you'll make everyone happy, including yourself.
#!/usr/bin/env python
'''
Send an multipart email with HTML and plain text alternatives. The message
should be constructed as a plain-text file of the following format:
From: Your Name <your@email.com>
To: Recipient One <recipient@to.com>
Subject: Your subject line
---
id,first_name,last_name,email,gender,ip_address
1,Mirelle,McMichael,mmcmichael0@ted.com,Female,136.70.202.209
2,Gerald,Lornsen,glornsen1@ifeng.com,Polygender,133.2.35.171
3,Kelbee,Wailes,kwailes2@is.gd,Agender,45.208.130.34
4,Wernher,Pietersen,wpietersen3@house.gov,Genderqueer,53.244.101.8
5,Arnuad,Chaperlin,achaperlin4@constantcontact.com,Male,73.225.93.164
6,Salvidor,Dumsday,sdumsday5@ocn.ne.jp,Polygender,182.71.35.12
7,Danella,Britland,dbritland6@wordpress.org,Male,192.219.147.127
8,Tod,Gleed,tgleed7@symantec.com,Non-binary,182.179.22.80
9,Dale,Elvins,delvins8@bloglines.com,Polygender,132.214.85.23

Let's say you have a Bash shell script, and you need to run a series of operations on another system (such as via ssh). There are a couple of ways to do this.

First, you can stage a child script on the remote system, then call it, passing along appropriate parameters. The problem with this is you will need to manually keep the remote script updated whenever you change it -- could be a bit of a challenge when you have something to execute on a number of remote servers (i.e., you have a backup script running on a central host, and it needs to put remote databases in hot backup mode before backing them up).

Another option is to embed the commands you want to run remotely within the ssh command line. But then you run into issues with escaping special characters, quoting, etc. This is ok if you only have a couple commands to run, but if it is a complex piece of Bash code, it can get a bit unwieldy.

So, to solve this, you can use a technique called rpcsh -- rpc in shell script, as follows:

First, place th

@jose-neta
jose-neta / bash.generate.random.alphanumeric.string.sh
Created October 30, 2020 12:16 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
#!/usr/bin/env sh
VBOX_LATEST_VERSION=$(curl http://download.virtualbox.org/virtualbox/LATEST.TXT)
wget -c http://download.virtualbox.org/virtualbox/${VBOX_LATEST_VERSION}/VBoxGuestAdditions_${VBOX_LATEST_VERSION}.iso -O /tmp/VBoxGuestAdditions_${VBOX_LATEST_VERSION}.iso
sudo mkdir -p /media/guestadditions ; sudo mount -o loop /tmp/VBoxGuestAdditions_${VBOX_LATEST_VERSION}.iso /media/guestadditions
sudo /media/guestadditions/VBoxLinuxAdditions.run
sudo umount /media/guestadditions && sudo rm -rf /tmp/VBoxGuestAdditions_$VBOX_VERSION.iso /media/guestadditions
echo 'You may safely ignore the message that reads: "Could not find the X.Org or XFree86 Window System."'
@jose-neta
jose-neta / Activate Office 2019 for macOS VoL.md
Created September 27, 2020 14:49 — forked from zthxxx/Activate Office 2019 for macOS VoL.md
crack activate office on mac with license file

Activate MS Office 2019/2016 for macOS - Microsoft_Office_2019_VL_Serializer

Office 2019 above

2019-06-03

Note that Office2019 DO NOT support activate via simple copy/paste plist license file which is the simplest way to activate Office 2016. Fortunately, you can also use the VL Serializer tool, just install Office 2019 and Serializer, then run Serializer to activate.

Ref