Skip to content

Instantly share code, notes, and snippets.

@fredeerock
Last active April 6, 2017 05:47
Show Gist options
  • Save fredeerock/c10cbebfc177a5224e61fcd58299c820 to your computer and use it in GitHub Desktop.
Save fredeerock/c10cbebfc177a5224e61fcd58299c820 to your computer and use it in GitHub Desktop.
quickly setup p5.js with serial
#!/bin/bash
FOLDER=$1
mkdir -p $FOLDER
cd $FOLDER
printf "Downloading p5.js......"; curl -LO `curl -s https://api.github.com/repos/processing/p5.js/releases | grep browser_download_url | head -n 4 | grep p5.min.js | cut -d '"' -f 4`; echo "done.";
printf "Downloading p5.serialport......"; curl -LO https://raw.githubusercontent.com/vanevery/p5.serialport/master/lib/p5.serialport.js; echo "done.";
printf "<!doctype html>\n<title>p5tests</title>\n<script src=\"p5.min.js\"></script>\n<script src=\"p5.serialport.js\"></script>\n<script src=\"sketch.js\"></script>" > index.html
printf "function setup() {\n\n}\n\nfunction draw() {\n\n}" > sketch.js
printf "{\n \"name\": \"serialserver\",\n \"version\": \"1.0.0\",\n \"scripts\": {\n \"start\": \"./node_modules/p5.serialserver/startserver.js\"\n }\n}" > package.json
npm install p5.serialserver
printf "\nStart with: cd $FOLDER && npm start\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment