Skip to content

Instantly share code, notes, and snippets.

@engineersamuel
engineersamuel / blog.md
Last active March 10, 2020 17:36
Managing remote docker-compose with Azure DevOps Deployment Groups

Introduction

This blog will detail how to manage remote docker-compose instances with Azure Devops Deployment groups.

I'm going through https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/containers/acr-template?view=azure-devops as a template.

I'm using AzureDevops https://dev.azure.com/, when I signed up it automatically created a project {FirstName}{LastName} for me.

Under Pipelines click Deployment Groups and create a new Deployment Group. You'll need to copy the script and run it on the machine in question. That could be a VM, for this blog I'm testing on my personal laptop.

@engineersamuel
engineersamuel / blog.md
Last active January 16, 2020 23:11
Long-term caching GraphQL queries with Webpack

Introduction

When using Apollo Graphql in the front-end, there is no established pattern to separate out your graphql queries into separate files instead of bundled with the js assets. I've searched and tried many various ways, including webpack file-loader and even modifying file-loader. Actually file-loader will separate it out but it returns a url that points to the filesystem which is not easily consumed. The answer is actually strangly obvious once you see the solution.

TL&DR: If you want to skip ahead to the configuration see What worked at the bottom.

The goal being, having some directory structure like:

  • src
    • graphql
  • users.query.graphql
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: 'http://localhost:7071/api/swagger/openapi.json', oauth2RedirectUrl: 'http://localhost:7071/api/swagger/oauth2-redirect.html',
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
},
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
...
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using CseApi.Functions.Shared;
using CseApi.Helpers.Config;
using CseApi.Helpers.Http;
using Microsoft.AspNetCore.Http;
@engineersamuel
engineersamuel / event.hooks.js
Created May 21, 2018 22:53
Webpack event hook to rewrite index.html
new EventHooksPlugin({
'afterEmit': () => {
const hashedIndexHtml = glob.sync(`${paths.appBuild}/*.html`)[0];
const hash = /index\.(.*?)\.html/.exec(hashedIndexHtml)[1];
const webConfig = fs.readFileSync(`${paths.appBuild}/web.config`).toString();
const result = webConfig.toString().replace(/index\.html/g, `index.${hash}.html`);
fs.writeFileSync(`${paths.appBuild}/web.config`, result);
}
}),
@engineersamuel
engineersamuel / web.config.xml
Created May 21, 2018 22:48
Azure IIS static web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.html" />
</files>
</defaultDocument>
<rewrite>
<rules>
interface IActionUpdateProductNameVersion {
productName: string;
productVersion: string;
}
const requestUpdateProductVersion = createAction<interfaces.IActionUpdateProductNameVersion, void>(types.REQUEST_UPDATE_PRODUCT_VERSION,
(productName: string, productVersion: string) => ({productName, productVersion}),
null
);
const receiveUpdateProductVersion = createAction<interfaces.IActionUpdateProductNameVersion, interfaces.IMetaIsXhrError>(types.RECEIVE_UPDATE_PRODUCT_VERSION,