Skip to content

Instantly share code, notes, and snippets.

View ianchanning's full-sized avatar

Ian Channing ianchanning

View GitHub Profile
@ianchanning
ianchanning / minecraft-backup-user-saves.bat
Last active August 29, 2015 14:05
Backup the minecraft saves directory (uses 7-zip)
@ECHO OFF
REM Backup the mincraft saves directory (uses 7-zip)
REM @author ICC 10 Aug 2014
REM @licence MIT
REM usage backs up the user saves directory to the current directory
REM gives the filename .minecraft-saves.[User]-[Computer]-YYYY-MM-DD.bak.7z
REM create date in YYYY-MM-DD format
FOR /f "tokens=1-3 delims=/ " %%a IN ('date /t') DO (SET today=%%c-%%b-%%a)
REM Computer name
@ianchanning
ianchanning / db_swap.bat
Created August 10, 2014 13:13
Rename a local SQL Server instance
@ECHO OFF
REM detach, rename and reattach one database to another
REM @author ICC 11 Sep 09
REM @param sting Server name i.e. <Computer Name>\<SQL Server Name> e.g. .\SQLEXPRESS or COCO\SQLEXPRESS
REM @param string Existing database name e.g. mydb
REM @param string New database name e.g. mydb2
REM @return none renames database, detaches database files, renames them and reattaches
REM usage db_swap.bat .\SQLEXPRESS mydb mydb2
REM *** The following error occurs if you use a forward slash not a back slash
@ianchanning
ianchanning / printf.js
Created July 20, 2014 12:50
printf JavaScript
if (!String.format) {
/**
* printf function
* @link http://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format
* @example var fullName = String.format('{0} {1}', firstName, lastName);
*
* @param {string} format String with replacable parameters
* @returns {string} formatted string
*/
String.format = function(format) {
<!DOCTYPE html>
<html>
<head>
<title>Minimal River Reader</title>
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
</head>
<body>
<script>
var theRiver;
function onGetRiverStream (updatedFeeds) {
@ianchanning
ianchanning / upgrade_translated_wordpress_skeleton.sh
Last active August 29, 2015 14:01
Upgrade a translated installation of WordPress-Skeleton
#!/bin/bash
# usage: upgrade_wordpress.sh X.X.X
# This is for upgrading a translated version of WordPress whilst using WordPress-Skeleton
# https://github.com/markjaquith/WordPress-Skeleton
# https://core.trac.wordpress.org/ticket/27752
# licence MIT
die () {
echo >&2 "$@"
exit 1
@ianchanning
ianchanning / app.js
Created February 4, 2014 23:29 — forked from hubgit/app.js
$(function() {
var form = $("form");
var button = form.find("button[type=submit]");
var input = form.find("input[name=postcode]");
var output = form.find("output[name=location]");
var map = L.mapbox.map("map", "hubbox.map-u557d78b").setView([54, 0], 6);
var failed = function(data) {
button.html("Failed");
@ianchanning
ianchanning / row_toggle.js
Last active February 14, 2020 16:17
Pure JavaScript hierarchical table row toggling (plus older jQuery version too)
/**
* Hierarchical table rows object
*
* Pure JavaScript - but comes with a IE9+ warning
*
* @param {object} options tableSelector e.g. 'table'
* parentClass e.g. 'parent'
* collapsedClass e.g. 'hidden'
* childClassPrefix e.g. 'parentId'
* @type function
@ianchanning
ianchanning / svn_upgrade_wordpress.sh
Last active December 24, 2015 13:49
For upgrading WordPress when you've got a subversion installation. Backs up the database then upgrades WordPress to the specified version. A bit odd having subversion commands on github... but hey.
#!/bin/bash
# usage: svn_upgrade_wordpress.sh X.X.X
# http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion
# licence MIT
die () {
echo >&2 "$@"
exit 1
}
@ianchanning
ianchanning / ping.php
Created June 14, 2013 17:17
PHP Ping Packets
<?php
/**
* Ping a host using an IMCP packet
*
* N.B. This function must be called by an administrator / root user as socket_create requires this
*
* @param string $host domain
* @param integer $timeout seconds
* @return mixed False | Response time milliseconds
*