Skip to content

Instantly share code, notes, and snippets.

View leoherzog's full-sized avatar

Leo leoherzog

View GitHub Profile
@leoherzog
leoherzog / code.gs
Last active June 14, 2017 18:48
Google Calendar Event Deleter - Remove all events on your calendar that were created by a certain id
function run() {
findAndNuke("blah@gmail.com");
}
/**
* This simple script gets all of your events on your calendar and deletes any that were created by "id".
* Useful for rogue events created by email addresses that don't exist anymore.
*
* @param {string} id (email address) of the creator of the events you want to get rid of
*/
@leoherzog
leoherzog / *setup.md
Last active March 18, 2021 14:27
Google Doc Clean HTML Output, powered by Apps Script

Google Doc Clean HTML Output, powered by Apps Script

Add this function to your Apps Script project and feed it an ID to a Google Doc.

If you need this on a lot of Docs, you may want to make a new Apps Script project to use as a library. Simply copy and paste this code to the new project, go to the script that's tied to your Doc, add your new Library (the script ID), and call var html = *NameOfYourLibraryProject*.getContent(DocumentApp.getActiveDocument().getId());

@leoherzog
leoherzog / temp.js
Last active December 9, 2020 15:34
Wunderground Color Temperature Scale with Chroma.js
//<script src="//cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.3/chroma.min.js"></script>
function getColorFromTemp(tempInF) {
// establish the chroma 'scale' object
var tempScaleColors = ["#111111", "#21006B", "#4C006B", "#6B006B", "#990099", "#B300B3", "#CC00CC", "#E600E6", "#FF02FF", "#D100FF", "#9E01FF", "#6600FF", "#1800FF", "#144AFF", "#0E74FF", "#00A4FF", "#00CBFF", "#00E6FF", "#00FFFF", "#01FFB3", "#7FFF00", "#CEFF00", "#FEFF00", "#FFE601", "#FFCB00", "#FFAE00", "#FF9900", "#FE7F00", "#FF4F00", "#FF0700", "#FF4545", "#FF6968", "#FF8787", "#FF9E9E", "#FFB5B5", "#FFCFCF", "#FFE8E8", "#EEEEEE"];
var tempScale = chroma.scale(tempScaleColors).domain([-60,130]).mode('lab');
// extract color from chroma scale by giving it a temp number
var color = tempScale(tempInF);
return color;
}
@leoherzog
leoherzog / mac-vm-prep.sh
Last active March 28, 2017 19:08
Prepare Virtualbox VM to host guest MacOS
#!/bin/bash
read -p "Case-sensitive name of the VM: " vmname
if [[ -z $vmname ]]; then
echo "$(tput setaf 1)Please enter a valid VM Name$(tput sgr0)"
exit 1
fi
if [[ $vmname =~ \ |\' ]]; then
echo "$(tput setaf 3)Be warned, there have been reports that this may not work with VM Names that contain spaces$(tput sgr0)"
fi
echo "What resolution would you like the VM guest to be?"
@leoherzog
leoherzog / code.gs
Last active January 13, 2017 20:28
Sort your array of CalendarEvent objects that were returned from the Google Apps Script CalendarApp
// copy this to the bottom of your script, then call it on your array of CalendarEvent objects that you got from the CalendarApp
//
// ex:
// var sortedEvents = sortArrayOfCalendarEventsChronologically(events);
// or
// events = sortArrayOfCalendarEventsChronologically(events);
function sortArrayOfCalendarEventsChronologically(array) {
if (!array || array.length == 0) {
return 0;
@leoherzog
leoherzog / weatherSymbols.gs
Last active January 5, 2017 13:34
Turn Wunderground API or Dark Sky API Conditions into Unicode Symbols
// possible options: https://www.wunderground.com/weather/api/d/docs?d=resources/icon-sets (image file names)
function getWundergroundIcon(condition) {
var conditionEmoji = "";
if (condition.indexOf("sunny") > -1 || condition.indexOf("clear") > -1) {
conditionEmoji = "☀️ ";
} else if (condition.indexOf("partlysunny") > -1 || condition.indexOf("mostlysunny") > -1) {
conditionEmoji = "⛅ ";
} else if (condition.indexOf("partlycloudy") > -1 || condition.indexOf("mostlycloudy") > -1) {
conditionEmoji = "🌥 ";
} else if (condition.indexOf("cloudy") > -1 || condition.indexOf("fog") > -1 || condition.indexOf("hazy") > -1) {
@leoherzog
leoherzog / *App Flow.md
Last active November 27, 2019 16:25
Pseudocode for Flicki. Package name: productions.agentl.flicki

The app Muzei (https://muzei.co/) has lots of plugins (https://play.google.com/store/search?q=muzei&c=apps). I would like you to create one in Java that uses the Flickr API and Android Awareness APIs. Familiarity in Retrofit, REST APIs, and the Android Awareness API are a must. App itself will have no launcher icon and no UI, and will act as a plugin for Muzei.

When the Art Source is selected, the finished app must:

  • Attempt to get the user's location via the Fused Location API from Google Play Services
    • If the location isn't granted, pop up dialog message saying it's required and ask again (loop until granted or cancelled)
  • Start the initial refresh

When it's time for a refresh, the finished app must:

  • Get current weather condition for user's location via the NWS JSON API v3 (happy to assist with this)
  • Ask Flickr for photos for this location
@leoherzog
leoherzog / keybase.md
Last active May 13, 2020 13:55
Keybase Verification

Keybase proof

I hereby claim:

  • I am leoherzog on github.
  • I am leoherzog (https://keybase.io/leoherzog) on keybase.
  • I have a public key whose fingerprint is C4FF C7C8 309B 8E7F 9954 8BBB 17B9 6B0F B3EC DB85

To claim this, I am signing this object:

@leoherzog
leoherzog / Description
Created August 7, 2016 16:39
Muzei extension for Tasker that gets local weather photos from #ProjectWeather
Muzei Weather Wallpaper Updater v2 (39)
<Kill the task if Wi-Fi isn't connected and the "Wi-Fi Only" setting is on>
A1: Stop [ With Error:Off Task:Muzei Weather Wallpaper Updater v2 ] If [ %WIFII !~ *CONNECTION* & %WWWIFIONLY ~ true ]
<Kill the task if the battery is low and the "Don't run on low battery" setting is on>
A2: Stop [ With Error:Off Task:Muzei Weather Wallpaper Updater v2 ] If [ %BATT < 15 & %WWDONTRUNONLOWBATTERY ~ true ]
A3: Variable Set [ Name:%flickrapikey To:0952e1ceeeca7a0e1b3867533ba4beff Do Maths:Off Append:Off ]
<#ProjectWeather Flickr Group ID>
A4: Variable Set [ Name:%projectweathergroupid To:1463451@N25 Do Maths:Off Append:Off ]
A5: Get Location [ Source:Net Timeout (Seconds):15 Continue Task Immediately:Off Keep Tracking:Off ]
<Turn network LAT,LONG into two variables>