Skip to content

Instantly share code, notes, and snippets.


Ian Channing ianchanning

View GitHub Profile
ianchanning / wp-bcrypt.php
Last active May 11, 2016
internationalized version of wp-bcrypt
View wp-bcrypt.php
* Plugin Name: wp-bcrypt
* Plugin URI:
* Description: wp-bcrypt switches WordPress's password hashes from MD5 to bcrypt, making it harder for them to be brute-forced if they are leaked.
* Author: dxw
* Author URI:
* Version: 1.0.2
* Licence: GPL2
View xkcd_pw.js
// Copyright (c) 2011, Jeff Preshing
// All rights reserved.
// Some parts based on, copyright 2003 David Finch.
// Released under the Modified BSD License:
// Redistribution and use in source and binary forms, with or without
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);
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
%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

This is my attempt at converting a solution to a pascal's triangle problem that I'd written in an imperitive manner into a functional one. I kind of hope that anyone reading this is also trying to figure out the meanings behind functional programming, I'm trying to describe all the steps that I go through.

It is a mini way of me trying to discover what being 'declarative' actually means.

I know the kind of definition e.g.:

  1. "say what you want" not "how to do it"
  2. picture vs recipie
  3. sqrt(2) vs looping from x = 1 finding the mean of x and 2/x
  4. SQL, Haskell vs C++, Java
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
ianchanning / doskey.bat
Last active Feb 3, 2016
Dos command history
View doskey.bat
doskey /history >> %USERPROFILE%\history.txt%

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 /
Last active Sep 8, 2019
What are the differences between segment trees, interval trees, binary indexed trees and range trees?
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!!!
* This code was based off but pretty much all that is left of that are the zeroPad and hand functions