Skip to content

Instantly share code, notes, and snippets.

View leoherzog's full-sized avatar

Leo leoherzog

View GitHub Profile
#!/bin/sh
#
# CloudFlare Dynamic DNS
#
# Updates CloudFlare records with the current public IP address
#
# Takes the same basic arguments as A/CNAME updates in the CloudFlare API
# https://www.cloudflare.com/docs/client-api.html#s5.2
#
# Use with cron jobs etc.
@jwbowles
jwbowles / excelToSimpleDateFormat
Last active February 17, 2017 10:28
Javascript function to convert Excel date format syntax (used in Google Apps Script spreadsheets) to simpleDateFormat syntax.
function excelToSimpleDateFormat(date, str) {
var excelNonReserved = /([^(m+|d+|y+|am\/pm|a\/p|h+|s+|0+|\[h+\]|\[m+\]|\[s+\])])/gi;
var excelElements = /("[^"]+"|m+|d+|y+|am\/pm|a\/p|h+|s+|0+|\[h+\]|\[m+\]|\[s+\])/gi;
var restrictedChars = /[a-z]+/gi;
var quotes = /"([^"]+)"/;
var minute = /m/g;
var month = /M/g;
var hour = /h/gi;
var seconds = /s/gi;
var ampm = /(a\/p|am\/pm)/gi;
@kevinoconnor7
kevinoconnor7 / c-ddns.sh
Last active November 24, 2020 11:07
CloudFlare Dynamic DNS
#!/bin/sh
WAN_IP=`curl ifconfig.io/ip`
OLD_WAN_IP=`cat /var/CURRENT_WAN_IP.txt`
if [ "$WAN_IP" = "$OLD_WAN_IP" ]
then
echo "IP Unchanged"
else
curl https://www.cloudflare.com/api_json.html \
-d 'a=rec_edit' \
-d 'tkn=8afbe6dea02407989af4dd4c97bb6e25' \
@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;
}
if [ $EUID != 0 ]; then
echo "It's a weird tree."
else
echo ' _ __'
echo ' / `\ (~._ ./ )'
echo ' \__/ __`-_\__/ ./'
echo ' _ \ \/ \ \ |_ __'
echo ' ( ) \__/ -^ \ / \'
echo ' \_/ " \ | o o |.. / __'
echo " \\. --' ==== / || / \\ "
@hazcod
hazcod / wgcf.sh
Created October 16, 2019 06:10
Connect to Cloudflare Warp from macOS.
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit 2>/dev/null || true
# this script will connect macOS to Cloudflare Warp using Wireguard
# note: this is *absolutely not* an official client from Cloudflare
# Copyright (C) 2019 Jay Freeman (saurik)
# Zero Clause BSD license {{{
@erickoledadevrel
erickoledadevrel / xmlToJson.js
Created December 1, 2014 14:30
A function to convert an XML string to a JSON object in Apps Script, using logic similar to the sunset method Xml.parse().
/**
* Converts an XML string to a JSON object, using logic similar to the
* sunset method Xml.parse().
* @param {string} xml The XML to parse.
* @returns {Object} The parsed XML.
*/
function xmlToJson(xml) {
var doc = XmlService.parse(xml);
var result = {};
var root = doc.getRootElement();
@ImranR98
ImranR98 / eOSUDS.sh
Last active March 23, 2023 06:33
elementaryOS 6 has great dark themes, but they only apply to "curated" appcenter apps. This script forces the system theme to work with regular Debian packages as well as non-curated Flatpak apps. It also optionally changes the wallpaper based on the theme. It also supports changing themes for the Mailspring email app (both .deb and Snap versions).
#!/usr/bin/bash
# =======================================
# eOS-Universal-Dark-Style
# =======================================
# elementaryOS 6 has great dark themes, but they only apply to "curated" appcenter apps
# This script forces the system theme to work with regular Debian packages as well as non-curated Flatpak apps
# It also optionally changes the wallpaper based on the theme
@Dhertz
Dhertz / Ubuntu_Aerial.md
Last active March 28, 2023 02:06
Quick overview of how to get Apple's new TV screensavers working on most linux systems.

Using Apple’s Aerial Screensavers on Ubuntu After coming across the [Aerial] (https://github.com/JohnCoates/Aerial) screensavers for Mac, and installing them, I decided that I had had enough of the graphics-demos of my Ubuntu Precise system. I hope to provide a simple guide on how to add them to your setup as well.

First, you need to install xscreensaver (for example with aptitude, but your distro should have it):

sudo aptitude install xscreensaver
@julianxhokaxhiu
julianxhokaxhiu / create-iso.sh
Created September 24, 2016 21:46
Simple bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
#!/bin/bash
#
# Credits to fuckbecauseican5 from https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/
# Adapted to work with the official image available into Mac App Store
#
# Enjoy!
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build