Skip to content

Instantly share code, notes, and snippets.

View daviddarke's full-sized avatar
🚀

David Darke daviddarke

🚀
View GitHub Profile
#!/bin/bash
HN=`hostname | awk -F. '{print $1}'`
# Set variables
DB_BACKUP="~/Dropbox/mysql/$HN-`date +%d-%m-%Y_%H-%M`"
DB_USER="root"
DB_PASSWD="root"
# Create the backup directory
mkdir -p $DB_BACKUP
@daviddarke
daviddarke / deploy.rb
Created May 6, 2015 20:03
Capistrano config files for standard WP deployments
set :application, ''
set :repo_url, ''
set :scm, :git
set :ssh_options, { :forward_agent => true }
set :deploy_via, :remote_cache
set :copy_exclude, [".git", ".DS_Store", ".gitignore", ".gitmodules"]
role :app, %w{root@ip-address}
@daviddarke
daviddarke / Wordpress gitignore
Last active August 29, 2015 14:22
Wordpress gitignore file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
<div class=‘orderMe'>
<div data-order=1>Content 1</div>
<div data-order=4>Content 2</div>
<div data-order=2>Content 3</div>
<div data-order=3>Content 4</div>
</div>
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
<!-- End thumbnails -->
{% assign my_content_array_start = pages.global-blocks.content | split: "<p>[[extraArtBlock start]]</p>" %}
{% assign my_content_array_end = my_content_array_start[1] | split: "<p>[[extraArtBlock end]]</p>" %}
{{ my_content_array_end[0] }}
@daviddarke
daviddarke / update-all-sites.sh
Last active September 19, 2016 12:49
Update all local sites running composer
#!/bin/bash
find . -maxdepth 2 -name 'composer.json' -exec bash -c 'site=$(dirname '{}') && composer update --prefer-dist --working-dir=$site' \;
@daviddarke
daviddarke / structured-data-single.twig
Last active September 23, 2016 09:04
Used for adding structured data to blog post in wordpress
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{post.link}}"
},
"headline": "{{ post.title }}",
"image": {
{% include 'jsonld/structured-data-single.twig' %}
@daviddarke
daviddarke / structured-data-include.php
Created October 4, 2016 08:25
Wordpress version of Google's structured data
<?php
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_image_src( $post_thumbnail_id );
?>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",