Skip to content

Instantly share code, notes, and snippets.

View ajtatum's full-sized avatar

AJ Tatum ajtatum

View GitHub Profile
@ajtatum
ajtatum / DirectMuxVideoBlobTrigger.cs
Created June 16, 2023 12:56
Upload to Mux API via Azure Function with Blob Trigger
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text.Json.Serialization;
namespace AJTDigital.Mux
@ajtatum
ajtatum / rankmath.php
Created February 20, 2023 05:21
Articles Custom OG Image
<?
add_filter("rank_math/opengraph/facebook/og_image", function($content) {
if(is_singular('articles') && is_main_query()){
$ogimg = get_post_meta(get_the_ID(), '_dcms_eufi_img', true);
if(isset($ogimg) && !empty($ogimg))
{
return $ogimg;
}
}
return $content;
@ajtatum
ajtatum / ChangeRemotePort.ps1
Created May 17, 2017 16:33
Simple script that allows you to easily change the port number for RDP connections by updating the Registry, Firewall, and the Restarting Terminal Services.
param (
[int]$port = $(Read-Host "Please enter the new RDP port number")
)
# Set the registry value for the port
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Terminal*Server\WinStations\RDP-TCP\ -Name PortNumber -Value $port
#Diable existing remote desktop rules
Set-NetFirewallRule -DisplayName "Remote Desktop - User Mode (TCP-In)" -Enabled False
Set-NetFirewallRule -DisplayName "Remote Desktop - User Mode (UDP-In)" -Enabled False
@ajtatum
ajtatum / article_schema.json
Created February 12, 2022 22:57
Rank Math Schema
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Place",
"@id": "https://ajtatumdigital.com/#place",
"address": {
"@type": "PostalAddress",
"addressLocality": "Fairfax",
"addressRegion": "VA",
@ajtatum
ajtatum / functions.php
Created January 28, 2022 17:51
Creating Custom WordPress Get Avatar Function
add_filter('get_avatar', 'ajtd_get_avatar', 10, 6);
function ajtd_get_avatar($avatar, $id_or_email, $size, $default, $alt) {
$args['size'] = (int) $size;
$url2x = get_avatar_url($id_or_email, array_merge($args, array('size' => $args['size'] * 2)));
$args = get_avatar_data($id_or_email, $args);
$url = $args['url'];
@ajtatum
ajtatum / country-helper.js
Created August 30, 2021 02:27
JavaScript Country Name To Code and Code To Country Name Functions
var countryNameToCode = {
'Afghanistan': 'AF',
'Aland Islands': 'AX',
'Albania': 'AL',
'Algeria': 'DZ',
'American Samoa': 'AS',
'Andorra': 'AD',
'Angola': 'AO',
'Anguilla': 'AI',
'Antarctica': 'AQ',
@ajtatum
ajtatum / cloudSettings
Last active August 30, 2021 02:26
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-08-30T02:26:20.541Z","extensionVersion":"v3.4.3"}
@ajtatum
ajtatum / docReady.js
Created August 23, 2021 02:04
Pure JavaScript docReady Function
// add event cross browser
function addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent("on" + event, function () {
// set the this pointer same as addEventListener when fn is called
return fn.call(elem, window.event);
});
}
@ajtatum
ajtatum / RedisService.cs
Created January 19, 2021 20:51
Get Redis Cache Keys
public async Task<List<string>> GetCacheKeys()
{
var cacheKeys = new List<string>();
var endpoints = Connection.GetEndPoints();
var keys = Connection.GetServer(endpoints.First()).KeysAsync();
var enumerator = keys.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
var key = enumerator.Current;
@ajtatum
ajtatum / Startup.cs
Created January 15, 2021 23:42
ImageKit Client Hints
var imageCdnUrl = Configuration["CDN:Images:CdnUrl"];
app.Use(async (context, next) =>
{
context.Response.Headers.Add("Accept-CH", "viewport-width, width, dpr");
context.Response.Headers.Add("Feature-Policy", $"ch-viewport-width {imageCdnUrl};ch-width {imageCdnUrl};ch-dpr {imageCdnUrl};ch-device-memory {imageCdnUrl};ch-rtt {imageCdnUrl};ch-ect {imageCdnUrl};ch-downlink {imageCdnUrl}");
context.Response.Headers.Add("Permissions-Policy", $"ch-viewport-width {imageCdnUrl};ch-width {imageCdnUrl};ch-dpr {imageCdnUrl};ch-device-memory {imageCdnUrl};ch-rtt {imageCdnUrl};ch-ect {imageCdnUrl};ch-downlink {imageCdnUrl}");
await next();
});