Skip to content

Instantly share code, notes, and snippets.

View ianchanning's full-sized avatar

Ian Channing ianchanning

View GitHub Profile
@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 / 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
<!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 / 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) {
@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 / 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 / startserver.bat
Created August 10, 2014 13:35
Custom Minecraft server script with banned until date and IP address
@echo off
REM Start server script that won't start before a certain date and gives the IP address
REM current date
for /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set olddate=%%a-%%b-%%c)
REM The server will run on or after this date
set newdate=02-08-2014
set "sdate1=%olddate:~-4%%olddate:~3,2%%olddate:~0,2%"
set "sdate2=%newdate:~-4%%newdate:~3,2%%newdate:~0,2%"
@ianchanning
ianchanning / dismiss.js
Last active August 29, 2015 14:07
Pure javascript dismissable divs that stay dismissed when you dismiss them
/**
* Dismissable divs that stay dismissed when you dismiss them
*
* Besides the dismiss/check its also a generic Cookie monster
*
* The cookie code is intially from the uk-cookie-consent plugin
* @link https://wordpress.org/plugins/uk-cookie-consent/
*
* Make the js less obtrusive
* @link http://www.w3.org/wiki/The_principles_of_unobtrusive_JavaScript
@ianchanning
ianchanning / wordpress_migrate.sh
Last active August 29, 2015 14:07
Migrate a WordPress sql script from one domain to another
#!/bin/bash
# mysqldump your product database to database_name_here.sql
# transfer it to this file's directory on another server
# copy wordpres_migrate.yml to this file's directory and update the variables
# usage: wordpress_migrate.sh [config.yml]
die () {
echo >&2 "$@"
exit 1
}
@ianchanning
ianchanning / extract-wp-config-db.sh
Created October 21, 2014 13:56
Sed commands to pull out wp-config database constants
# taken from jplew's excellent SyncDB
# @link https://github.com/jplew/SyncDB/blob/master/syncdb
all_db_name=$(sed -n "s/.*DB_NAME', '\([^']*\)'.*/\1/p" wp-config.php)
all_db_user=$(sed -n "s/.*DB_USER', '\([^']*\)'.*/\1/p" wp-config.php)
all_db_pass=$(sed -n "s/.*DB_PASSWORD', '\([^']*\)'.*/\1/p" wp-config.php)
all_db_host=$(sed -n "s/.*DB_HOST', '\([^']*\)'.*/\1/p" wp-config.php)