Skip to content

Instantly share code, notes, and snippets.

View phillip-haydon's full-sized avatar
💭
Banana's are yellow.

Phillip Haydon phillip-haydon

💭
Banana's are yellow.
View GitHub Profile
@phillip-haydon
phillip-haydon / setup.sh
Last active January 16, 2021 12:23
Ubuntu (or derivatives) setup
# chmod +x InstallScript.sh
# ./InstallScript.sh
# sudo nano /etc/default/grub
# Clean up any stupid cdrom that gets into the list
sudo sed -i '/cdrom/d' /etc/apt/sources.list
# Notes
# Screen tearing: https://cubethethird.wordpress.com/2016/06/14/eliminate-screen-tearing-with-amd-gpu-on-ubuntu/
# Check boot time: run `systemd-analyze` in terminal.
public static class PostgresServiceCollectionExtensions
{
public static WorkflowOptions UsePostgreSqlLocking(this WorkflowOptions options, string connectionString, string schemaName = "wfc")
{
options.UseDistributedLockManager(sp => new PostgreSqlLockProvider( connectionString, schemaName, sp.GetService<ILoggerFactory>()));
return options;
}
}
public class PostgreSqlLockProvider : IDistributedLockProvider
@phillip-haydon
phillip-haydon / Update-Raygun.ps1
Last active July 28, 2023 10:06
Raygun Agent Update
# UPDATE RAYGUN
# Create Temp Path
$tempPath = "C:\\automated-setup-temp\\"
If (!(Test-Path -Path $tempPath)) {
New-Item -Path $tempPath -ItemType Directory
}
# Configure where you want to download the installer
<template>
<div :class="{ 'is-active': show, 'modal': true }">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">{{title}}</p>
<button
class="delete"
aria-label="close"
@phillip-haydon
phillip-haydon / script.ps1
Created June 7, 2018 10:29
Powershell - Disable Shutdown / Restart buttons on Windows
Install-Module -Name PolicyFileEditor -SkipPublisherCheck -Force
$UserDir = "$env:windir\system32\GroupPolicy\User\registry.pol"
# After manually setting the values in Local Group Policy Editor (gpedit.msc), extract the values our so we can set them
# Get-PolicyFileEntry -Path $UserDir -All
# Disable the Shutdown / Restart options
# http://brandonpadgett.com/powershell/Local-gpo-powershell/
@phillip-haydon
phillip-haydon / Modal.vue
Last active April 26, 2017 05:59
custom modal component vue
<template>
<div id="modal" v-bind:class="{ 'show': show }">
<div class="modal-dialog">
<div class="modal-content">
<div></div>
</div>
</div>
<button v-on:click="$bus.$emit('hide-tm')">Close</button>
@phillip-haydon
phillip-haydon / aggregate_function.sql
Created December 6, 2016 18:06
starting of a postgresql jsonb aggregate function to merge documents together
create or replace function jsonb_or(state jsonb[], current_val jsonb) returns jsonb[] as $$
if (!state) {
state = [];
}
state.push(current_val);
return state;
@phillip-haydon
phillip-haydon / jsonb_merge.sql
Created December 6, 2016 10:17
Deep Merge two jsonb documents in PostgreSQL
CREATE OR REPLACE FUNCTION jsonb_merge(left JSONB, right JSONB) RETURNS JSONB AS $$
var mergeJSON = function (target, add) {
function isObject(obj) {
if (typeof obj == "object") {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return true; // search for first object prop
}
}
@phillip-haydon
phillip-haydon / slow-postgresql-query.sql
Created November 24, 2016 01:56
Rearranged slow query
sql> SELECT lab_name, COUNT(*)
FROM (
SELECT (record ->> 'scientist_id')::BIGINT AS scientist_id
FROM measurements
WHERE
(record ->> 'value_1')::INTEGER = 0 AND
(record ->> 'value_2')::INTEGER = 0 AND
(record ->> 'value_3')::INTEGER = 0
) m
JOIN scientist_labs AS s