Skip to content

Instantly share code, notes, and snippets.

View ianchanning's full-sized avatar

Ian Channing ianchanning

View GitHub Profile
@ianchanning
ianchanning / .vimrc
Last active April 24, 2017 15:25
.vimrc hacks
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic
" http://amix.dk - amix@amix.dk
"
" Version:
" 5.0 - 29/05/12 15:43:36
"
" Blog_post:
@ianchanning
ianchanning / sublimetext-to-vim-translation.md
Last active April 23, 2017 13:40
Translating Sublime Text into Vim

Translating Sublime Text into Vim

Intro

Coming from a Windows world getting into Vim, to me is almost exactly like the struggles I had learning French or Dutch. I spent 10 years learning French growing up and I can't speak a proper sentence. I then moved from England to the Dutch speaking part of Belgium (Flanders) and I learnt to speak Dutch to a conversational level within 2 years.

If you're going to learn Vim you need to immerse yourself in it. I suspect the majority of Vim users only ever use it to make minor file modifications via SSH. That's what I did anyway.

I've used lots of editors in Windows but the one I prefer now is [Sublime Text][2] (ST). However ST has almost all the exact same commands as other editors, with the one major improvement which is Ctrl+P, we'll come to that later. ST is free to use with a popup once in a while, its a great tool, you should buy a licence.

@ianchanning
ianchanning / casper-google-disco-v2.js
Last active May 16, 2016 09:15
Bowie discography scraping
var links = [];
var casper = require('casper').create();
function getLinks() {
var links = document.querySelectorAll('div#mw-content-text table.wikitable tbody tr td i b a');
return Array.prototype.map.call(links, function(e) {
return 'https://en.wikipedia.org' + e.getAttribute('href');
});
}
@ianchanning
ianchanning / wp-bcrypt.php
Last active May 11, 2016 13:34
internationalized version of wp-bcrypt
<?php
/**
* Plugin Name: wp-bcrypt
* Plugin URI: http://wordpress.org/plugins/wp-bcrypt/
* 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: http://dxw.com
* Version: 1.0.2
* Licence: GPL2
*
//-------------------------------------------------------------------
// 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
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
ianchanning / BifurDiag.m
Last active April 6, 2016 01:49
A Matlab program to iterate the logistic map - Dana Kester (with slight modifications by me)
% 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

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
ianchanning / doskey-shortcut.bat
Created February 3, 2016 16:41
Shortcut target to save command history to history.log
%windir%\system32\cmd.exe /K doskey exit=doskey/history$g$g%USERPROFILE%\history.log$texit $1 $2
@ianchanning
ianchanning / doskey.bat
Last active February 3, 2016 16:38
Dos command history
doskey /history >> %USERPROFILE%\history.txt%