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
| /* | |
| * Example of a $some operator workaround using $expr. The document would match if | |
| * purchasedProducts contain at least two of the three provided ObjectIds | |
| */ | |
| const purchasedProducts = [[ObjectId('ID1'), ObjectId('ID2'), ObjectId('ID3')] | |
| db.collection.find({ | |
| purchasedProducts: { $in: purchasedProducts }, | |
| $expr: { |
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
| /* | |
| * Workaround using aggregation pipeline stages to solve what a | |
| * $some operator could have done. | |
| * | |
| * Inspired by this SO answer: https://stackoverflow.com/a/28161130/678801 | |
| */ | |
| const purchasedProducts = [[ObjectId('ID1'), ObjectId('ID2'), ObjectId('ID3')]; | |
| db.collection.aggregate([ |
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
| /* | |
| * Example of a $some operator where the document would match if purchasedDocuments | |
| * contain at least two of the three provided ObjectIds | |
| */ | |
| db.collection.find({ | |
| purchasedProducts: { | |
| $some: [[ObjectId('ID1'), ObjectId('ID2'), ObjectId('ID3')], { $gte: 2 }] | |
| } | |
| }) |
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
| $cert = New-SelfSignedCertificate -DnsName your.domain.com -CertStoreLocation "cert:\LocalMachine\My" -KeyLength 2048 -KeySpec "KeyExchange" | |
| $password = ConvertTo-SecureString -String "Pa$$w0rd" -Force -AsPlainText | |
| Export-PfxCertificate -Cert $cert -FilePath ".\your-certificate.pfx" -Password $password |
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 AzureStorage from 'azure-storage' | |
| import { Context, HttpRequest } from '@azure/functions' | |
| import util from 'util' | |
| const queueService = AzureStorage.createQueueService() | |
| queueService.messageEncoder = new AzureStorage.QueueMessageEncoder.TextBase64QueueMessageEncoder() | |
| const deleteMessage = util.promisify(queueService.deleteMessage).bind(queueService) | |
| const createMessage = util.promisify(queueService.createMessage).bind(queueService) | |
| const getMessage = util.promisify(queueService.getMessage).bind(queueService) |
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
| /** | |
| * Split an array into chunks | |
| * @param array {T[]} Array to split | |
| * @param size {number} Chunk size | |
| */ | |
| const chunkArray = <T>(array: T[], size: number): T[][] => { | |
| const arr: T[][] = [] | |
| for (let i = 0, j = array.length; i < j; i += size) { | |
| arr.push(array.slice(i, i + size)); | |
| } |
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 chunkArray = (array, size) => { | |
| const arr = [] | |
| for (let i = 0, j = array.length; i < j; i += size) { | |
| arr.push(array.slice(i, i + size)); | |
| } | |
| return arr | |
| } |
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
| // Internet Explorer did not support indexOf until IE9 | |
| if (!Array.prototype.indexOf) | |
| { | |
| Array.prototype.indexOf = function(elt /*, from*/) | |
| { | |
| var len = this.length >>> 0; | |
| var from = Number(arguments[1]) || 0; | |
| from = (from < 0) | |
| ? Math.ceil(from) |