This file contains hidden or 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 securos = require('securos'); | |
| // let vivotekCam = { | |
| // url: "ws://192.168.15.15:888", | |
| // id: "7", | |
| // totalIn: 0, | |
| // totalOut: 0 | |
| // }; | |
| let vivotekCams = [ |
This file contains hidden or 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 express, { Router, Request } from 'express'; | |
| import admin from 'firebase-admin'; | |
| admin.initializeApp({ | |
| credential: admin.credential.applicationDefault() | |
| }); | |
| const db = admin.firestore(); | |
| const router = Router() | |
| router.get('/', async (req, res, next) => { |
This file contains hidden or 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 | |
| // The drupal_set_message() function is being deprecated! | |
| // @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x | |
| // > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. | |
| // > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. | |
| // In some custom code. | |
| \Drupal::messenger()->addMessage('Say something else'); |
This file contains hidden or 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
| var citiesRef = db.collection("cities"); | |
| var query = citiesRef.where("capital", "==", true); | |
| citiesRef.where("state", "==", "CA") | |
| citiesRef.where("population", "<", 100000) | |
| citiesRef.where("name", ">=", "San Francisco") | |
| citiesRef | |
| .where("state", "==", "CA") |
This file contains hidden or 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
| // functions/income/counter.function.js | |
| 'use strict' | |
| const functions = require('firebase-functions') | |
| const admin = require('firebase-admin') | |
| // Prevent firebase from initializing twice | |
| try { admin.initializeApp(functions.config().firebase) } catch (e) {} |
This file contains hidden or 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 PHPFireStore { | |
| class FireStoreDocument { | |
| private $fields = []; | |
| private $name = null; | |
| private $createTime = null; | |
| private $updateTime = null; |
This file contains hidden or 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
| var db = firebase.firestore(); | |
| var content = require("./sourceData.json"); | |
| content && | |
| Object.keys(content).forEach(contentKey => { | |
| const nestedContent = content[contentKey]; | |
| if (typeof nestedContent === "object") { | |
| Object.keys(nestedContent).forEach(docTitle => { | |
| firebase | |
| .firestore() |
This file contains hidden or 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 Drupal\my_module\Form; | |
| use Drupal\Component\Datetime\TimeInterface; | |
| use Drupal\Core\Entity\EntityFormBuilderInterface; | |
| use Drupal\Core\Entity\EntityManagerInterface; | |
| use Drupal\Core\Entity\EntityTypeBundleInfoInterface; | |
| use Drupal\Core\Extension\ModuleHandlerInterface; |
This file contains hidden or 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
| function lotus_cron() { | |
| $result = \Drupal::entityQuery("user") | |
| ->condition('login', strtotime('-6 months'), '<=') | |
| ->execute(); | |
| $storage_handler = \Drupal::entityTypeManager()->getStorage("user"); | |
| foreach ($result AS $user) { | |
| $entity = $storage_handler->load($user); |
This file contains hidden or 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 | |
| use Drupal\file\Entity\File; | |
| use Drupal\image\Entity\ImageStyle; | |
| // File ID. | |
| $fid = 123; | |
| // Load file. | |
| $file = File::load($fid); | |
| // Get origin image URI. | |
| $image_uri = $file->getFileUri(); | |
| // Load image style "thumbnail". |
NewerOlder