Skip to content

Instantly share code, notes, and snippets.

View DanEdens's full-sized avatar
💭
Building a Test Kit!

Dan Edens DanEdens

💭
Building a Test Kit!
View GitHub Profile
@DanEdens
DanEdens / teams_webhook_post.py
Last active January 15, 2020 17:33 — forked from devStepsize/slack_webhook_post.py
POST a JSON payload to a Team's channel Incoming Webhook using Python requests
'''
This is an example of how to send data to Team's webhooks in Python with the
requests module.
Documentation for Team's Incoming Webhooks:
https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/what-are-webhooks-and-connectors
Card playground:
https://messagecardplayground.azurewebsites.net/
'''
import json
@DanEdens
DanEdens / DisplayPhotoTime.bat
Last active December 16, 2022 00:42
Overlay Photos creation time to southwest corner of image
# Extract the EXIF DateTime metadata from the input file and store it in the clipboard
magick identify -format %%[EXIF:DateTime] "%1" | CLIP
# Retrieve the contents of the clipboard and store it in the CLIPBOARD_TEXT variable
for /f "eol=; tokens=*" %%I in ('powershell Get-Clipboard') do set CLIPBOARD_TEXT=%%I
# Use the Magick command to annotate the input file with the EXIF DateTime metadata
# and save the output to a new file with "_converted" appended to the filename
magick "%1" -gravity SouthWest -fill "#7C0A02" -pointsize 84 -annotate +50+50 "%CLIPBOARD_TEXT%" "%1_converted.jpg"
@DanEdens
DanEdens / flows.json
Last active March 9, 2020 00:50
Fleet controller flow for node-red
[{"id":"ddaf41df.e76d7","type":"tab","label":"Debug","disabled":false,"info":""},{"id":"ef0a1326.ffefe","type":"tab","label":"Event Listener","disabled":false,"info":""},{"id":"620a8013.090dd","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d8072816.202f58","type":"tab","label":"Notepad","disabled":false,"info":""},{"id":"f8b092ce.2f198","type":"tab","label":"Outbox","disabled":false,"info":"Filter and log outgoing traffic"},{"id":"8606dfd5.df337","type":"join-config","z":"","name":"pi4-2","register":true},{"id":"174c9775.d43329","type":"join-server","z":"","name":"pi4-2","port":"1822","joinConfig":"8606dfd5.df337"},{"id":"72ae563e.956af8","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,R
process.stdin.on('keypress', async (str, key) => {
if (key.sequence === '\u0003') {
await browser.close();
process.exit();
}
if (['up', 'down', 'left', 'right', 'enter'].includes(key.name)) {
const capitalized = key.name[0].toUpperCase() + key.name.slice(1);
const keyName = `Arrow${capitalized}`;
console.log(`page.keyboard.down('${keyName}')`);
@DanEdens
DanEdens / index.js
Created April 27, 2020 17:45
Interactive Browser session with Live template function
const readline = require('readline');
const puppeteer = require('puppeteer');
const Promise = require("bluebird");
const CREDS = require(__dirname + '/user/creds.js');
const url = 'www.google.com'
(async () => {
let wargs = puppeteer.defaultArgs()
function arrayRemove(arr, value) {
@DanEdens
DanEdens / getstock.js
Created May 3, 2020 20:37
function to get stock price based on symbol
function getStockQuote(symbol) {const url = `https://finance.google.com/finance?q=${symbol}&output=json`got(url).then(response => {/* Must remove the first three characters of the Google finance text returned to parse JSON.*/const stock = JSON.parse(response.body.substr(3))const quote = stock[0]console.log(`${quote.t} ${quote.l} ${quote.c} (${quote.cp}%)`)}).catch(error => {console.log(error.response.body)})}
@DanEdens
DanEdens / node-red
Last active July 7, 2020 12:17
Init.d script for node-red
#! /bin/sh
### BEGIN INIT INFO
# Provides: node-red
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start node-red server at init
### END INIT INFO
#!/bin/bash
set -e
# install java
sudo apt -y install default-jre-headless
# fetch latest bfg.jar
sudo wget https://repo1.maven.org/maven2/com/madgag/bfg/1.13.0/bfg-1.13.0.jar -O /usr/local/bin/bfg-latest.jar
# install to /usr/local/bin
### Preseed for Ubuntu 18.04
# Derived from: https://help.ubuntu.com/lts/installation-guide/example-preseed.txt
### Usage
# We recommend to use the build-iso.sh script to build an image with embedded
# preseed and other required files. In that case the preseed file gets loaded
# automatically and all additional files are available to the installer.
### Unattended Installation
d-i auto-install/enable boolean true
@DanEdens
DanEdens / mqtt_eg_link.sh
Last active October 22, 2020 22:15
This method of piping commands is independent of EG, and will start it up if not already running. This is very useful if I need to restart it remotely. Events are sent to Eventghost through subscribing to topic "ghost" on my MQTT broker.