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 / invite.xml
Created May 24, 2012 14:39
Invite a user to a MUC room
<message to="secret-chat@groups.staging.bonfire.im" id="ab23a" >
<x xmlns="http://jabber.org/protocol/muc#user">
<invite to="twitter.60173@staging.bonfire.im" />
</x>
</message>
@jaygooby
jaygooby / dropbox
Created June 18, 2012 14:29
/etc/init.d script for dropbox on Ubuntu
#!/bin/sh
#
# Copied from http://forums.dropbox.com/topic.php?id=38529#post-414344
# Modified by jay@gooby.org (@jaygooby on Twitter)
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
@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 -%>
//
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 / percona-xtrabackup.sh
Last active May 9, 2022 15:43
Call via crontab on whatever schedule suits you; keep n full mysql Percona xtrabackups of your mysql database, with binary logs applied. Also does a full mysqldump that can then have the binary logs applied to restore to a point-in-time backup via the binlogs. Copy all of this (backup, mysqldump, binlogs) to S3.
#!/bin/bash
#
# Carries out a full mysqldump, calls percona-xtrabackup and then
# copies the sql dump, the percona backup and your mysql bin logs
# to S3 using s3cmd http://s3tools.org/s3cmd
#
# TODO: extract out the S3 backup stuff to make it optional, and so
# other s3 programs can replace the s3cmd call.
# TODO: the if [ $? == 0 ] alert blocks should be a function
# TODO: make the if [ $? == 0 ] if [ $? != 0 ] more consistent - test
@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>
@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 / 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 / double-dropbox.sh
Created February 13, 2014 16:20
Starts Dropbox and Dropbox Encore for OS X in the correct order. Add to your Login Items in System Preferences
#!/bin/bash
#
# To run Dropbox and Dropbox Encore[1] together, you've
# got to start Dropbox first. I *always* forget this,
# so added this script to my Login Items instead
#
# [1] http://www.joyofmacs.com/software/dropboxencore/
#
# Jay Caines-Gooby
# jay@gooby.org

If you import live data into Google Docs spreadsheets using the importdata function and you want to force a refresh at a certain interval, but you also want to ensure that some cache-busting goes on, append a querystring that's the epoch time value that the refresh occurs, so for a sheet that should grab new data every hour you could force an update like this:

importData("http://example.com/data.csv?" & hour(googleclock()) & ")")

But the url requested looks like this: http://example.com/data.csv?11 if the refresh happened at 11am. The next day at 11, the url will be the same, so there's a chance you may get cached data. To get around this, use an epoch time-based refresh. The formula:

=((date(year(googleclock()),month(googleclock()),day(googleclock())) & " " & time(hour(googleclock()), 0, 0)) - DATE( 1970;1;1))*86400

gives you the epoch timestamp for the time at the current hour. If you wanted the timest