Skip to content

Instantly share code, notes, and snippets.

View AndrewAllison's full-sized avatar

Andy Allison AndrewAllison

View GitHub Profile
@AndrewAllison
AndrewAllison / search-fundtions.ts
Created November 2, 2021 11:13
Mongo Snippets
// This allows an exact search to be used on an indexed
const scotNamedCharity = await oscrCollection.find({
$text: { $search: `\"${removeStopWords(fund.funderName)}\"` }
}).toArray();
@AndrewAllison
AndrewAllison / array-functions.spec.ts
Last active August 19, 2021 14:14
Some commonly used javascript functions
import { compare } from './array-functions';
describe('array-functions', () => {
it('should sort and array', () => {
const unsortedArray = [
{ order: 0, name: 'item 1' },
{ order: 2, name: 'item 3' },
{ order: 1, name: 'item 2' },
];
const resultsArray = unsortedArray.sort((a, b) =>
@AndrewAllison
AndrewAllison / release_extract_files.yml
Created June 9, 2021 10:39
React to Azure Blob Storage Deploy Via Pipelines
steps:
- task: ExtractFiles@1
displayName: 'Extract files '
inputs:
archiveFilePatterns: '**/$(Build.BuildId).zip'
destinationFolder: '$(agent.builddirectory)'
overwriteExistingFiles: true
@AndrewAllison
AndrewAllison / gormmet-sample.jsx
Created November 18, 2020 20:46
Playing with gormmet
import React, { useState } from 'react';
// eslint-disable-next-line no-unused-vars
import {
Box, Button, Collapsible, Grommet, Heading, Layer, ResponsiveContext,
} from 'grommet';
import PropTypes from 'prop-types';
import { FormClose, Notification } from 'grommet-icons';
const theme = {
global: {
@AndrewAllison
AndrewAllison / PollyPolicyWithRetry.cs
Created September 30, 2020 09:50
Using Polly lib with C# For retries.
var processingPolicy = Policy
.Handle<SageLockingException>()
.Or<SageProductException>()
.WaitAndRetry(delay, onRetry: (exception, timeSpan, context) =>
{
HandleException(result, orderToProcess, exception);
});
var orderResults = processingPolicy.Execute(() => sageOrderHandler.ProcessNewOrder(sageOrder));
trigger:
- master
- develop
- feature/*
pool:
vmImage: 'windows-2019'
variables:
configuration: 'Release'
@AndrewAllison
AndrewAllison / build_deploy_ready.yml
Created July 10, 2020 08:32
Gists relating to yml for azure devops
trigger:
- master
- develop
- feature/*
pool:
vmImage: 'windows-2019'
variables:
configuration: 'Release'
/*
Object Sizes
Modified from http://stackoverflow.com/questions/15896564/get-table-and-index-storage-size-in-sql-server
*/
SELECT
@@SERVERNAME as InstanceName
, DB_NAME() as DatabaseName
, ISNULL(s.name+'.'+t.NAME, '**TOTAL**') AS TableName
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"System": "Information",
"Microsoft": "Warning",
"Hangfire": "Debug"
}
},
"WriteTo": [
@AndrewAllison
AndrewAllison / firebase-example.ts
Created June 7, 2020 11:56
Example of using Firebase with React
import React, { useEffect } from 'react';
import { Link } from "@reach/router";
import { db } from "../_core/firebase";
const HomePage = () => {
const init = async () => {
await db.collection('customers')
.onSnapshot(function (doc) {
let count = 0;