Skip to content

Instantly share code, notes, and snippets.

View gwelser's full-sized avatar

Glenn Welser gwelser

  • Punta Gorda, FL
  • 05:14 (UTC -04:00)
View GitHub Profile
@gwelser
gwelser / gitignore_per_git_branch.md
Last active July 29, 2020 17:16 — forked from wizioo/gitignore_per_git_branch.md
HowTo have specific .gitignore for each git branch

Ignoring files and folders needed only for deloyment branches.

Objective

We need a way to ignore compiled css and js assets when working in development branches including master so developers are not stepping on each others toes when committing and merging development branches.

Solution

Create a general .gitignore file for standard ignores. In this file we ignore the usual suspects (e.g.: node_modules, .DS_Store and IDE configuration files and folders.) Then create a .gitignore.default file containing the paths to files and folders to be excluded in development branches. (e.g.: compiled plugin and theme dist folders.)

# WebP Express rules
# --------------------
location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
add_header Vary Accept;
expires 365d;
if ($http_accept !~* "webp"){
break;
}
try_files
/wp-content/webp-express/webp-images/doc-root/$uri.webp
@gwelser
gwelser / blend-mode-alternative.php
Last active November 1, 2017 15:42
Divi Blend-Mode Alternative
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
section.et_pb_fullwidth_header.et_pb_fullwidth_header_0:before {
background: linear-gradient(180deg, rgba(16, 26, 36, .75) 0%, rgba(0, 76, 131, .75) 100%);
content: "";
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
@gwelser
gwelser / reposition-split-logo.js
Created October 27, 2017 13:49
Reposition Divi Split Menu Logo
(function($){
setTimeout(function(){
var $og_logo = $('.centered-inline-logo-wrap');
var $logo = $og_logo.clone();
$og_logo.prev().before($logo);
$og_logo.remove();
$('body').removeClass('hide-logo');
}, 1000);
})(jQuery);
<?php
/**
* Ensure that a specific theme is never updated. This works by removing the
* theme from the list of available updates.
*/
add_filter( 'http_request_args', function ( $response, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/themes/update-check' ) ) {
$themes = json_decode( $response['body']['themes'] );
<?php
/**
* Ensure that a specific plugin is never updated. This works by removing the
* plugin from the list of available updates.
*/
add_filter( 'http_request_args', function ( $response, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/plugins/update-check' ) ) {
$basename = plugin_basename( __FILE__ );
@gwelser
gwelser / FoundationSlider.php
Created January 29, 2016 18:27
Pattern definition for Foundation Slider.
<?php
namespace CNP;
class FoundationSlider extends AtomTemplate {
public function __construct( $data ) {
parent::__construct( $data );
if ( '' == $this->name ) {
@gwelser
gwelser / fix_plugin_order.php
Created January 29, 2016 18:25
The CNP Core plugin must load before other plugins. Use this script to manually fix the order.
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
// paste in serialized options array from db into variable $ser
$ser = 'a:41:{i:0;s:27:"CNP-Spotlight/spotlight.php";i:1;s:21:"EFI-Core/EFI-Core.php";i:2;s:33:"EFI-Infoscreen/efi-infoscreen.php";i:3;s:35:"EFI-User-Import/EFI-User-Import.php";i:4;s:19:"Hey-You/hey-you.php";i:5;s:62:"Post-Select-Extension/contact-form-7-post-select-extension.php";i:6;s:17:"Salvor/Salvor.php";i:7;s:15:"Zelus/zelus.php";i:8;s:34:"advanced-custom-fields-pro/acf.php";i:9;s:21:"cnp-core/CNP-Core.php";i:10;s:79:"contact-form-7-dynamic-text-extension/contact-form-7-dynamic-text-extension.php";i:11;s:36:"contact-form-7/wp-contact-form-7.php";i:12;s:53:"contexture-page-security/contexture-page-security.php";i:13;s:40:"coschedule-by-todaymade/tm-scheduler.php";i:14;s:31:"debug-objects/debug-objects.php";i:15;s:45:"enable-media-replace/enable-media-replace.php";i:16;s:31:"exclude-pages/exclude_pages.php";i:17;s:33:"featured-links/featured-links.php";i:18;s:21:"flaming
@gwelser
gwelser / 0_reuse_code.js
Created January 29, 2016 18:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gwelser
gwelser / gist:7d5e1a0737ea4eb7b808
Created January 30, 2015 16:59
Principal & Interest Payment
/// <summary>
/// Calculates principle & Interest paymnet
/// </summary>
/// <param name="p">Amount of Loan</param>
/// <param name="i">Annual Intesest Rate</param>
/// <param name="l">Length of loan in years</param>
/// <returns>Monthly payment</returns>
public double MonthlyPayment(double p, double i, double l)
{
// M = P * ( J / (1 - (1 + J) ** -N))