Skip to content

Instantly share code, notes, and snippets.

View mbierman's full-sized avatar

Michael Bierman mbierman

View GitHub Profile
@mbierman
mbierman / overdueCheck.js
Last active September 6, 2019 23:25
email based on past date
function overdueCheck() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Data");
// var values = sheet.getRange("J2:J").getValues();
var values = sheet.getRangeByName("FollowUp").getValues();
var today = new Date();
var todays = today.getTime();
var TO = "foo@domain.com";
var URL = "https://docs.google.com/spreadsheets/d/1hMZnkvsVE1B_9X37V-WH6o7dYmX_BoHxwP2YCY8DOWE/edit#gid=0";
@mbierman
mbierman / updateDate.js
Last active September 6, 2019 22:52
Update Google Sheet column based on other cells in same row.
function onEdit(e) {
var range = e.range;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var target = "Data";
var sheet = ss.getSheetByName(target);
var datestamp = Utilities.formatDate(new Date(), "PST", "dd/MM/yyyy hh:mm:ss a");
// SpreadsheetApp.getUi().alert("Edited in A1 Notation is: " + range.getA1Notation() + "\nDatestamp: " + datestamp ); //If you're having problems, uncomment this to make sure your named range is properly defined
@mbierman
mbierman / imagerename.sh
Last active July 30, 2019 22:46
renames image files using exif creation
#!/bin/sh
# echo "RSS feed?"
# read FeedName
domain="https://ramahnorcal.smugmug.com"
if [ "$1" = "1" ]; then
path="/hack/feed.mg?Type=gallery&Data=194176300_3dMVQd&format=rss200"
foldername="Day 1"
elif [ "$1" = "2" ]; then
@mbierman
mbierman / update row.js
Last active July 3, 2019 17:36
Google AppScript to automatically copy formulas to the last row of columns D:I of a Google Spreadsheet if an edit is made on a particular sheet
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sName = ss.getSheetName();
var target = 'Data'
Logger.log('Starting script...');
if (sName == target){
Logger.log('The sheet name: "' + target +'" was edited.');
var destSheet = ss.getSheetByName(target);
@mbierman
mbierman / Arris.sh
Last active January 8, 2019 19:22
Reboot Arris modem
#!/usr/bin/env bash
# Configure/Initialize
# Configure/Initialize
# read sensitive data from local files. Example:
# KEY=value
BASEDIR=$(dirname "$0")
APIKEY="$(cat $BASEDIR/arrisdata.txt | grep API | cut -f2 -d "=" )"
USER="$(cat $BASEDIR/arrisdata.txt | grep USER | cut -f2 -d "=" )"
PASS="$(cat $BASEDIR/arrisdata.txt | grep PASS | cut -f2 -d "=" )"
@mbierman
mbierman / cleanupHomeboy.gs
Created August 20, 2018 17:24
Google App script to remove files created more than 90 days from multiple directories
function DeleteOldFiles() {
var Folders = new Array(
'insert dir ID', //Entry
'insert dir ID', //Garage
'insert dir ID' //Kitchen
);
var Files;
Logger.clear();
@mbierman
mbierman / Import CSV to Google Sheet.gs
Last active August 2, 2018 23:54
I use this to take CSV data about the temperature and fan speed of my Mac (https://gist.github.com/mbierman/af96ef30445f0359e2d91bb7e2c184ad). This Google App Script 1. converts CSV to a Google compatible format 2. copies the data 3. Renames the CSV for backup for a while... and then adds the data to the end of a spreadsheet which creates a chart.
function importData() {
var fSource = DriveApp.getFolderById('enter ID Here'); // reports_folder_id = id of folder where csv reports are saved
var fi = fSource.getFilesByName('report.csv'); // latest report file
var ss = SpreadsheetApp.openById('enter ID here'); // data_sheet_id = id of spreadsheet that holds the data to be updated with new report data
// Convert CSV > Google Sheet
if ( fi.hasNext() ) { // proceed if "report.csv" file exists in the reports folder
var file = fi.next();
// Logger.log('starting point: ' + file.getName());
Drive.Files.copy({}, file.getId(), {convert: true});
@mbierman
mbierman / Import
Created August 2, 2018 23:51
I use this to take CSV data about the temperature and fan speed of my Mac (https://gist.github.com/mbierman/af96ef30445f0359e2d91bb7e2c184ad).
function importData() {
var fSource = DriveApp.getFolderById('1x_iNzrNZDfgWz1MykMiADa_7Yd0kMtln'); // reports_folder_id = id of folder where csv reports are saved
var fi = fSource.getFilesByName('report.csv'); // latest report file
var ss = SpreadsheetApp.openById('1BkLfWzBB9WFmUxkBtM8ID43Y34nO9kC0IpjSZQ5aCBA'); // data_sheet_id = id of spreadsheet that holds the data to be updated with new report data
// Convert CSV > Google Sheet
if ( fi.hasNext() ) { // proceed if "report.csv" file exists in the reports folder
var file = fi.next();
// Logger.log('starting point: ' + file.getName());
Drive.Files.copy({}, file.getId(), {convert: true});
@mbierman
mbierman / Import
Created August 2, 2018 23:51
I use this to take CSV data about the temperature and fan speed of my Mac (https://gist.github.com/mbierman/af96ef30445f0359e2d91bb7e2c184ad).
function importData() {
var fSource = DriveApp.getFolderById('1x_iNzrNZDfgWz1MykMiADa_7Yd0kMtln'); // reports_folder_id = id of folder where csv reports are saved
var fi = fSource.getFilesByName('report.csv'); // latest report file
var ss = SpreadsheetApp.openById('1BkLfWzBB9WFmUxkBtM8ID43Y34nO9kC0IpjSZQ5aCBA'); // data_sheet_id = id of spreadsheet that holds the data to be updated with new report data
// Convert CSV > Google Sheet
if ( fi.hasNext() ) { // proceed if "report.csv" file exists in the reports folder
var file = fi.next();
// Logger.log('starting point: ' + file.getName());
Drive.Files.copy({}, file.getId(), {convert: true});
@mbierman
mbierman / gettemp.sh
Last active August 11, 2022 02:10
Uses osx-cpu (https://github.com/lavoiesl/osx-cpu-temp) to get temp and fanspeed. Using LaunchAgent, run every 5 minutes, log to a file
#!/usr/bin/env bash
MACH=$(hostname -s)
tool="$HOME/Documents/Applications/bin/osx-cpu-temp"
if [ ! -f ${tool} ]; then
echo -e "\n\nSorry, you need to install osx-cup-temp on \"$MACH\" for this to function.\n Check https://github.com/lavoiesl/osx-cpu-temp\n"
exit
fi