Skip to content

Instantly share code, notes, and snippets.

@jefrydco
jefrydco / mypostgres.sh
Created January 21, 2019 02:03
Run PostgreSQL and pgAdmin4 on Docker with single command
#!/bin/bash
# Create postgres directory with pgvolume and pga4volume as child directory.
mkdir -p postgres/{pgvolume,pga4volume}
# Navigate to postgres directory
cd postgres
# Create pg.env that holds environment variable for postgres docker container.
cat << EOF > pg.env
@takvol
takvol / gist:0a0dd9b089314bc5463eaf6af83fa060
Last active January 27, 2025 00:04 — forked from siygle/gist:9678772
Parse Gmail Inbox to sheet
function extractData(data, startStr, endStr) {
// This function extracts text between two strings
// i.e. extractData("Good_news,_everyone!", "Good_", ",_Everyone!") will return "News"
var startIndex, endIndex, text = 'N/A';
startIndex = data.indexOf(startStr);
if(startIndex != -1) {
startIndex += startStr.length;
text = data.substring(startIndex);
@robsonke
robsonke / checkDockerDisks.sh
Last active September 30, 2024 09:34
This Bash script will loop through all running docker containers on a host and list the disk usage per mount. In case it's breaching the 65%, it will email you.
#!/bin/bash
# get all running docker container names
containers=$(sudo docker ps | awk '{if(NR>1) print $NF}')
host=$(hostname)
# loop through all containers
for container in $containers
do
echo "Container: $container"
@mogsdad
mogsdad / Apps Script pdfToText utility.md
Last active May 4, 2025 09:00
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);
    
@siygle
siygle / gist:9678772
Created March 21, 2014 03:12
Parse Gmail Inbox to sheet
function processInboxToSheet() {
//var threads = GmailApp.getInboxThreads();
// Have to get data separate to avoid google app script limit!
var start = 0;
var threads = GmailApp.getInboxThreads(start, 100);
var sheet = SpreadsheetApp.getActiveSheet();
var result = [];
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
@mogsdad
mogsdad / Google Apps Script Survey Workflow.md
Last active August 1, 2022 07:48
Google Apps Script workflow for an email survey. Written in response to StackOverflow question 18668828. http://stackoverflow.com/a/18669532/1677912

Google Apps Script Survey Workflow

The components involved in this workflow are:

  • A script to generate and send an email with an HTML form.
  • An html template for that email, which allows us to customize the email for each recipient.
  • A doPost() function to handle responses. The script must be [deployed as a Web App][1].
  • A spreadsheet to collect responses. The script will be contained in the spreadsheet, and extends the spreadsheet UI with a menu for sending a copy of the survey. (It could be adapted for standalone use, without the UI component.)

Here is an example of such a workflow, conducting a Commuting Survey. Recipients will receive a survey email like this: