Skip to content

Instantly share code, notes, and snippets.

const { spawn } = require('child_process');
const python = spawn('python', ['/path/to/myscript.py']);
python.stdout.on('data', (data) => {
// This is the output from the Python Script:
console.log(`stdout: ${data}`);
});
python.stderr.on('data', (data) => {
var location = {"bounds": [{"lat":42.34398047870971,"lng":-71.10525637865067},{"lat":42.34413114540996,"lng":-71.10488891601562},{"lat":42.34408554894667,"lng":-71.10476285219193},{"lat":42.34398444362749,"lng":-71.10463410615921},{"lat":42.34367716175749,"lng":-71.10504180192947},{"lat":42.343764390311954,"lng":-71.10523492097855},{"lat":42.343895232916715,"lng":-71.10531806945801}]}];
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 42.34398047870971, lng: -71.10525637865067},
zoom: 18
});
var polygon = new google.maps.Polygon({
paths: location.bounds,
strokeColor: '#FF0000',
@vanevery
vanevery / ButtonLE
Created March 28, 2017 18:42
ButtonLE Example from Class
<html>
<head>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
var connectedDevice = null;
var button = {
service: "19B10010-E8F2-537E-4F6C-D104768A1214",
data: "19B10012-E8F2-537E-4F6C-D104768A1214"
@vanevery
vanevery / express_sessions.js
Created March 28, 2017 01:40
Express Sessions Cookies NeDB GUID
//https://github.com/expressjs/session
//https://github.com/broofa/node-uuid
//https://github.com/JamesMGreene/nedb-session-store
var express = require('express');
var app = express();
var session = require('express-session');
var nedbstore = require('nedb-session-store')(session);
const uuidV1 = require('uuid/v1');
function dateFormatter(date) {
//YYYY-MM-DD
var year = date.getUTCFullYear();
var month = date.getUTCMonth();
month++; // months begin at 0 for some reason
if (month < 10) {
month = "0" + month; // add a leading 0
}
var day = date.getUTCDate()
if (day < 10) {
@vanevery
vanevery / gist:5699b02ae7cd27f608ab
Created November 14, 2014 21:00
p5.js Device Orientation Example
//https://developer.mozilla.org/en-US/docs/Web/Events/deviceorientation
var alpha = 0; // Orientation around Z axis
var beta = 0; // Orientation around X axis
var gamma = 0; // Orientation around Y axis
function setup() {
createCanvas(200,200);
if (window.DeviceOrientationEvent) {
window.addEventListener('deviceorientation', onOrientationChange);
#include <Bridge.h>
#include <Process.h>
// make a new Process for calling Node
Process p;
String message = "";
char sensorStr[3];
void setup() {
@vanevery
vanevery / gist:6679267
Created September 24, 2013 01:32
Follow the mouse javascript
<html>
<head>
</head>
<body>
<div style="width: 1000px; height: 1000px">
<div id="dragme" style="position: absolute; left: 10px; top: 10px;">hi</div>
</div>
<script type="text/javascript">
@vanevery
vanevery / gist:6679266
Created September 24, 2013 01:32
create image tag javascript
<html><head>
<script type="text/javascript">
var createImage = function(source) {
var img=document.createElement("IMG");
img.src = source;
// don't forget to add it to the document
};