Skip to content

Instantly share code, notes, and snippets.

View johnlpage's full-sized avatar

John Page johnlpage

  • MongoDB Inc.
  • Glasgow
View GitHub Profile
const numfont = [24, 36, 44, 36, 52, 36, 24, 0, 8, 24, 8, 8, 8, 8, 8, 0, 24, 36,
36, 8, 16, 32, 60, 0, 60, 4, 24, 4, 36, 36, 24, 0, 8, 24, 24, 40, 40, 60, 8, 0,
60, 32, 56, 4, 36, 36, 24, 0, 8, 16, 24, 36, 36, 36, 24, 0, 60, 4, 8, 8, 8, 16, 16,
0, 24, 36, 36, 24, 36, 36, 24, 0, 24, 36, 36, 36, 24, 8, 16
]
async function write_text_num(image, x, y, txt) {
for (let d = 0; d < txt.length; d++) {
let charcode = txt[d].charCodeAt(0);
[{
$match: {
$expr: {
$gt: ["$date", {
$dateSubtract: {
startDate: "$$NOW",
unit: "day",
amount: 7
}
}]
[$setWindowFields: {
partitionBy: "$location",
sortBy: {
date: 1
},
output: {
average: {
$avg: "$temp",
window: {
range: [-60, 60],
exports = async function(arg) {
const axios = require('axios');
const APIKEY = "XXXXXXXXXXXXXXXXXXXf";
const endpoint = `https://api.openweathermap.org/data/2.5/weather?lat=55.7384&lon=-4.216&appid=${APIKEY}`;
try {
weather = await axios.get(endpoint);
if (weather.status == 200) {
console.log(JSON.stringify(weather.data));
const roomtemps = context.services.get("mongodb-atlas").db("energy").collection("roomtemps");
// add this to the roomtemps too for simplicity
from bluepy.btle import Scanner, DefaultDelegate, Peripheral
from pprint import pprint
import time
import pymongo
import datetime
TEMPERATURE_SERVICE_UUID = "e95d6100-251d-470a-a062-fa1922dfa9a8"
TEMPERATURE_CHARACTERISTIC_UUID = "e95d9250-251d-470a-a062-fa1922dfa9a8"
[{
$group: {
_id: {
date: {
$dateTrunc: {date: "$date", unit: "day"}
},
type: "$type"
},
max: { $max: "$reading" },
min: { $min: "$reading" }
[{
$match: {
reading: { $gt: 1000, $lt: 40000 }
}
}, {
$setWindowFields: {
partitionBy: "$type",
sortBy: { date: 1 },
output: {
hourago: {
{
"errInfo": {
"failingDocumentId": "test",
"details": {
"operatorName": "$and",
"clausesNotSatisfied": [
{
"index": 0,
"details": {
"operatorName": "$expr",
var sign = (doc,fields) => {
let toSign=""
fields.forEach(f => { toSign += parseFloat(doc[f]) + "." } )
toSign = toSign.replace(/NaN/,'.')
print(`Signing: ${toSign}`)
iv = 56781234
for(c=0;c<toSign.length;c++) {
v = parseInt(toSign[c])
if(isNaN(v)) v=10; //Dots etc
v += 1; //No point multiplying 0 by anything
doc = {_id: "test", x:1,y:1,s:5.5}
try { db.readonlyfields.insertOne( doc) } catch(e) {print(e.errmsg)}
Document Failed validation