Skip to content

Instantly share code, notes, and snippets.

const https = require('https');
const http = require('http');
const getJSON = (options, onResult) => {
console.log('rest::getJSON');
const port = options.port == 443 ? https : http;
let output = '';
const req = port.request(options, (res) => {
@tcha-tcho
tcha-tcho / gist:ee166789bd892970df9c5de440f4c832
Last active June 5, 2024 20:05
Real time fixando valor
let yamldata = {
t: newdata.t
,dt: newdata.dt
,ft: newdata.ft
,spd: newdata.spd
,lat: newdata.lat || 0
,lng: newdata.lng || 0
,ang: newdata.ang
,stp: newdata.stp
,ign: newdata.ign
/* UTILS AND CONSTANTS*/
const SPEED_MULTIPLIER = 1.852;
const DISTANCE_MULTIPLIER = 111.045;
const SETTINGS = {
"default_object_online_timeout": 5
,"valid_by_avg_speed": false
,"min_moving_speed": 6
,"addon.device_tracker_app_login": false
@tcha-tcho
tcha-tcho / company count.md
Last active February 15, 2024 19:43
Comportamento do arquivo company e sua relação com devices e users

Organização de devices e companies

Agregação de dispositivos e organização geral entre a hierarquia de empresas.

Dispositivos sempre ficam lotados em alguma companhia específica. Ela fica identificada no arquivo device:

{// documento device gravado com o nome "<imei>" na collection de devices
  "imei": "<imei>"
  ,"deviceOf": "<companyId>"
@tcha-tcho
tcha-tcho / invoice.js
Last active January 31, 2024 21:11
Invoice_data.js
// [bucket]/<userID>/invoices/invoiceID.json
{
"invoiceID": "Number"
,"by": "UID"
,"createdAt": "Date"
,"legacyLogin": "String"
,"chargeType": "String[event|recurrent|occasional]"
,"userToCharge": {
"name": "String"
,"CPFCNPJ": "String"
@tcha-tcho
tcha-tcho / comparing.html
Created September 14, 2023 14:13
comparing.html
<!doctype HTML>
<html>
<head>
<meta charset="UTF-8">
<!-- <script type="module" src="http://localhost:5000/tracker-net/us-central1/getHistory" /> -->
<!-- <script type="module" src="https://us-central1-tracker-net.cloudfunctions.net/getHistory" /> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.15.3/xlsx.full.min.js" ></script>
const UserScheme = {
uid: {
type: "string"
,match: /[0-9].*/
,required: true
,unique: true
,validate: "uid"
,trim: true
,max: 25
}
@tcha-tcho
tcha-tcho / pelias_toadd.js
Last active August 16, 2023 20:33
code to place on Pelias
const http = require('node:http');
const url = require('url');
function getData(req) {
return new Promise((resolve, reject) => {
const queryObject = url.parse(req.url, true).query;
let body = '';
function res() {
resolve(Object.assign({}, JSON.parse(body||'{}'), queryObject));
}
@tcha-tcho
tcha-tcho / du.Model.js
Last active August 15, 2023 20:31
Small ORM part of the framework duJS
/**
* Module to work with Models and Classes
*/
(function(o){
o.Model = {_:{}};
// o.Model.connection;
// o.Model.connect;
var counter = 0;