Skip to content

Instantly share code, notes, and snippets.

View benjamenjohnsondev's full-sized avatar
🚀
array[role: FullStack, BE: PHP, FE: JavaScript]

Ben Johnson benjamenjohnsondev

🚀
array[role: FullStack, BE: PHP, FE: JavaScript]
View GitHub Profile
@benjamenjohnsondev
benjamenjohnsondev / Lazy-Load.js
Created December 19, 2019 08:30
Lazy Load images with the intersection observer - change the querySelectorAll to target a single class
var o = new IntersectionObserver(function (a, s)
{
a.forEach(e =>
{
if (e.isIntersecting)
{
e.target.src = e.target.getAttribute("data-ls");
e.target.removeAttribute("data-ls");
s.unobserve(e.target);
}
@benjamenjohnsondev
benjamenjohnsondev / index.php
Last active September 26, 2019 15:51
Wordpress Index for install script
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
@benjamenjohnsondev
benjamenjohnsondev / .bashrc
Created September 14, 2018 09:47
handy aliases
alias prodterm='gnome-terminal --window-with-profile=LIVE'
alias m2='php bin/magento'
alias setphp5.6='
sudo a2dismod php7.0 &&
sudo a2dismod php7.1 &&
sudo a2dismod php7.2 &&
sudo a2enmod php5.6 &&
sudo update-alternatives --set php /usr/bin/php5.6&&
sudo update-alternatives --set phar /usr/bin/phar5.6&&
@benjamenjohnsondev
benjamenjohnsondev / .eslintrc.json
Created September 14, 2018 09:43
Defaults for eslint and jsbeautify for use with VScode
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
@benjamenjohnsondev
benjamenjohnsondev / cloudSettings
Last active March 19, 2019 17:31
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-03-19T17:30:58.785Z","extensionVersion":"v3.2.7"}
version: '3.3'
services:
db:
image: mysql:5.7
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20160309
#
# This is from the root of the server dir - remove the public folder "httpdocs" to init from one level deep
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/benjamenhogben/fb93e46f4825e77e1a9f02a35dec9462/raw/024ca685f8a61e755c45b3391286c173e78d34c1/.gitignore
# to download this file
#
@benjamenjohnsondev
benjamenjohnsondev / button_shortcode.php
Created September 26, 2017 13:25
Add classes to wp links with shortcode
<?php
function button_shortcode( $atts , $content = null ) {
// Attributes
$atts = shortcode_atts(
array(
'url' => '/',
'class' => 'class',
),
$atts
<?php
/**
* Product controller
* @id = product id
*/
class ProductController extends CoreController {
const maxproducts = 18;
protected $itemsPerPage = array(2,23,31,50);
protected $sortByOptions = array(
@benjamenjohnsondev
benjamenjohnsondev / svg.js
Created August 16, 2017 14:25 — forked from cod3cow/svg.js
Replace all SVG images with inline SVG using jQuery
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {