Skip to content

Instantly share code, notes, and snippets.

View craigiswayne's full-sized avatar

Craig Wayne craigiswayne

View GitHub Profile
@craigiswayne
craigiswayne / azure-pipelines.yml
Last active May 21, 2023 15:19
Azure Pipeline to Deploy Angular as a Static Web App
trigger:
batch: true
branches:
include:
- '*'
pr:
branches:
include:
- '*'
@craigiswayne
craigiswayne / countdown.pipe.ts
Last active June 4, 2021 13:35
Angular Custom Pipe Countdown Timer Simple
import { Pipe, PipeTransform } from '@angular/core';
import { Observable, timer } from 'rxjs';
import { map } from 'rxjs/operators';
@Pipe({
name: 'countdown'
})
export class CountdownPipe implements PipeTransform {
/**
@craigiswayne
craigiswayne / README.md
Last active August 5, 2019 09:38
Housekeeping Angular Applications

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 July 12, 2019 08:35
Build all DotNet Projects in Directory
#!/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 June 16, 2019 07:22
InquirerJS with URL required Input and Validation
'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 June 12, 2021 23:50
How to Compile Sass \ Scss via NPM - Simple

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 April 18, 2019 08:44
Extract all computed css from an element
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 January 26, 2019 11:03
Batch Create WordPress Posts via wp-cli
###
# 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 June 29, 2019 09:17
Gravity Forms Post Image Upload Preview

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 October 28, 2018 21:51
Create WordPress Posts with Featured Images from WP-CLI
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