Skip to content

Instantly share code, notes, and snippets.

Craig Wayne craigiswayne

View GitHub Profile
@craigiswayne
craigiswayne / README.md
Last active Aug 5, 2019
Housekeeping Angular Applications
View README.md

Managing undocumented and convoluted front-end angular applications is a nightmare as many of you know...

However this document will serve to help those tasked with this management.

tsconfig.json changes

{
  "compilerOptions": {
    "noUnusedLocals": true,
@craigiswayne
craigiswayne / find-and-build-all.sh
Created Jul 12, 2019
Build all DotNet Projects in Directory
View find-and-build-all.sh
#!/bin/bash
###########################################################################################
# Find's All *.csproj files in a directory
# then executes a dotnet build on that project
# if the build fails, it will stop the script execution
###########################################################################################
separator="===============================================================================";
search="*.csproj"
startingDirectory=$PWD;
@craigiswayne
craigiswayne / url-prompt.js
Created Jun 16, 2019
InquirerJS with URL required Input and Validation
View url-prompt.js
'use strict';
var inquirer = require('inquirer');
var questions = [
{
type: 'input',
name: 'url',
message: 'Enter in a URL',
required: true,
validate: function(value) {
@craigiswayne
craigiswayne / setup.md
Last active Jul 28, 2020
How to Compile Sass \ Scss via NPM
View setup.md

How to Setup npm and scss \ sass

npm init
npm install node-sass --save
mkdir -p src/styles
touch src/styles/style.scss

In your generated package.json add the following to your scripts entry

@craigiswayne
craigiswayne / cssFromElement.js
Last active Apr 18, 2019
Extract all computed css from an element
View cssFromElement.js
function getAllCSS(element){
if( !element instanceof HTMLElement ){
console.warn("Select a valid HTML Element before proceeding");
return '';
}
let cssString = '';
const cssObj = window.getComputedStyle(element);
let cssAttributes = [];
@craigiswayne
craigiswayne / create-dummy-posts.sh
Created Jan 26, 2019
Batch Create WordPress Posts via wp-cli
View create-dummy-posts.sh
###
# Creates 30 dummy posts with featured images via placeimg.com
###
POST_TYPE_SLUG=post;
POST_TYPE_SINGULAR_NAME=Post;
for i in {1..31}
do
echo "Creating $POST_TYPE_SINGULAR_NAME i = [$i]";
post_id=$(wp post create --post_name="Entrant $i" --post_title="Entry $i" --post_type="$POST_TYPE_SLUG" --post_status=publish --post_author=1 --post_date="1987-10-$i 00:00:00" --porcelain --allow-root);
echo "post_id = [$post_id]";
@craigiswayne
craigiswayne / README.md
Last active Jun 29, 2019
Gravity Forms Post Image Upload Preview
View README.md

Gravity Forms Post Image Upload Preview

This is the snippet I use for immediately previewing an image loaded with gravity forms post type

You can add this snippet to the bottom of your javascript file or enqueue it using wp_enqueue_script

@craigiswayne
craigiswayne / script.sh
Last active Oct 28, 2018
Create WordPress Posts with Featured Images from WP-CLI
View script.sh
for i in {1..20}
do
post_type="post";
post_type_singular="Entrant";
post_title="$post_type_singular $i";
post_id=$(wp post create --post_author=admin --post_type=$post_type --post_status=publish --post_content="$post_title Content" --post_title="$post_title" --post_excerpt="$post_title Excerpt" --porcelain);
wp media import "https://picsum.photos/480/640/?random&$i.jpeg" --post_id=$post_id --title="Random Image for $post_title" --caption="$post_title Caption" --alt="$post_title Alternative Text" --desc="$post_title Desciption" --featured_image;
done
@craigiswayne
craigiswayne / functions.php
Created Sep 20, 2018
How to Render YouTube Video in WordPress (given the URL)
View functions.php
<?php
$ytURL = https://www.youtube.com/watch?v=dQw4w9WgXcQ;
echo wp_oembed_get( $ytURL );
@craigiswayne
craigiswayne / install-wp-cli-composer-imagick.sh
Last active Jan 29, 2019
Install WP-CLI, Composer and Imagick on Digital Ocean WordPress Droplet (Ubuntu 16)
View install-wp-cli-composer-imagick.sh
echo "Installing WP-CLI...";
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
echo "Installing Composer...";
sudo apt-get update;
sudo apt-get install curl php-cli php-mbstring git unzip -y;
cd ~;
You can’t perform that action at this time.