Skip to content

Instantly share code, notes, and snippets.

@AtomicSmash
AtomicSmash / post-receive
Created February 16, 2014 17:10
This is an example of a GIT "post-receive" hook that check the branch name before deploying
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
git --work-tree=/var/www/domain.com --git-dir=/home/git/repositories/root/testproject.git checkout -f
fi
done
@AtomicSmash
AtomicSmash / wp-xml-import.php
Last active December 30, 2015 20:29
Start of Wordpress import script
<?php
/*
___ __ _ __
/ | / /_____ ____ ___ (_______________ ___ ____ ______/ /_
/ /| |/ __/ __ \/ __ `__ \/ / ___/ ___/ __ `__ \/ __ `/ ___/ __ \
/ ___ / /_/ /_/ / / / / / / / /__(__ / / / / / / /_/ (__ / / / /
/_/ |_\__/\____/_/ /_/ /_/_/\___/____/_/ /_/ /_/\__,_/____/_/ /_/
Wordpress XML importer - with Advanced Custom Fields Support
*/
@AtomicSmash
AtomicSmash / image_replace
Created October 15, 2013 20:07
Bash script to replace underscores
find . -depth -name '* *' \
| while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done
@AtomicSmash
AtomicSmash / get-local-authories.php
Last active December 24, 2015 19:49
INCOMPLETE - So far this script grabs local authority information from openlylocal.com, then output the address and turn the postcode into an array.
<?php
$xml=simplexml_load_file("http://openlylocal.com/councils/all.xml");
echo "<pre>";
//print_r($xml);
echo "</pre>";
@AtomicSmash
AtomicSmash / wp-dropbox-sync.sh
Last active December 23, 2015 18:39
Sync to and from the uploads folder and database of a local Wordpress site to Dropbox
#!/bin/bash
#get folder name
echo "Enter the root folder name of Wordpress"
read name
#Get the database details from wp-config file
WPDBNAME=`cat ~/Sites/$name/wp-config.php | grep DB_NAME | cut -d \' -f 4`
@include font-face('Name', font-files(
"filename.woff", woff,
"filename.ttf", truetype,
"filename.svg", svg),
$weight:normal,
$style:normal);
@AtomicSmash
AtomicSmash / password-alert
Created July 18, 2013 07:34
Hide wordpress password alert
//disable password nag
function stop_password_nag( $val ){
return 0;
}
add_filter( 'get_user_option_default_password_nag' ,'stop_password_nag' , 10 );
@AtomicSmash
AtomicSmash / MYSQL IMPORT
Created July 9, 2013 08:20
MYSQL IMPORT
sudo /Applications/MAMP/Library/bin/mysql -u root -p DATABASE < /SQL/backup.sql
@AtomicSmash
AtomicSmash / MYSQL DUMP
Last active December 19, 2015 12:29
MYSQL DUMP
sudo /Applications/MAMP/Library/bin/mysqldump -u root -p DATABASE > /SQL/backup.sql
@AtomicSmash
AtomicSmash / Wordpress transient
Last active December 16, 2015 17:09
A simple transient testing setup. Saves the current time in the DB and resets it after 5 mins
//Get transient value. If it's expired it will return jolly sod all...
$teat = get_transient( 'cool_cache_name');
//See what's in the variable
if($teat == ""){
//Add the current time as a new transient, good value for testing.
//300 is equal to 5 minute - 60*60*12 is 12 hours
set_transient( 'cool_cache_name', date('G:i'), 300 );
echo(date('G:i'));
}else{