Skip to content

Instantly share code, notes, and snippets.

View Steveorevo's full-sized avatar

Stephen J. Carnam Steveorevo

View GitHub Profile
@Steveorevo
Steveorevo / abcopy
Created September 24, 2023 06:20
Copies a source folder to the destination via rsync -an and fixes *absolute* links. Normally rsync only handles *relative* symbolic. This script searches for absolute links with destinations that are within the source folder and updates them to reflect the destination copy.
#!/bin/bash
#
# Copies a source folder to the destination folder via `rsync -a` and
# fixes *absolute* links. Normally rsync only handles *relative* links
# and preserves absolute links. This script searches for the copied
# absolute links in the destination that are pointing to the original
# source folder and updates them to reflect the new destination copy.
#
# Author: Stephen J. Carnam
# Copyright (c) 2023 Virtuosoft / Stephen J. Carnam
@Steveorevo
Steveorevo / linear_strings.php
Last active February 9, 2023 19:12
Linear version of GStrings' most used parsing methods
<?php
/**
* Deletes the right most string from the found search string
* starting from right to left, including the search string itself.
*
* @return string
*/
function delRightMost( $sSource, $sSearch ) {
for ( $i = strlen( $sSource ); $i >= 0; $i = $i - 1 ) {
$f = strpos( $sSource, $sSearch, $i );
@Steveorevo
Steveorevo / gist:e31b2b8e207c83625245e92049e49762
Created September 2, 2022 00:57
Wild card domain renewal using let’s encrypt
certbot certonly --manual \
--preferred-challenges=dns \
--email admin@website.com \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos \
--manual-public-ip-logging-ok \
-d website.com \
-d *.website.com \
@Steveorevo
Steveorevo / var-styles.js
Created September 1, 2022 06:20
JavaScript style camelcase to PHP style underscore and back
// Underscore to camelcase
function usToCC(str) {
return str.replace(/_([a-z])/g, function (g) { return g[1].toUpperCase(); });
}
// Camelcase to underscore
function ccToUs(str) {
return str.replace(/([a-z][A-Z])/g, function (g) { return g[0] + '_' + g[1].toLowerCase() });
}
@Steveorevo
Steveorevo / gist:7510cc8c718dbb22f8a062271a66109e
Last active August 18, 2022 07:36
Determine if a Node-RED node is enabled and all of its subflow parents and subsequent tab
/**
* isNodeEnabled checks to see if the given node is enabled and is in an enabled tab
* and/or subflow instance (vs just in the palette); checks it's parents/ancestors.
*
* @param {object} RED The RED object for accessing nodes.
* @param {string} node_id The node ID to check for a valid instance.
* @return {boolean} True if the node is a valid enabled instance, false otherwise.
*/
function isNodeEnabled(RED, node_id) {
@Steveorevo
Steveorevo / index.php
Last active March 25, 2023 06:32
The twenty twenty two index.php + generic/minimalist php template support
<?php
// There is nothing output here because block themes do not use php templates.
// There is a core ticket discussing removing this requirement for block themes:
// https://core.trac.wordpress.org/ticket/54272.
?><!DOCTYPE html>
<html>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" />
@Steveorevo
Steveorevo / .gitignore
Last active February 1, 2018 05:39
NRG Web Server
*.backup
.DS_Store
@Steveorevo
Steveorevo / draftcode.php
Created March 7, 2017 07:21
Suggested DraftCode fix.
<?php
if ( !class_exists( 'DraftCode' ) ) {
/**
* Our DraftCode class fixes WordPress compatibility issues.
*/
class DraftCode
{
public function __construct()
{
global $wp_filter;
@Steveorevo
Steveorevo / apt-cyg
Created February 18, 2016 20:50
apt-cyg with lynx fallback
#!/bin/bash
# apt-cyg: install tool for Cygwin similar to debian apt-get
#
# The MIT License (MIT)
#
# Copyright (c) 2013 Trans-code Design
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
<?php
/**
* Place next to wp-blog-header.php. Visit this file to find the time suck.
*/
declare(ticks=1);
register_tick_function('ds_do_profile');
$ds_profile = array();
$ds_last_time = microtime(true);