Skip to content

Instantly share code, notes, and snippets.

View gareth-cheeseman's full-sized avatar

Gareth Cheeseman gareth-cheeseman

View GitHub Profile
@gareth-cheeseman
gareth-cheeseman / TableOwners.sql
Created April 20, 2023 21:13
Table owners postgres
-- Get owners of schema
SELECT
nsp.nspname AS the_schema,
rol.rolname AS the_owner
FROM
pg_namespace nsp
JOIN pg_roles rol ON rol.oid = nsp.nspowner
WHERE
nsp.nspname = 'public';
@gareth-cheeseman
gareth-cheeseman / getEnums.sql
Created April 20, 2023 20:35
Get enum values postgres
SELECT enum_range(NULL::enum_name)
@gareth-cheeseman
gareth-cheeseman / databaseRole.sql
Created April 20, 2023 20:34
get roles postgres
SELECT
U.rolname
,D.datname
FROM
pg_roles AS U JOIN pg_database AS D ON (D.datdba = U.oid)
WHERE
D.datname = current_database()
;
@gareth-cheeseman
gareth-cheeseman / CalendarInfo.cs
Created June 9, 2019 14:15
Class used in UI testing to calculate months and days till passed in day for selecting on UI calendar
public class CalendarInfo
{
public string DateFromString { get; }
public int MonthsTillDateFrom { get; }
public string DateUntilString { get; }
public int MonthsTillUntilDate { get; }
public DateTime DateFromDateTime { get; }
public DateTime DateUntilDateTime { get; }
@gareth-cheeseman
gareth-cheeseman / CustomSortExtension.js
Last active December 21, 2018 12:53
Javascript Array.prototype property custom sort of object by property in order of values in array, and normal function to do the same.
Object.defineProperty(Array.prototype, 'sortByOrder', {
value: function(property, valuesInOrder) {
const map = new Map(
valuesInOrder.map(value => [value, valuesInOrder.indexOf(value)])
);
return this.sort((a, b) => {
return map.get(a[property]) - map.get(b[property]);
});
}
});
@gareth-cheeseman
gareth-cheeseman / ConvertBlob.js
Created December 21, 2018 11:50
Convert blob to data url js
export const blobToDataUrl = blob => {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = () => {
const base64Data = reader.result;
return base64Data;
};
};
@gareth-cheeseman
gareth-cheeseman / CustomLoadProfile.cs
Created April 5, 2018 08:42
Custom Load Profile for VS loadtesting. Must be in root of solution.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.LoadTesting;
namespace Tests
{
public class CustomLoadProfile : ILoadTestPlugin
{
// The initialize method is called just before the load test starts running
@gareth-cheeseman
gareth-cheeseman / HTMLParsingPlugin.cs
Created April 5, 2018 08:38
HTMLParsingPlugin for use with VS loadtesting. Must be file in main solution
using System;
using System.Net.Configuration;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.LoadTesting;
namespace Tests
{
public class HMTLParsingPlugin : ILoadTestPlugin
{
public void Initialize(LoadTest loadTest)