Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dfar-io
dfar-io / sp_index_maintenance.sql
Last active February 21, 2023 19:36
Stored Procedure for cleaning indexes for SQL Server
CREATE PROCEDURE sp_index_maintenance
AS
-- Drop temp table if it exists
IF OBJECT_ID(N'tempdb..#FragmentedIndexes') IS NOT NULL
BEGIN
DROP TABLE #FragmentedIndexes
END
-- Add fragmented indexes to temp table
CREATE TABLE #FragmentedIndexes
@dfar-io
dfar-io / create-pfx-cert.sh
Created February 1, 2022 15:46
Creates a PFX cert using Let's Encrypt
#!/bin/bash
# Creates a PFX certificate using CertBot
# exit when any command fails
set -e
if [ "$1" == "" ] || [ "$2" = "" ]
then
echo "Usage: pfxcert <domain> <output_filename>"
#!/bin/bash
# Adds the appropriate TXT record for creating a Let's Encrypt certificate.
# exit when any command fails
set -e
if [ "$1" == "" ] || [ "$2" == "" ]
then
echo "GODADDY_API_KEY and GODADDY_API_SECRET arguments required."
#!/bin/bash
# Deletes the appropriate TXT record after creating a Let's Encrypt certificate.
# exit when any command fails
set -e
if [ "$1" == "" ] || [ "$2" == "" ]
then
echo "GODADDY_API_KEY and GODADDY_API_SECRET arguments required."
exit 1
@dfar-io
dfar-io / pfx-le-cert.sh
Created October 8, 2020 17:32
Creates a Let's Encrypt Cert using TXT record verification and converts to PFX
# Creates a PFX certificate using CertBot
#
# TODO: Use hooks to implement automation via GoDaddy
# https://certbot.eff.org/docs/using.html#hooks
# exit when any command fails
set -e
if [ "$1" == "" ] || [ "$2" = "" ]
then
@dfar-io
dfar-io / loggly-endpoint.cs
Last active June 15, 2020 23:37
A .NET Core Azure function that forwards EventHub events to a Loggly endpoint
#r "Microsoft.Azure.EventHubs"
using System;
using System.Text;
using Microsoft.Azure.EventHubs;
public static async Task Run(EventData[] events, ILogger log)
{
var exceptions = new List<Exception>();
@dfar-io
dfar-io / extract-bold360-chats.sh
Created June 5, 2020 13:31
Extracts all Bold360 Chats from an account
#!/bin/bash
# Gets all chat messages from a Bold360 account
# you can easily pipe this to output file with:
# ./extract-bold-chat.sh | jq '.Data' > output.json
accountId=[YOUR_ACCOUNT_KEY]
apiSettingId=[YOUR_API_SETTING_KEY]
apiKey=[YOUR_API_KEY]
@dfar-io
dfar-io / vertically-centered-modal
Last active June 5, 2020 13:29
Provides a link to JSFiddle with vertically centered modal
// Can be found at https://jsfiddle.net/jkem8nsz/49/
// HTML
<a href="#" id="text">
click to show modal<br >
</a>
<div id="modal" class="modal-outer">
<div class="modal-middle">
<div class="modal-inner">
@dfar-io
dfar-io / Copy-Sql-Db.ps1
Created May 28, 2020 18:41
Copies a SQL Server database with a different name.
<#
Backs up and optionally restores a SQL Server database.
#>
param (
[Parameter(Mandatory, Position=0)][string]$backupDbName,
[Parameter(Position=1)][string]$restoreDbName
)
$timestamp = $(((get-date).ToUniversalTime()).ToString("yyyyMMddTHHmmssZ"));
# Gets the trade-in value on KBB
var rangeBox = document.getElementById("RangeBox")
var html = rangeBox.innerHTML
html.substring(html.indexOf("y=\"-8") + 8, html.lastIndexOf("</"))