Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Channing ianchanning

View GitHub Profile
@ianchanning
ianchanning / jquery.chk.js
Last active Oct 13, 2015
A general object for ticking a set of values up or down
View jquery.chk.js
(function($) {
/**
* A general object for ticking a set of values up or down
*
* Each tick is done on a unit (e.g. hour / minute / second)
* And compared against all the fractions of the unit e.g. seconds are fractions of a minte
* Short for chained tick I think of it as 'chuck' rather than 'check', i.e. 'chuck up'
* Also see: @link https://en.wikipedia.org/wiki/!!!
*
* This code was based off https://github.com/kellishaver/stopwatch but pretty much all that is left of that are the zeroPad and hand functions
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
ianchanning / svn_upgrade_wordpress.sh
Last active Dec 24, 2015
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.
View svn_upgrade_wordpress.sh
#!/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 / doskey.bat
Last active Feb 3, 2016
Dos command history
View doskey.bat
doskey /history >> %USERPROFILE%\history.txt%
@ianchanning
ianchanning / doskey-shortcut.bat
Created Feb 3, 2016
Shortcut target to save command history to history.log
View doskey-shortcut.bat
%windir%\system32\cmd.exe /K doskey exit=doskey/history$g$g%USERPROFILE%\history.log$texit $1 $2
View segment-trees.md

Segment Trees

Wow they seem overly complex to learn about. They're a very easy concept, but there is a paucity of resources for explaining them.

Have a gander at the resources at the bottom for the ones I came across. Took me ages to figure out the differences between them.

Here, I assume you know about Binary Trees and recursion on Binary Trees.

Any code is in python which is about as close to pseudo code as you can get.

@ianchanning
ianchanning / BifurDiag.m
Last active Apr 6, 2016
A Matlab program to iterate the logistic map - Dana Kester (with slight modifications by me)
View BifurDiag.m
% http://www.po.gso.uri.edu/tracking/tracking/chaos/presentations/bifurcationmicroscope/
%BifurDiag.m is a Matlab program to construct a bifurcation diagram for the logistic map
%to allow exploring the period doubling route to Chaos. Dana Kester, Oct. 2002
% The logistic map is x[t+1] = r*x[t]*(1-x[t]) where 0 < r < 4 is a parameter
% value and 0 < x[t] < 1 is a variable. The user specifies the following:
% rmin = the lowest value of r to three decimals (or maybe two decimals)
% rmax = the highest value of r to three decimals (or maybe two decimals)
% xo = initial value of x[t]
% num = number of iterations
@ianchanning
ianchanning / jquery-chker.htm
Last active May 8, 2016
jQuery timer function
View jquery-chker.htm
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>chker</title>
<link type="text/css" href="style.css" rel="stylesheet" />
</head>
<body>
<div id="chker" class="chker">
View hash_verify.php
function login($username, $password) {
$options = array('cost' => 10);
$userdata = 'query to find the user in your framework/PDO prepared query';
$plainText = $password;
if ($userdata['legacy']) {
$password = md5($password);
}
View xkcd_pw.js
//-------------------------------------------------------------------
// Copyright (c) 2011, Jeff Preshing
// http://preshing.com/20110811/xkcd-password-generator
// All rights reserved.
//
// Some parts based on http://www.mytsoftware.com/dailyproject/PassGen/entropy.js, copyright 2003 David Finch.
//
// Released under the Modified BSD License:
//
// Redistribution and use in source and binary forms, with or without