Skip to content

Instantly share code, notes, and snippets.

View shyampurk's full-sized avatar

Shyam Purkayastha shyampurk

View GitHub Profile
@shyampurk
shyampurk / Dockerfile
Last active July 7, 2022 14:27
Sample API Service for Reminder CRUD with Minikube Deployment
FROM node:16
#Create app directory
WORKDIR /usr/src/app
#Install any dependencies
COPY . .
RUN npm install
@shyampurk
shyampurk / gist:dffedb478b9305eb0600abbe7bf45932
Created February 11, 2022 06:52
LightRun-Nodejs-HTTP-Sample
require('lightrun').start({
lightrunSecret: '<YOUR_LIGHTRUN_SECRET>',
company: '<YOUR_COMPANY_NAME>',
});
const express = require('express');
const req = require('express/lib/request');
const app = express();
let bodyParser = require('body-parser');
public function addUser(Request $request) {
$username1 = $request->get('username');
$username2 = $request->get('remoteUsername');
$exists = User::where('username',$username2)->first();
$callingUser = User::where('username',$username1)->first();
$uuid1 = $callingUser->uuid;
if($exists) {
$uuid2 = $exists->uuid;
$pubnub = new PubnubConfig($uuid1);
$pubnub->grantOne($uuid1,$uuid2);
def systemInit():
global port, loraM, client
obtain_port()
gpio_init()
emergencyVehicleState.setdefault("state",0)
#loraM handles all the loraEvents
loraM = MCLoRa(port)
success = loraM.testOK()
if success:
def handleEmergencyMessage(client, userdata, msg):
print(msg.topic + ' ' + str(msg.payload))
dataReceived = json.loads(msg.payload)
gpsLocation[0] = dataReceived["lat"]
gpsLocation[1] = dataReceived["lon"]
gps_tuple = tuple(gpsLocation)
distanceCalculated = int(vincenty(TRAFFIC_SIGNAL, gps_tuple).meters)
print ("Emergency Vehicle Location: ", distanceCalculated)
if distanceCalculated >= 150:
emergencyVehicleState["state"] = 0
def updateTrafficSignal():
global trafficLightNormalCurrState
state = emergencyVehicleState["state"]
if state == NORMAL:
if (LIGHT_RED == trafficLightNormalCurrState):
print "Switching to RED\n"
set_red()
elif (LIGHT_YELLOW == trafficLightNormalCurrState):
print "Switching to YELLOW\n"
def loraReceive():
global loraM
count = 0
while True:
print "LoRa Packet Receive Start"
try:
data = str(loraM.recv())
if data == "01": #Code 01 indicates primary communication failure
print "Received LoRa Signal from Emergeny Vehicle"
emergencyVehicleState["state"] = 1
document = client.sync \
.services(SERVICE_SID) \
.documents("gpsData") \
.update(data=gps_Data)
document = client.sync \
.services(SERVICE_SID) \
.documents("gpsData") \
.update(data=gps_Data)
@shyampurk
shyampurk / EmergencyVehicleSystemInit.py
Created June 28, 2018 04:57
Twilio Sync for Emergency Vehicle Control
def systemInit():
global port, loraM, client
obtain_port()
gpio_init()
emergencyVehicleState.setdefault("state",0)
#loraM handles all the loraEvents
loraM = MCLoRa(port)
success = loraM.testOK()
if success: