Skip to content

Instantly share code, notes, and snippets.

Samuel engineersamuel

Block or report user

Report or block engineersamuel

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
@engineersamuel
engineersamuel / blog.md
Last active Mar 10, 2020
Managing remote docker-compose with Azure DevOps Deployment Groups
View blog.md

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 Jan 16, 2020
Long-term caching GraphQL queries with Webpack
View blog.md

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
View index.snippet.html
<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
View local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
},
View swaggerSnippet.js
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
...
}
View Swagger.cs
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
Webpack event hook to rewrite index.html
View event.hooks.js
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
Azure IIS static web.config
View web.config.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.html" />
</files>
</defaultDocument>
<rewrite>
<rules>
View action_reducer_do_this.ts
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,
You can’t perform that action at this time.