Skip to content

Instantly share code, notes, and snippets.

View michaelstoffer's full-sized avatar
:octocat:

Michael Stoffer michaelstoffer

:octocat:
View GitHub Profile
@michaelstoffer
michaelstoffer / getYouTubeID.php
Last active March 25, 2024 13:24
Using PHP and regex to grab the YouTube ID from the URL.
<?php
// youtube.com/v/{vidid}
// youtube.com/vi/{vidid}
// youtube.com/?v={vidid}
// youtube.com/?vi={vidid}
// youtube.com/watch?v={vidid}
// youtube.com/watch?vi={vidid}
// youtu.be/{vidid}
<?
# Upload and attach files (Attachment, ContentVersion, ContentDocument & ContentDocumentLink) to lead in Salesforce
# https://github.com/bjsmasth/php-salesforce-rest-api
# Installation:
# composer require bjsmasth/php-salesforce-rest-api
class Salesforce {
private $log = true;
<?
namespace Client;
class SQL {
private $db_host;
private $db_user;
private $db_pass;
private $db_name;
private $mysqli;
.flex-copy {
@margin: 75px; // Margin between elements
@half-margin: @margin/2;
margin: -@half-margin/2 -@half-margin;
@width: calc(~"100% + @{margin}");
width: @width;
.flex(0, 1, @width);
max-width: @inner-wrapper;
.display-flex;
.flex-wrap-wrap;
<?
$holidays = [
"New Year's Day" => date('Y-m-d', strtotime("1/1")),
"Independence Day" => date('Y-m-d', strtotime("7/4")),
"Veteran's Day" => date('Y-m-d', strtotime("11/11")),
"Christmas Day" => date('Y-m-d', strtotime("12/25")),
"MLK Day" => date('Y-m-d', strtotime("Third Mon of Jan")),
"Pres Day" => date('Y-m-d', strtotime("Third Mon of Feb")),
"Memorial" => date('Y-m-d', strtotime("Last Mon of May")),
"Labor" => date('Y-m-d', strtotime("First Mon of Sep")),
// ResizeObserver polyfill for any browser that doesn't support it
"undefined"==typeof ResizeObserver&&function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ResizeObserver=e()}(this,function(){"use strict";var i=function(){if("undefined"!=typeof Map)return Map;function i(t,n){var i=-1;return t.some(function(t,e){return t[0]===n&&(i=e,!0)}),i}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var e=i(this.__entries__,t),n=this.__entries__[e];return n&&n[1]},t.prototype.set=function(t,e){var n=i(this.__entries__,t);~n?this.__entries__[n][1]=e:this.__entries__.push([t,e])},t.prototype.delete=function(t){var e=this.__entries__,n=i(e,t);~n&&e.splice(n,1)},t.prototype.has=function(t){return!!~i(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(t,e){void 0===e&&(e=null);for(va
(function($) {
// Inject YouTube iframe API script
let tag = document.createElement('script'),
script_tag = document.getElementsByTagName('script')[0];
tag.src = 'https://www.youtube.com/iframe_api';
script_tag.parentNode.insertBefore(tag, script_tag);
let promo = null,
teaser = null,
first_video = false,
<?
// Save UTMs, click IDs, referring URL, and other marketing-related data to include during lead generation
function saveUTMs() {
$parameters = ['source','campaign','medium','term','content'];
if(!isset($_SESSION['UTMs'])) {
$_SESSION['UTMs'] = new stdClass();
foreach($parameters as $param) $_SESSION['UTMs']->{'utm_'.$param} = '';
}
<?
// Place this is in the document root to backup the database to a date-specific SQL backup file outside the document root
error_reporting(E_ALL);
ini_set('display_errrors', 1);
$hostname = 'localhost';
$database = 'database';
$username = 'username';
$password = 'superSTRONGpasswd';
<?
error_reporting(E_ALL);
ini_set('display_errors', 1);
$parent_dir = '/var/home/forefront';
$default_dir = '/var/home/forefront/forefrontdermatology.com/www';
$output_file = $default_dir . '/_MDG_disk_usage.txt';
echo '<pre>';
exec("echo \"Total Usage: `du -hs $parent_dir`\n\" > $output_file"); // Initialize the output file (or empty it if it exists)