Skip to content

Instantly share code, notes, and snippets.

@NicholasBallard
NicholasBallard / txt2rtf.sh
Created June 12, 2018 16:50 — forked from gildotdev/txt2rtf.sh
Simple Bash script to create a rich text format file from a plain text file
#!/bin/sh
#check to see if arguments are set
E_BADARGS=65
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` textfilename [rtffilename optional]"
exit $E_BADARGS
fi
import os
import pandas as pd
import xlsxwriter
from xlsxwriter.utility import xl_col_to_name
def set_column(df: 'dataframe', worksheet: 'a pd.Excelwriter sheet', cols: list, format: 'excel format to use', col_width: int = None) -> None:
""" sets column by index, the column's position in the dataframe """
idx = [df.columns.get_loc(c) for c in cols if c in df]
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
email_user = 'your_email'
email_password = 'your_password'
email_send = 'recipient_email'
from abc import ABC, abstractmethod
import os
import sys
import time
import pandas as pd
from helper_functions import (
connectdbmethod,
toUtcDay,

How to Log In to an EC2 Instance Using SSH

Save your key pair downloaded from the EC2 accounts page for the server instance to your local machine.

Save the file in a readily accessible place on your disk. I like saving keys in a directory called keys in my root.

PEMFILE=/path/to/pem/file.pem
mkdir -p /c/keys
mv $PEMFILE /c/keys

The team's machine is assuming a default encoding when opening the CSV in an editor, then on save is replacing non-ASCII characters with ? placeholders.

Explanation: Emojis are 2 4-bit characters... 2*4 = 8 bits, that's why it's UTF-8, meaning Unicode Text Format 8-bit. It's a newer format, machines will often assume ASCII characters (a-zA-Z0-9!@#$%^&*()_+, etc.)

Here is the Excel program on my machine defaulting to an ASCII format when opening a CSV:

image

Since I'm not opening the CSV file in a text editor defaulting to UTF-8 support, the program will have an algorithm to replace sequences of bits it doesn't understand. In the case of emojis, like the smiley face 😀, what the machine sees is actually the tear-jerking sequence of bits as follows: \U0001f604, which is actually two blocks of sequences (that make up the UTF-8 character). If I were to open the text file in a program that expects UTF-8 characters by default, like Visual Studio Code, it would

@NicholasBallard
NicholasBallard / saveTextUsingSpreadsheetsSafely.md
Last active October 25, 2019 19:39
How to import text into spreadsheet programs without changing the underlying bytes of the file.

Directions for Saving Files from the Oracle Bronto Portal

In the Bronto portal: clipboard

File saved to computer as a text file (csv): clipboard

We can see the encoding is correctly UTF-8 and the non-ASCII characters (the emojis) are preserved:

<#
chocopkgs.ps1
Install packages listed in variable $packages on a Windows machine in Powershell (Administrator)
#>
$packages = @"
audacity
autohotkey.install
awscli
choco install --confirm audacity autohotkey.install awscli azure-cli chromedriver colortool conemu dart-sdk docker-desktop everything ffmpeg filezilla firacode firefox git googlechrome jq jre8 microsoft-windows-terminal mysql mysql.workbench nodejs nvm pgadmin4 postgresql postman pritunl-client python quicklook sgt-puzzles steam tor-browser treesizefree vim virtualbox vlc vscode wget youtube-dl zeal.portable typora

Crontab is Beautiful

Nicholas Ballard


AWS Lambda. Azure Functions. Firebase Functions. Cloud Run. Serverless. Docker. Kubernetes. Hakuna Matata.

We're swimming in a world of great hosted options for scheduling and automating our software programs.