Skip to content

Instantly share code, notes, and snippets.

View Blake-C's full-sized avatar

Blake Cerecero Blake-C

View GitHub Profile
@Blake-C
Blake-C / image-optimization.sh
Created March 12, 2020 03:30
Optimizing Images with mogrify & convert
find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | rename --make-dirs --lower-case --keep-extension --expr 's/[^[:alnum:]\/]+/-/g; s/\A-*//; s/[\^-]*$//' --hardlink --trim --prepend='./optimized/'
find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | magick '*.jpg[1000x1000]'
convert *.png -set filename:base "%[basename]" "%[filename:base].jpg"
convert '*.*[700x700]' %03d-opt.jpg
convert '*.*[700x700]' -verbose -quality 80 -set filename:base "%[basename]" "%[filename:base].jpg"
@Blake-C
Blake-C / App.js
Last active June 12, 2019 05:37
Conditional Rendering - React
import React, { Component } from "react"
/*
Challenge:
Given a stateless functional component:
1. Follow the steps necessary to add state to it,
2. Have state keep track of whether the user is logged in or not
3. Add a button that logs the user in/out
a. extra challenge - make the button display "log in" if they're not logged in and "log out" if they are
@Blake-C
Blake-C / drupal-update-notes.md
Last active April 2, 2019 15:10
Updating Drupal Notes

Updating Drupal 7

composer global require drush/drush:8.2.2

Use drush v8 when working on older versions of Drupal.

Run drush up to update core Drupal and modules from CLI.

References:

@Blake-C
Blake-C / sublime-linter-settings
Created November 13, 2018 22:40
Sublime Text Linter Settings
{
"debug": true,
"delay": 0.25,
"lint_mode": "background",
"linters": {
"eslint": {
"@disable": false,
"args": [],
"excludes": [],
"env": {
@Blake-C
Blake-C / gulp.babel.js
Last active July 16, 2018 03:01
Gulp image resize task
// https://www.npmjs.com/package/gulp-gm
// https://www.npmjs.com/package/gulp-newer
gulp.task('images', () => {
return gulp.src( `${dir.theme_components}/images/**/*` )
.pipe( $.newer( `${dir.assets}/images` ) )
.pipe( $.gm( gmfile => {
return gmfile.resize( 1300, 1300 );
}))
.pipe( $.imagemin({
@Blake-C
Blake-C / phpcs_setup.sh
Created July 15, 2018 19:45
PHPCS/WPCS
apt-get update
apt-get install php-xml
composer global require "squizlabs/php_codesniffer=3.*"
mkdir /utilities
cd /utilities
git clone https://github.com/PHPCompatibility/PHPCompatibility.git
cd PHPCompatibility
git checkout tags/8.1.0
@Blake-C
Blake-C / back-button.php
Created January 22, 2016 14:20
PHP Back Button
<?php
$allowed_host = $_SERVER['SERVER_NAME'];
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
?>
<?php if( substr($host, 0 - strlen($allowed_host)) == $allowed_host ) : ?>
<br><p><a class="btn btn-primary" href="<?php echo $_SERVER['HTTP_REFERER'];?>">Back to list</a></p>
<?php else : ?>
<br><p><a class="btn btn-primary" href="<?php echo get_post_type_archive_link('associate-members'); ?>">Back to list</a></p>
<?php endif; ?>
@Blake-C
Blake-C / wp-cli-wordpress-build.sh
Last active November 23, 2015 05:39
WP-CLI Wordpress Build
#!/bin/bash -e
# Resources
# http://www.ltconsulting.co.uk/getting-wp-cli-work-mamp/
# http://www.ltconsulting.co.uk/automated-wordpress-installation-with-bash-wp-cli/
wp-init () {
echo ""
echo "================================================================="
echo "WP CLI WordPress Installer"
@Blake-C
Blake-C / add-to-calendar.html
Created September 2, 2015 21:37
Add to google calendar sample format link
<a href="http://www.google.com/calendar/event?
action=TEMPLATE
&text=[event-title]
&dates=[start-custom format='Ymd\\THi00\\Z']/[end-custom format='Ymd\\THi00\\Z']
&details=[description]
&location=[location]
&trp=false
&sprop=
&sprop=name:"
target="_blank" rel="nofollow">Add to my calendar</a>
@Blake-C
Blake-C / php-errors.php
Created August 26, 2015 18:20
PHP Errors
<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);