Skip to content

Instantly share code, notes, and snippets.

View christopheranderson's full-sized avatar
🪐
Making the Cosmos (DB) better

Christopher Anderson christopheranderson

🪐
Making the Cosmos (DB) better
View GitHub Profile
@christopheranderson
christopheranderson / upsert-test.js
Created October 9, 2019 23:21
Test using upsert with condition on non-existing always succeeds
//@ts-check
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
const { CosmosClient } = require("@azure/cosmos");
const client = new CosmosClient({
endpoint: "https://localhost:8081",
key:
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
});
@christopheranderson
christopheranderson / index.js
Created March 14, 2019 18:38
ChangeFeed hasMoreResults issue
//@ts-check
const cosmos = require("@azure/cosmos");
const {items} = require("./sampleItems");
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
const {CosmosClient} = cosmos;
const endpoint = process.env.COSMOS_ENDPOINT;
const key = process.env.COSMOS_KEY;
@christopheranderson
christopheranderson / index.ts
Created August 28, 2018 02:10
create-hmac typescript default import
import createHmac from "create-hmac";
const hmac = createHmac("sha256", "hello world").update("I love cupcakes").digest("hex");
console.log(hmac);
@christopheranderson
christopheranderson / body.json
Created January 9, 2018 23:27
Example context object for Azure Functions
{
"invocationId": "a3ea24b8-d262-41d0-a57b-f6a207ade9c2",
"executionContext": {
"invocationId": "a3ea24b8-d262-41d0-a57b-f6a207ade9c2",
"functionName": "hello",
"functionDirectory": "C:\\workspace\\temp\\contextjs\\hello"
},
"log": "[FUNCTION]",
"bindingData": {
"invocationId": "a3ea24b8-d262-41d0-a57b-f6a207ade9c2",
@christopheranderson
christopheranderson / omg.cs
Last active November 15, 2017 00:28
Why would I do this?
using System;
using System.Threading.Tasks;
using EdgeJs;
class Program
{
public static async Task Start()
{
var func = Edge.Func(@"
return function (data, callback) {
@christopheranderson
christopheranderson / run.csx
Created September 8, 2017 20:31
Factory/Singleton pattern in Azure Functions
public class StartUpWork {
private static StartUpWork _singleton;
private string initializeOnce;
public StartUpWork() {
// Do long startup tasks/create database connection pools/whatever you want to happen once
this.initializeOnce = "Woooooo!";
}
public static StartUpWork ensureStartUp() {
@christopheranderson
christopheranderson / host.json
Created May 10, 2017 00:58
Example config for App Insights pipeline
{
"logger": {
"categoryFilter": {
"defaultLevel": "Information",
"categoryLevels": {
"Host.Results": "Error",
"Function": "Error",
"Host.Aggregator": "Information"
}
},
{
"properties": {
"issue_description": {
"type": "number"
},
"issue_title": {
"type": "string"
}
},
"type": "object"
@christopheranderson
christopheranderson / query.sql
Created April 6, 2017 16:15
Analytics Query - Duration percentiles
requests
| where timestamp > ago(30m)
| summarize percentiles(duration, 50, 95, 99) by bin(timestamp, 1m)
| render timechart
@christopheranderson
christopheranderson / azuredeploy.json
Created February 10, 2017 08:54
Function App ARM template with MSDeploy
{
"$schema": "http://schemas.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},