Skip to content

Instantly share code, notes, and snippets.


Ian Channing ianchanning

View GitHub Profile
View jquery.chker.js
(function($) {
jQuery.fn.chker = function() {
var timer = $(this);
var timerId = 0;
var tickInterval = 1000;
var dd = timer.find('.day');
var hh = timer.find('.hr');
var mm = timer.find('.min');
var ss = timer.find('.sec');
ianchanning / jquery-chker.htm
Last active May 8, 2016
jQuery timer function
View jquery-chker.htm
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" href="style.css" rel="stylesheet" />
<div id="chker" class="chker">
ianchanning / !.bat
Last active Dec 26, 2016
Basic windows history and bang commands (assuming Git installed)
View !.bat
@echo off
rem simple replacement for linux ! syntax e.g. !591
rem usage: ! N (executes line N of history.log)
rem @link
if "%1"=="" goto Syntax
if "%1"=="/?" goto Syntax
for /f "tokens=*" %%x in ('sed -n "%1{p;q}" %USERPROFILE%\history.log') do echo %%x & cmd /c %%x
goto End
ianchanning /
Created Oct 21, 2014
Sed commands to pull out wp-config database constants
# taken from jplew's excellent SyncDB
# @link
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)
ianchanning /
Last active Aug 29, 2015
Migrate a WordPress sql script from one domain to another
# 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: [config.yml]
die () {
echo >&2 "$@"
exit 1
ianchanning / dismiss.js
Last active Aug 29, 2015
Pure javascript dismissable divs that stay dismissed when you dismiss them
View dismiss.js
* 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
* Make the js less obtrusive
* @link
ianchanning / startserver.bat
Created Aug 10, 2014
Custom Minecraft server script with banned until date and IP address
View startserver.bat
@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 / minecraft-backup-user-saves.bat
Last active Aug 29, 2015
Backup the minecraft saves directory (uses 7-zip)
View minecraft-backup-user-saves.bat
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 / db_swap.bat
Created Aug 10, 2014
Rename a local SQL Server instance
View db_swap.bat
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 / printf.js
Created Jul 20, 2014
printf JavaScript
View printf.js
if (!String.format) {
* printf function
* @link
* @example var fullName = String.format('{0} {1}', firstName, lastName);
* @param {string} format String with replacable parameters
* @returns {string} formatted string
String.format = function(format) {