Skip to content

Instantly share code, notes, and snippets.

View jameslutley's full-sized avatar
🎯
Focusing

James Lutley jameslutley

🎯
Focusing
View GitHub Profile
@jameslutley
jameslutley / git-log-parser.js
Created February 29, 2020 05:43 — forked from didoo/git-log-parser.js
Git Log Parser & Aggregator
/* eslint-env node */
/* eslint-disable no-console, dot-notation */
const fse = require('fs-extra');
const readline = require('readline');
// const platform = 'mw_less';
// const platform = 'mw_scss';
const platform = 'cosmos';
@jameslutley
jameslutley / WP-HTML-Compression
Created June 6, 2019 02:11 — forked from sethbergman/WP-HTML-Compression
Minify HTML for WordPress without a Plugin - Add to function.php
<?php
class WP_HTML_Compression
{
// Settings
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
// Variables
@jameslutley
jameslutley / uploads.yml
Created May 30, 2019 02:29 — forked from louim/uploads.yml
Drop-in playbook for Trellis to push and pull uploads from the server to your local machine.
---
- name: Sync uploads between environments
hosts: web
remote_user: "{{ web_user }}"
vars:
project: "{{ wordpress_sites[site] }}"
project_root: "{{ www_root }}/{{ site }}"
tasks:
@jameslutley
jameslutley / README.md
Created May 28, 2019 03:39 — forked from bikubi/README.md
Simple Purgecss setup for Roots Sage WordPress starter theme

Why

  1. Sage doesn't come with Purgecss (or uncss, etc.)
  2. Say, we use Bulma -- suddenly dist/main.css grows by 400K!
  3. Let's purge it!
  4. Oh dang, we need to whitelist /\.wp-/, /\.post-type/, /myfancylightbox/...
  5. Wait we are whitelisting pretty much everything from /resource/assets/styles!
  6. Isn't there an option to purge /node_modules/**/* only?
  7. Nope.
  8. purgecss start ignore, strategically placed, to the rescue!
@jameslutley
jameslutley / server-setup.sh
Created April 16, 2019 04:35 — forked from mikestecker/server-setup.sh
Bash script for my server setup with Digital Ocean, Server Pilot with Node, Gulp and Craft
For Buddy to be able to update NGINX and run other commands as root, you need to follow these steps to give the user buddy access.
If no user has been created, follow the guide here to create a user for Buddy:
https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-ubuntu-16-04
1. On ubuntu based systems, run " $ sudo visudo "
2. this will open /etc/sudoers file.
3. If your buddy user is already in that file, then modify to look like this:
buddy ALL=(ALL) NOPASSWD: ALL
@jameslutley
jameslutley / description.markdown
Created January 28, 2019 06:05 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@jameslutley
jameslutley / keybase.md
Created August 13, 2018 05:30
Keybase proof

Keybase proof

I hereby claim:

  • I am jameslutley on github.
  • I am jameslutley (https://keybase.io/jameslutley) on keybase.
  • I have a public key ASB1xBLj-Q_Nnw0gg0vQrWLegSokRL9XICKTKwrrUUMoEAo

To claim this, I am signing this object:

@jameslutley
jameslutley / post.md
Created July 1, 2018 01:26 — forked from LostKobrakai/post.md
Using Laravel-Mix with Phoenix

Introduction

Laravel-Mix is "an elegant wrapper around Webpack for the 80% use case". It has nothing to do with Elixir's Mix and does not require Laravel to work!

Set up

Create a new phoenix application with mix phx.new. You may choose to add the --no-brunch flag to stop brunch from being intiailized, but I personally prefer leaving that in and replacing brunch so that the folder structure is set up for me.

$ mix phx.new demo

Install Laravel-Mix

The Complete Guide to Nested Forms in Phoenix

I recently spent some time dealing with nested forms in Phoenix. Nested forms are great when you want to create multiple database records in a single transaction and associate them with each other. I am new to Phoenix and really struggled to find any resources that helped me with my specific problem. I decided to document what I learned in the process in hopes of helping others that are new to Elixir and Phoenix.

Here is my attempt at a one stop shop to learn everything you will need to know about nested forms. If you would like to view the GitHub repo you can check it out here.

Thanks to Heartbeat and Jose for excellent blog posts on nested forms. Also shoutout to Josh for showing me some examples at Ruby

@jameslutley
jameslutley / up-and-running-with-edeliver-on-do.md
Created June 23, 2018 03:49 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys