Skip to content

Instantly share code, notes, and snippets.

View stephkoltun's full-sized avatar

Stephanie Koltun stephkoltun

View GitHub Profile
// Tiny TFJS train / predict example.
async function myFirstTfjs() {
// Create a simple model.
const model = tf.sequential();
model.add(tf.layers.dense({units: 1, inputShape: [1]}));
// Prepare the model for training: Specify the loss and the optimizer.
model.compile({
loss: 'meanSquaredError',
optimizer: 'sgd'
@stephkoltun
stephkoltun / snowstorm.js
Last active March 30, 2018 17:04
Demo of MQTT
var mqtt = require('mqtt');
var options = {
username: 'try',
password: 'try'
}
var client = mqtt.connect('mqtt://broker.shiftr.io', options);
client.on('connect', function() {
client.subscribe("thebestpets");
client.publish("thebestpets/dogs", "Dogs are really great");
set dFolder to "~/'Dropbox (Method)'/Projects/'2018-01 The Atlas Project'/screencapture/"
do shell script ("mkdir -p " & dFolder)
set pathToMouseTools to "Macintosh HD:Users:skoltun:Desktop:bin:MouseTools"
set xPos to 957
set yPos to 692
var url;
var mic;
var prevState;
var lights;
function setup() {
mic = new p5.AudioIn();
mic.start();
connect();
}
#include <SPI.h>
#include <WiFi101.h>
#include "ArduinoJson.h"
#include "config.h"
// Sensors // MK1000 only takes 3.3V
int audioPin = A3; //
float audioValue = 0.0;
int lightPin = A4; // photocell: put with a brown-black-orange resistor
float lightValue = 0.0; // or photo transister: red red yellow
projection = d3.geoMercator()
.scale([2000000]); // scale things wayyyy up
path = d3.geoPath() // path generator that will convert GeoJSON to SVG paths
.projection(projection); // tell path generator to use above defined projection
d3.json('Manhattan-Blocks.geojson', function(error, mapData) {
var features = mapData.features;
features.sort(function(x, y){
return d3.descending(x.properties.area, y.properties.area);
var roofObject = require('./roofObject.js');
var dateFormat = require('dateformat');
module.exports = {
addReading: function(request, response) {
console.log("add new reading");
var now = new Date();
var timeFormatted = dateFormat(now, "isoDateTime");
var roofObject = require('./roofObject.js');
module.exports = {
getLatest: function(request, response) {
response.send(roofObject.readings[roofObject.readings.length-1]);
},
getAll: function(request, response) {
response.send(roofObject.readings);
},
@stephkoltun
stephkoltun / server.js
Created January 31, 2018 19:48
Roof server
var express = require('express'); // include express.js
var app = express(); // a local instance of it
var bodyParser = require('body-parser'); // include body-parser
var getRequest = require('./getRequest.js');
var postRequest = require('./postRequest.js');
// you need a couple of parsers for the body of a POST request:
app.use(bodyParser.json()); // for application/json
app.use(bodyParser.urlencoded({extended: false})); // for application/x-www-form-urlencoded
app.use(express.static('public'));
var limit = 50; // number of results to return
var offset = 0; // position where to start returning from
app.get("/compareSents", function(req, res) {
console.log("compare sentences in batches");
// call the comparison function below
compareTheSentences();
// should have a response???