Skip to content

Instantly share code, notes, and snippets.

Sean M. Tracey seanmtracey

Block or report user

Report or block seanmtracey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@seanmtracey
seanmtracey / Word Counter Node Codes
Last active Jan 14, 2019
The code for the IBM Developer UK word counter tutorial
View Word Counter Node Codes
This is all of the code needed to follow the IBM Developer UK word counter tutorial.
@seanmtracey
seanmtracey / GlowOrbWordCounter.md
Last active Sep 24, 2018
A Node-RED flow that turns a glow orb different colors depending on how fast I'm talking
View GlowOrbWordCounter.md

Steps for use:

  1. Import the flow to a Node-RED instance
  2. Add credentials to the speech-to-text node
  3. Configure your MQTT node to communicate with your Gloworb / MQTT enabled device
  4. Click 'Deploy'
  5. Open up https://<YOUR_NODE_RED_HOST>/word-count. You'll be asked to enable your microphone, this will begin the capture of audio from your mircophone for counting.
  6. Once you enable the microphone, you can click the 'Start' button to stream the audio over web sockets to your Node-RED instance.
  • NB: If you hit the 'stop' button, you'll need to refresh the page to start streaming again, I haven't finished that bit of the code yet.
  1. Voila! If you're speaking at an acceptable rate, your glow orb will be green. If you're going a little fast, it will turn orange. If you're WWAAAYYYYY out, it will turn blue (because red is an alarming color for anyone to see.)
View Node-RED + Watson Assistant Details.md

Instructions for plugging a website into Watson Assisstant with Node-RED + WebSockets

Okie dokie, so you want to plug your website into Watson Assistant, well, here's how you can do that.

First, you'll need to set up a Node-RED server which can talk to Watson Assistant. The demo-flow.json contains a demo flow that will hook up a websockets endpoint to a Watson Assistant instance enabling you to talk to the Assistant instance with a web page.

  1. Copy the contents of demo-flow.json into your clipboard and then head to any Node-RED flow.
  2. Top right of the Node-RED UI, hit the hamburger menu and then hover over "import" and then select "clipboard" from the context menu that appears.
  3. In the dialog box that appears, paste the content of your clipboard and then click "import"
  4. A flow will appear in your workflow, click to place it, you now have a websocket connection configured to talk to Watson Assistant
@seanmtracey
seanmtracey / instructions.md
Created Sep 3, 2018
Instructions to clear CloudantDB Documents
View instructions.md
  1. First up, head to https://console.bluemix.net and find your Cloudant DB instance. Click on it to be taken to the service page.
  2. Next, click on the "Launch Cloudant Dashboard" button at the top-right of your screen. This will take you to the dashboard for your Cloudant DB instance
  3. You should be taken to the 'databases' view (if not, click on the icon on the far left of the screen that looks like stacked pancakes). Click the database that you would like to delete the records from
  4. A table with rows of your documents should appear.
  • If you only want to delete select documents from your database, click the individual checkboxes on the left-hand side of each row in the tabl
  • If you want to delete all of the documents in this view, clickbox just above the table on the left-hand side
  1. When you've selected some (or all) of your records, a trash can icon will appear at the top left of the table. Click it to delete the selecte rows.
@seanmtracey
seanmtracey / instructions.md
Created Sep 3, 2018
Instructions to clear CloudantDB Documents
View instructions.md
  1. First up, head to https://console.bluemix.net and find your Cloudant DB instance. Click on it to be taken to the service page.
  2. Next, click on the "Launch Cloudant Dashboard" button at the top-right of your screen. This will take you to the dashboard for your Cloudant DB instance
  3. You should be taken to the 'databases' view (if not, click on the icon on the far left of the screen that looks like stacked pancakes). Click the database that you would like to delete the records from
  4. A table with rows of your documents should appear.
  • If you only want to delete select documents from your database, click the individual checkboxes on the left-hand side of each row in the tabl
  • If you want to delete all of the documents in this view, clickbox just above the table on the left-hand side
  1. When you've selected some (or all) of your records, a trash can icon will appear at the top left of the table. Click it to delete the selecte rows.
View Hays Solutions.md

Hard

 Number( input.toString().split('').sort( (a, b) => { return a < b ? 1 : -1 } ).join('') )

Intermediate

const lower = 'abcdefghijklmnopqrstuvwxyz'.split('');
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
View Node-RED Web Component Ideas.md

Web components to hook up client-side applications to Node-RED nodes in a standardised way.

Rationale

Node-RED is incredibly good at letting people prototype their ideas without a great deal of programming knowledge. However, the dashboard, whilst great connecting service A -> C via. B, it doesn't lend itself especially well to being hooked up to a custom application running on said server in quite the same way.

I believe Web Components could allow for more web apps to be built and integrated with Node-RED nodes as seemlessly as creating a flow is now, but with a greater ability to customise that JS/CSS/HTML afford up-and-coming developers.

How would this work?

  1. A developer would drop a node onto the canvas, just as they always have (say, for a camera), and give it a unique name.
  2. The developer would include a <script> tag in a web page they are delivering from the same Node-RED instance
View gist:63c3b3220d50d0eb46757b8a595e883f
Array.from(table.querySelectorAll('tr')).map(tr => {tds = Array.from(tr.querySelectorAll('td') ); return `${tds[0].querySelector('input').value}=${tds[1].querySelector('textarea').value}` }).join('\n')
@seanmtracey
seanmtracey / Extract_and_analyse.json
Created Nov 20, 2017
A Node-red flow for extracting keyframes from videos and analysing them with Watson Visual Recogntion
View Extract_and_analyse.json
[{"id":"146f4acc.4733c5","type":"function","z":"ceee673f.122fb8","name":"Determine File Path","func":"if (msg.req.files) {\n var files = Object.keys(msg.req.files);\n msg.payload.filePath = msg.req.files[files[0]][0].path; \n}\nreturn msg;","outputs":1,"noerr":0,"x":278.5,"y":452,"wires":[["c4cd6b26.2acfc8"]]},{"id":"3bf669a6.9b88e6","type":"httpInMultipart","z":"ceee673f.122fb8","name":"","url":"/analyse","method":"post","fields":"[ { \"name\": \"video\", \"maxCount\" : 1 } ]","swaggerDoc":"","x":145,"y":387,"wires":[["146f4acc.4733c5"]]},{"id":"e1f10989.eab7c8","type":"visual-recognition-v3","z":"ceee673f.122fb8","name":"Analyse frame","apikey":"50a86834a2d8947a442a1ba81e9dde323f074786","image-feature":"classifyImage","lang":"en","x":628,"y":652,"wires":[["1a442f8b.94618","5f0f5910.f08c08"]]},{"id":"5f0f5910.f08c08","type":"function","z":"ceee673f.122fb8","name":"Make Sense","func":"\nconst jobData = flow.get(msg.analysisUUID);\nconst frameData = {\n time : msg.keyframeTimeoffset,\n result :
@seanmtracey
seanmtracey / index.html
Last active Mar 4, 2017
Paint with light in less than 1024 bytes.
View index.html
<!DOCTYPE html>
<html>
<head>
<style>
html, body, canvas{width: 100%; height: 100%;margin:0;padding:0;}
</style>
</head>
<body>
You can’t perform that action at this time.