Skip to content

Instantly share code, notes, and snippets.

View jonlow's full-sized avatar
💭
On the toilet

Jon Low jonlow

💭
On the toilet
View GitHub Profile
@jonlow
jonlow / createPosts.js
Created November 27, 2019 22:42
Create Posts used on IG gatsby build
const path = require(`path`)
const {
postData,
} = require('../src/fragments/data.js');
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
@jonlow
jonlow / hide-public-pages.php
Created January 29, 2019 00:45
Redirect all Wordpress templates to the login page
<?php
function hide_public_site( $template)
{
wp_redirect( wp_login_url(), 301 );
exit;
}
add_action('template_include', 'hide_public_site');
@jonlow
jonlow / deploy.sh
Created July 3, 2017 02:13
rsync deploy on amazon ec2 with .pem file
rsync -rave "ssh -i /Users/path/pemfile.pem" localDistFolder/ ubuntu@myAmazonec2server:/var/www/productionDistFolder/
@jonlow
jonlow / lastmodifieduser.sql
Last active May 31, 2017 02:30
Get authors of the last modified wordpress posts
select wp_postmeta.post_id, meta_value as 'authorid', user_login, post_title, post_type, post_modified, post_date
from wp_postmeta
inner join wp_posts
on wp_posts.ID = post_id
inner join wp_users
on wp_users.ID = meta_value
where meta_key ='_edit_last'
order by post_modified desc
@jonlow
jonlow / externalWpFunctions.php
Created January 10, 2016 03:26
External php file that can hook into Wordpress (+ Advanced Custom Fields) functions
<?php
include('wp-load.php');
$post = get_post(2);
setup_postdata( $post );
?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
@jonlow
jonlow / loopacf.php
Created January 9, 2016 04:42
Loop Advanced Custom Fields repeater
<?php
// check if the repeater field has rows of data
if( have_rows('related_pages') ):
// loop through the rows of data
while ( have_rows('related_pages') ) : the_row();
$postobject = get_sub_field('page');
@jonlow
jonlow / super.js
Last active September 17, 2015 06:11
SUPER an existing javascript function.
// Existing function is T2.page.popup.open(number)
T2.page.popup.open = (function(_super) {
return function(popupNumber) {
// 1. Add in your custom code here
// e.g someting.completePage()
@jonlow
jonlow / queue.js
Last active August 30, 2016 02:45
var aFunc = [];
function callback(delay) {
setTimeout(function() {
if (aFunc.length > 0) {
console.log(aFunc.length)
aFunc[0]();
aFunc.shift();
@jonlow
jonlow / Vagrantfile
Created June 22, 2015 13:20
Vagrant file with synched folder read/write permission and NFS enabled for performance
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@jonlow
jonlow / .vimrc
Created June 22, 2015 09:38
Vagrant solarized .vimrc
execute pathogen#infect()
syntax enable
colorscheme solarized
hi Normal ctermbg=NONE