Skip to content

Instantly share code, notes, and snippets.

View jaygooby's full-sized avatar
✏️
working on https://writiny.com in my sparse spare time

Jay Caines-Gooby jaygooby

✏️
working on https://writiny.com in my sparse spare time
View GitHub Profile
@jaygooby
jaygooby / strip_related_videos.php
Created November 4, 2011 13:51
Always put a rel=0 attribute on Youtube embedded videos so that related videos aren't shown at the end
<?php
// Check if your Wordpress install is vulnerable to
// https://exploitbox.io/vuln/WordPress-Exploit-4-6-RCE-CODE-EXEC-CVE-2016-10033.html
//
// After you've saved this to your docroot/wp-content folder, you can call
// curl -sH "Host: vulnerable" http://example.com/wp-content/vars.php | grep SERVER_NAME | grep vulnerable
// where example.com is your actual wordpress domain.
//
// If you see nothing, you're fine; you're either running nginx or the patched version of Wordpress.
// If you see [SERVER_NAME] => vulnerable, then you should patch ASAP
@jaygooby
jaygooby / monit-alert-slack.sh
Last active April 12, 2017 12:10
Pipe your Monit email alerts into Slack
#!/bin/bash
# Save this file as e.g. /usr/local/bin/monit-alert-slack.sh
# then chmod +x /usr/local/bin/monit-alert-slack.sh
#
# In your /etc/monitrc set a user to get the alerts you
# want pushed to Slack:
#
# set alert monit-alerts@localhost
#
# and then in /etc/aliases set this as the user which
@jaygooby
jaygooby / gist:2170045
Created March 23, 2012 12:02
Replacing text nodes http://stackoverflow.com/a/1175796/391826 patched for MSIE
function htmlreplace(a, b, element) {
if (!element) element = document.body;
var nodes = element.childNodes;
for (var n=0; n<nodes.length; n++) {
// MSIE doesn't have Node
if (nodes[n].nodeType == 3) {
var r = new RegExp(a, 'gi');
// MSIE8 and less doesn't have textContent
if (nodes[n].textContent) {
@jaygooby
jaygooby / README.md
Last active May 19, 2016 15:17
Run your own remote server that you can ssh to? You can use it to host your own private git repositories...

Run your own remote server that you can ssh to? You can use it to host your own private git repositories - they're just directories that have been git init --bare.

Use this script to create new remote repositories, list existing and get simple help for cloning or adding them as remotes.

Save this script to the remote server (e.g. ~/bin/repo-man.sh), and then invoke from your local machine like this:

ssh -t you@example.com "~/bin/repo-man.sh"
@jaygooby
jaygooby / toggle-port-80
Last active December 28, 2015 03:38
Need to toggle between nginx and Apache on your development machine?
#!/bin/bash
#
# Needs to be run as sudo toggle-port-80
#
# because port 80 is a privileged port
#
# Jay Caines-Gooby
# jay@gooby.org
# @jaygooby
@jaygooby
jaygooby / deploy-uxbri.sh
Last active December 26, 2015 05:39
Deploy UX Brighton github pages
#!/bin/bash
#
# Danny, you'll need to change the
# path to the place where you have saved the
# 2013.uxbrighton.org.uk folder
# e.g.
# "/Users/danny/uxbri/2013.uxbrighton.org.uk"
# then save this file to e.g. /usr/local/bin/deploy-uxbri
# make it executable, and then you should be able to make a
# shortcut to that, that you can double click.
@jaygooby
jaygooby / friday-afternoons.html
Created April 17, 2013 08:45
How to embed all six units. As the units become live, they'll stop showing the "Coming Soon" message.
<div class="charanga-embed" data-sqwidget="src:http://fridayafternoons.charanga.com/unit1.js"></div>
<div class="charanga-embed" data-sqwidget="src:http://fridayafternoons.charanga.com/unit2.js"></div>
<div class="charanga-embed" data-sqwidget="src:http://fridayafternoons.charanga.com/unit3.js"></div>
<div class="charanga-embed" data-sqwidget="src:http://fridayafternoons.charanga.com/unit4.js"></div>
<div class="charanga-embed" data-sqwidget="src:http://fridayafternoons.charanga.com/unit5.js"></div>
34 // Redirect admins to the dashboard and other users elsewhere
35 add_filter( 'login_redirect', 'dkis_login_redirect', 10, 3 );
36 function dkis_login_redirect( $redirect_to, $request, $user ) {
37 // Is there a user?
38 if ( is_array( $user->roles ) ) {
39 // Is it an administrator?
40 if ( in_array( 'administrator', $user->roles ) ):
41 return '/wp-admin/';
42 else:
43 if ( in_array( 'teacher', $user->roles ) ):
@jaygooby
jaygooby / content_for_js.tmbundle
Created October 7, 2012 07:20 — forked from hmcfletch/gist:1018085
TextMate javascript syntax highlighting for content_for :javascript_includes and :jquery_ready
// To edit:
// Bundles -> Bundle Editor -> Edit Languages
// Open Ruby on Rails
// Edit HTML (Rails)
// add to the patterns
// Works for <% content_for :jquery_ready do -%>
// <% content_for :javascript_includes do -%>
// and <% javascript_tag do -%>
//