This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Text, View, StyleSheet, Image, Dimensions } from 'react-native'; | |
import * as Permissions from 'expo-permissions'; | |
import { Camera } from 'expo-camera'; | |
import CameraGrid from './CameraGrid' | |
export default class UploadImage extends Component { | |
state = { | |
hasCameraPermission: null, | |
type: Camera.Constants.Type.back, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//upload is a custom middleware built using multer to get a file buffer to process on the google vision API | |
app.post('/api/analyze/image', upload.single('vinImage'), async (req, res, next) => { | |
// GOOGLE VISION SETUP HERE | |
// ============================================================= | |
// Creates a google vision client for this request | |
const client = new vision.ImageAnnotatorClient(); | |
// Performs text detection from a buffer, this buffer was processed in the upload middleware | |
const [result] = await client.textDetection(req.file.buffer); //buffer | |
const detections = result.textAnnotations; | |
//handling error in case no text has been recognized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const multer = require('multer'); | |
const multerS3 = require('multer-s3'); | |
//aws s3 | |
const aws = require('aws-sdk'); | |
const s3 = new aws.S3({ | |
// some initilization goes here. | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//GPIO interaction using rpi-gpio package | |
const Gpio = require('onoff').Gpio; | |
const gpiop = require('rpi-gpio').promise; | |
//initialize temperature sensor | |
const sensor = require('ds18x20'); | |
//***need to add the sensor's Id**** | |
// The Id of the sensor can be found in /sys/bus/w1/devices/ | |
let sensorId = tempID; // sensor ID here, will set this with device factory settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('ws'); | |
//Initialize websocket communication | |
let wsCommunication = false | |
let ws; //store websocket connection | |
//connect to socket | |
connectToSocket = async () => { | |
// server address to connect to. | |
ws = new WebSocket('ws://serverPathHere'); // <== removed the server path on purpose | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize twilio client here | |
//some boring boilerplate initialization for twilio goes here | |
// ================ | |
//this function is triggered when temperature >= tempTarget && movement && !cancelAlarm | |
const emergencyCall = (temp) => { | |
//create text message to be sent | |
client.messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Dimensions } from 'react-native'; | |
import Svg, { Circle, Rect } from 'react-native-svg'; | |
// this code is not complete and won't work by itself but you can use it to get an idea how to make something similar | |
const thermostatSection = ({temperatureProgress,indicatorColor})=>{ | |
const { width } = Dimensions.get("window"); | |
//initialize size for container and circle dimmensions | |
const size=50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Auth from '../../modules/Auth'; | |
import Dashboard from '../../components/Dashboard'; | |
import SideBar from '../../components/SideBar'; | |
import TopBar from '../../components/TopBar'; | |
class DashboardPage extends React.Component { | |
constructor(props) { | |
super(props); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken'); | |
const User = require('mongoose').model('User'); | |
const Task = require('mongoose').model('Task'); | |
const config = require('../../config'); | |
/** | |
* The Auth Checker middleware function. | |
*/ | |
module.exports = (req, res, next) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import MagneticMouse from '../PathToMagneticMouse'; | |
//MagneticMouse also accepts a img props which is the url of an image | |
const Example=()=>{ | |
return( | |
<div style={{ height: '500px', width: '100%', boxShadow: '-1px 2px 4px -2px', borderRadius: '10px', margin: '10px', display: 'flex', justifyContent: 'center' }}> | |
<MagneticMouse myBackground={'Hi this is a sample message'} /> | |
</div> |