Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stephenharris
stephenharris / copy-pre.css
Last active May 8, 2023 06:46
Adding a 'copy' button to <pre> content
.pre-wrapper{
position:relative;
}
.pre-wrapper pre{
padding-top: 25px;
}
.pre-wrapper .copy-snippet {
border-radius: 0;
min-width:55px;
background: none repeat scroll 0 0 transparent;
@stephenharris
stephenharris / jenkins-ec2-continous-integration.md
Last active May 15, 2023 00:16
How to set up CI with Jenkins on AWS EC2 (and some notes)
@stephenharris
stephenharris / get-local-copy-of-all-remote-branches.sh
Created October 8, 2015 09:38
A oneline script to create tracking branches for all remote branches
# A oneline script to create tracking branches for all remote branches
# @see http://stackoverflow.com/a/4754797/932391
#
git branch -a | grep -v HEAD | perl -ne 'chomp($_); s|^\*?\s*||; if (m|(.+)/(.+)| && not $d{$2}) {print qq(git branch --track $2 $1/$2\n)} else {$d{$_}=1}' | csh -xfs;
@stephenharris
stephenharris / readme.md
Last active April 10, 2023 06:53
Suppressing comments from git diff of .po files

How to suppress comments when performing git diff on .po files.

Taken from: http://stackoverflow.com/questions/2006351/gettext-po-files-under-version-control

Changes in the codebase can alter line numberings given in .po 'comments'. While such changes should be committed they make obsecure the actual translation changes made, and make auditing them difficult.

  1. Create /usr/local/bin/strippocomments as given in this gist.
<?php
/*
* Plugin Name: Event Organiser iCal feed work around
* Version: 1.0
* License: GNU General Public License, v2 (or newer)
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Description: Implements a work around for feeds with invalid DTSTART/DTEND properties.
*/
/**
@stephenharris
stephenharris / git-alias.md
Last active December 16, 2016 11:52
An in-progress collection of useful git 'shortcuts' (alias)

.gitconfig

[alias]
        # A simplified graph of branches**
        branchtree = log --oneline --decorate --all --graph --simplify-by-decoration
        
        # Search commit messages

logsearch = !sh -c 'git log -i --all --grep=$1' -

@stephenharris
stephenharris / print-selected.sh
Created April 4, 2015 10:03
Print selected files form the right-click context menu in Nautilus
#!/bin/bash
#
# print-selected.sh
#
# Print files from the right-click context menu in Nautilus.
# Place this script in ~/.local/share/nautilus/scripts & make executable.
#
# @see http://askubuntu.com/questions/319948/printing-multiple-files-from-nautilus
# @see http://www.frenssen.be/content/printing-file-right-click-context-menu-nautilus
for i in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
@stephenharris
stephenharris / eo-theme.php
Created February 20, 2015 10:23
Examples of filters themes can use to easily style Event Organiser Pro's booking form
<?php
/**
* Examples of filters themes can use to easily style Event Organiser Pro's booking form
* The classes used in this example should ensure the booking form looks native to
* any bootstrap based theme.
* Of course, you can change those classes to whatever your theme uses.
**/
@stephenharris
stephenharris / exclude-bookings.php
Last active August 29, 2015 14:15
Excludes bookings for other organisers from Event Organiser's Pro bookings admin page
<?php
/**
* Excludes bookings for other organisers from Event Organiser's Pro bookings admin page
* Applies only to users who do not have permission to manage others' bookings
* (see Settings > Event Organiser > Permissions).
*/
function sod_eo_pro_bookings_for_event_organiser( $clauses, $query ){
global $wpdb;
@stephenharris
stephenharris / register-template.php
Created January 8, 2015 18:35
Allows registering Backbone templates as scripts
/**
* @author Franz Josef Kaiser http://unserkaiser.com/
* @link http://chat.stackexchange.com/transcript/message/19439060#19439060
*/
// Allows registering Backbone templates as scripts
// Add type="text/template" and id="{handle}" for Backbones .tmpl <script>s
add_filter( 'script_loader_tag', function( $html, $handle, $src )
{
$dom = new \DOMDocument;