Skip to content

Instantly share code, notes, and snippets.

View cybersholt's full-sized avatar
🏠
Working from home

Sean cybersholt

🏠
Working from home
View GitHub Profile
@cybersholt
cybersholt / closeRDP.cmd
Created December 30, 2023 06:30
RDP Keep Session Active + fix DPI issue
@echo off
:: Get current user's session ID
for /f "tokens=1,2,3 delims= " %%i in ('query session ^| findstr "%USERNAME%"') do set SessionId=%%k
:: Reconnect the session to the console
Tscon %SessionId% /Dest:console
:: Restart Windows Explorer
taskkill /f /im explorer.exe
@cybersholt
cybersholt / plex_duplicates.ps1
Created November 18, 2023 19:00
Find Duplicates in Plex for PowerShell
# Plex duplicate finder for PowerShell written by Sean W. https://cybersholt.com
# Copyright (c) 2023 Sean W. <cybersholt@gmail.com> All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# SPDX-License-Identifier: BSD-3-Clause
# Function to test connectivity to the Plex server
Function Test-PlexConnectivity {
param(
[string]$server,
@cybersholt
cybersholt / update_vuetorrent.sh
Created July 5, 2023 19:21
VueTorrent Self Update
#!/bin/bash
# need to have bsdtar installed to get it on raspberry pi
# sudo apt install libarchive-tools
# Use \033 if you need OS X compatibility
# e.g. RED='\033[0;31m' && echo -e ${RED}"My red text"...
# Reset
Color_Off='\e[0m' # Text Reset
@cybersholt
cybersholt / WingetUpgrade.ps1
Last active January 7, 2024 13:17 — forked from alkampfergit/WingetUpgrade.ps1
Upgrade with Winget being able to select list of software to skip
class Software {
[string]$Name
[string]$Id
[string]$Version
[string]$AvailableVersion
}
# This fixes the character encoding issue
[System.Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
@cybersholt
cybersholt / export_yoast_kw.sql
Created September 22, 2022 20:09
Export Yoast Keywords
SELECT wpp.post_title, wpp.ID, wpp.post_date, mt1.meta_value as focus_keyword,
REPLACE( REPLACE( REPLACE( REPLACE( wpo.option_value, '%year%', DATE_FORMAT(wpp.post_date,'%Y') ), '%monthnum%', DATE_FORMAT(wpp.post_date, '%m') ), '%day%', DATE_FORMAT(wpp.post_date, '%d') ), '%postname%', wpp.post_name ) AS permalink
FROM wp_posts wpp
LEFT JOIN wp_postmeta AS mt1 ON (wpp.ID = mt1.post_id AND mt1.meta_key='_yoast_wpseo_focuskw')
JOIN wp_options wpo
ON wpo.option_name = 'permalink_structure'
WHERE wpp.post_type = 'post'
AND wpp.post_status = 'publish'
ORDER BY wpp.post_date DESC;
@cybersholt
cybersholt / functions.php
Created November 4, 2021 17:28
Better Elementor Forms Email Validation Message
<?php
add_action( 'elementor_pro/forms/validation', function ( $record, $ajax_handler ) {
$email = $record->get_field( [ 'id' => 'email' ] );
if ( $email ) {
if ( ! filter_var( $email['email']['value'], FILTER_VALIDATE_EMAIL ) ) {
$ajax_handler->add_error( $email['email']['id'], 'The email address is invalid.' );
}
}
}, 10, 2 );
@cybersholt
cybersholt / s3_ranger.php
Created July 12, 2019 02:48
Ranger like function for s3, get just enough of an image to read the dimensions.
<?php
function s3Ranger($key)
{
// inspired by https://stackoverflow.com/a/4635991/2320760
$s3 = new S3Client(
array(
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => $key,
@cybersholt
cybersholt / stream.php
Last active December 3, 2020 11:36
symfony - streamAction
<?php
// Original @ https://stackoverflow.com/questions/14559371/symfony2-video-streaming
use SplFileInfo;
use RuntimeException;
// Symfony >= 2.1
use Symfony\Component\HttpFoundation\StreamedResponse;
public function streamAction($fileName) {
@cybersholt
cybersholt / getErrorMessages.php
Created February 21, 2019 01:57 — forked from WishCow/getErrorMessages.php
One of the new symfony releases (probably 2.1) broke the previous gist, because $form->getErrors() now returns a sequentially indexed array, instead of a fieldname => errormsg one.
<?php
private function getErrorMessages(\Symfony\Component\Form\Form $form) {
$errors = array();
if ($form->hasChildren()) {
foreach ($form->getChildren() as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getFormErrors($child);
}
@cybersholt
cybersholt / README.md
Created October 23, 2018 15:34 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version