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
"use strict"; | |
let scope = {}; | |
(function twoWayDataBinding() { | |
let bindingItems = document.querySelectorAll('[tw-binding]'); | |
// loop through all bindable elements | |
bindingItems.forEach((e) => { |
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
// where the magic happens | |
function createElement(type, props, text) { | |
const elem = document.createElement(type); | |
Object.keys(props).forEach(prop => elem[prop] = props[prop] ); | |
const textNode = document.createTextNode(text); | |
elem.appendChild(textNode); | |
return elem |
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 whoAmI = async () => { | |
/** | |
* * 1. Create the query | |
* * 2. Send the query and get the response as object | |
* * 3. If there was an error then throw it | |
* * 4. Otherwise return the result | |
*/ | |
// * 1 | |
const query = "{ whoAmI { id profilePicture email confirmed } }"; |
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 MongoClient = require("mongodb").MongoClient; | |
(async function() { | |
const newDbName = "my-new-db"; | |
const newDbUser = "test"; | |
const newDbPwd = "test"; | |
const newCollection = "my-new-collection"; | |
// ? Create a new user for a new database | |
console.time("CreateNewUser"); |
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
/****************************************************************************** | |
Read Temperature and Humidity | |
DHT22 Hardware Connections (Breakoutboard to ESP32): | |
OUT to GPIO 0 | |
- to GND | |
+ to 3.3V | |
******************************************************************************/ |
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 _setAudioTime = (e, line) => { | |
let offset = 15, //15 because has a padding left of 15 px | |
clickedX = e.clientX - offset, | |
elementWidth = line.clientWidth, | |
percentClicked = clickedX * 100 / elementWidth, | |
audioDuration = _audioElem.duration; | |
let timeClicked = percentClicked * audioDuration / 100; | |
_audioCircle.style.left = percentClicked + '%'; |
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
this.notifications = this.notifications.filter( | |
(notification) => !idOfSelectedNotifications.includes(notification._id) | |
); |