Skip to content

Instantly share code, notes, and snippets.

View fvdm's full-sized avatar
🦖
I may be slow to respond

Franklin fvdm

🦖
I may be slow to respond
View GitHub Profile
@fvdm
fvdm / homeyscript_datum.js
Last active April 10, 2024 21:28
HomeyScript for simple date calculation within a flow. The date class is using the timezone configured in the Homey settings. The result is provided as card tags which can be used in cards that come after. Make sure to add delays to the cards that use these tags, because HomeyScripts are executed async.
/**
* Get current date and time as card tags
* Optional date offset calculation using Homey's timezone
* suffix: [y]ears, [m]onths, [d]ays, [h]ours, m[i]nutes, [s]econds, [m]illi[s]econds
*
* @example
* // two months ago
* '-2m'
*
* @example
@fvdm
fvdm / homeyscript_waitms.js
Last active February 17, 2024 12:54
HomeyScript to stall the flow a number of minutes, seconds or millieconds (default)
/**
* HomeyScript to stall the flow a number of [m]inutes, [s]econds or [m]illi[s]econds (default)
*
* @example 2 -> waiting 2ms
* @example 2m -> waiting 2 min
* @example 2s -> waiting 2 seconds
*
* @see {@link https://gist.github.com/fvdm/23a77945799d204512877caf87aee9a2}
*/
@fvdm
fvdm / homeyscript_parseint.js
Last active February 17, 2024 12:40
HomeyScript to parse an integer from any argument type within a flow. The result is provided in the `value` tag. You can optionally set a different output type: `number` (default), `string` or `bool`.
/**
* Parse the argument to an integer of `number` type.
* Optionally you can enforce the output type to `number` (default), `string` or `bool`.
* The result is provided in the `value` tag.
*
* @example '22:00' -> 22
* @example '22:00 string' -> '22'
* @example '22:00 bool' -> true
* @example '0 bool' -> false
*

Keybase proof

I hereby claim:

  • I am fvdm on github.
  • I am fvdm (https://keybase.io/fvdm) on keybase.
  • I have a public key ASAS4VBijLQUJfPqff4YybLRQpbqtJpvFjCJmj7hqaO1Uwo

To claim this, I am signing this object:

#!/usr/bin/env node
/*
USAGE: cat file.json | parsejson [OPTION] [PROPERTY]
Name: parsejson
Description: Parse JSON text to human-readable tree with syntax coloring.
Source: https://frankl.in/code/json-cli-parser-with-syntax-coloring
Author: Franklin (https://github.com/fvdm)
License: Unlicense / Public Domain
@fvdm
fvdm / evernote.js
Created December 30, 2012 00:38 — forked from codewzrd/evernote.js
CmdUtils.makeBookmarkletCommand({
name: "Evernote",
description: "Save a note on Evernote.",
icon: "http://www.evernote.com/favicon.ico",
homepage: "http://www.makadia.com",
author: {name: "Svapan Makadia", email: "codewzrd@hotmail.com"},
help: "Select content and invoke this command to save the selection as a note or just save the whole page without selecting anything.",
url: "javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();"
})
#!/bin/sh
if [ "$1" == "-h" ]; then
echo "Colorful Homebrew update script"
echo
echo "USAGE: update [-y]"
echo
echo " -y skip questions"
echo " -h display this help"
echo
exit 0
# Force download for certain URLs with ?force_download
set $forceDownload "";
set $filename "";
if ($request_filename ~ /([^/]+)$) {
set $filename $1;
}
if ($request_uri ~ [\?&]force_download(=(?<filename>[^&$]+)|&|$)) {
set $forceDownload "attachment; filename=\"$filename\"";
#!/bin/sh
export arg=$@
find . -name '.git' -type d -exec bash -c 'path=${1%/.git}; echo $path; cd "$path" && git gc $arg' 0 {} \;
// Add pre-exit script
process.on ('exit', code => {
console.log (`Whoa! Exit code ${code}, cleaning up...`);
// i.e. close database
});
// Add another for fun
process.on ('exit', code => {
if (code > 0) {
console.log ('Hmm something went wrong');