Skip to content

Instantly share code, notes, and snippets.

💭
Learning starts here

David Starr dstarr

💭
Learning starts here
Block or report user

Report or block dstarr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dstarr
dstarr / provision.sh
Created Jun 18, 2019
Provisions an app gateway and a scale set
View provision.sh
#!/bin/bash -e
set -e
location="westus2"
resource_group="dms-dev-10-rg"
ag_be_gw="dms-ag-backend-gw"
ag_be_pool="dms-ag-backend-pool"
ag_public_ip="dms-ag-public-ip"
ag_subnet="dms-app-gw-subnet"
View Cosmos_2.cs
private async Task AddSensorData()
{
SensorTickerFactory sensorTickerFactory = new SensorTickerFactory();
for (int i = 0; i < 10; i++)
{
var tick = sensorTickerFactory.GetSensorTick();
await AddSensorTickIfNotExists(tick);
}
}
@dstarr
dstarr / Program3.cs
Last active Mar 7, 2018
Updating the docs my adding 100 degrees to the temperature.
View Program3.cs
private void DeleteAllDocs()
{
List<SensorTick> ticks = _client.CreateDocumentQuery<SensorTick>(_dbcUri).ToList();
foreach (var tick in ticks)
{
Uri docUri = UriFactory.CreateDocumentUri(DbName, CollectionName, tick.Id);
_client.DeleteDocumentAsync(docUri);
Console.WriteLine(@"Deleted: {0}", tick.Id);
}
@dstarr
dstarr / Cosmos_4_ModifyDocs.cs
Last active Mar 7, 2018
Deleting all the files in the Azure Cosmos DB,
View Cosmos_4_ModifyDocs.cs
private async Task ModifyAllDocs()
{
List<SensorTick> docs = _client.CreateDocumentQuery<SensorTick>(_dbcUri).ToList();
foreach (var doc in docs)
{
doc.Temperature += 100;
Uri docUri = UriFactory.CreateDocumentUri(DbName, CollectionName, doc.Id);
await _client.ReplaceDocumentAsync(docUri.ToString(), doc);
Console.WriteLine(@"Updated: {0}", doc.Id);
@dstarr
dstarr / Program.cs
Created Mar 6, 2018
Provision Azure Cosmos DB if needed
View Program.cs
private async Task ProvisionDbIfNeeded()
{
await client.CreateDatabaseIfNotExistsAsync(new Database { Id = dbName });
await client.CreateDocumentCollectionIfNotExistsAsync(
UriFactory.CreateDatabaseUri(dbName),
new DocumentCollection { Id = collectionName }
);
}
@dstarr
dstarr / SensorTick.cs
Created Mar 6, 2018
Simple Entity for Sensor Data
View SensorTick.cs
public class SensorTick
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "temperature")]
public int Temperature { get; set; }
[JsonProperty(PropertyName = "humidity")]
public int Humidity { get; set; }
View ColorSwatch.js
import React from 'react';
import PropTypes from 'prop-types';
const ColorSwatch = (props) => {
let style = {
backgroundColor: props.color,
};
return (
View ColorSwatchClass.js
import React from 'react';
import PropTypes from 'prop-types';
class ColorSwatchClass extends React.Component {
constructor(props) {
super(props);
}
@dstarr
dstarr / gulpfile.js
Created Jun 17, 2016
My gulpfile.js ensuring nodemon doesn't leave a hanging Node.js process when interrupted.
View gulpfile.js
const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
gulp.task('default', launchServer);
function launchServer() {
var restart_called = false;
var nm = nodemon({
You can’t perform that action at this time.