MQTT is probably best known as a lightweight messaging protocol implemented for small sensors, but there is actually a JavaScript implementation called MQTT.js
. It's a JavaScript implementation, so of course it works in a browser. I think it's a great option for front-end engineers who are working with MQTT/IoT-related projects (for example, creating a dashboard to visualize MQTT data). In this article, I'd like to write about what I did when I tried to connect MQTT.js
to the test server (broker) of Mosquitto™
.
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
1. sendScreenShot (front-end js) method uses subsciber.getImgData() method to capture screenshot of the subscriber (remote participant) and post it to the server. | |
2. On the server we use detectFace() method to detect the facial features in this image and we get a identifier for the detected face (id1) | |
3. we use detectFace() again with the image we want to compare with and we get identifier for the detected face (id2) | |
4. we use verifyFace() method and pass id1 and id2 as the inputs. Microsoft face API compares these two faces and provides a result that includes match/mismatch as well as a score. | |
Reference - | |
1. getImgData() - https://tokbox.com/developer/sdks/js/reference/Subscriber.html#getImgData | |
2. Microsoft Face API - https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236 | |
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 'dart:async'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_localizations/flutter_localizations.dart'; | |
import 'package:intl/date_symbol_data_local.dart' as intl; | |
import 'package:intl/intl.dart' as intl; | |
class _PTBRMaterialLocalizationsDelegate | |
extends LocalizationsDelegate<MaterialLocalizations> { |
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
<?php | |
namespace App\Passport; | |
use App\User; | |
use Lcobucci\JWT\Builder; | |
use Lcobucci\JWT\Signer\Key; | |
use League\OAuth2\Server\CryptKey; | |
use Lcobucci\JWT\Signer\Rsa\Sha256; | |
use Laravel\Passport\Bridge\AccessToken as BaseToken; |
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
package main | |
import "fmt" | |
func main() { | |
// shoppingList is a map that has a map inside it | |
shoppingList := make(map[string]map[string]int) | |
// veggies key points to veggiesMap | |
veggiesMap := map[string]int{"onion": 2, "orka": 3} |
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
/* SELECT test */ | |
SELECT ID, reg_replace(post_content, '<aside class="mashsb-container(.*)">((.|\n)*)<\/aside>', '', TRUE, 2, 0) as content | |
FROM wp_posts | |
WHERE post_content REGEXP('<aside class="mashsb-container(.*)">((.|\n)*)<\/aside>') | |
LIMIT 1 | |
/* Update */ | |
UPDATE wp_posts | |
SET post_content = REGEXP_REPLACE('post_content', '<aside class="mashsb-container(.*)">((.|\n)*)<\/aside>', '') | |
WHERE ID = 469 |
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
package main | |
import ( | |
"database/sql" | |
"encoding/json" | |
"fmt" | |
"log" | |
"time" | |
"github.com/go-sql-driver/mysql" |
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
<?php | |
$opt = getopt('', ['host:', 'port:', 'skey:', 'group:', 'consumer:', 'sleep:']); | |
$host = isset($opt['host']) ? $opt['host'] : 'localhost'; | |
$port = isset($opt['port']) ? $opt['port'] : '6379'; | |
$skey = isset($opt['skey']) ? $opt['skey'] : 'stream'; | |
$group = isset($opt['group']) ? $opt['group'] : 'group'; | |
$consumer = isset($opt['consumer']) ? $opt['consumer'] : 'Alice'; | |
$sleep = isset($opt['sleep']) ? $opt['sleep'] : 100000; |
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
<template> | |
<div class="wrapper"> | |
<div class="box" @scroll="handleScroll"> | |
<p>Your content here...</p> | |
</div> | |
<a href="#" v-if="hasScrolledToBottom">Show After Scrolling</a> | |
</div> | |
</template> | |
<script> | |
export default { |
NewerOlder