Instantly share code, notes, and snippets.

Ian Channing ianchanning

View GitHub Profile
@ianchanning
ianchanning / .eslintrc.json
Last active Nov 25, 2018
A Neural Network in JavaScript. This now has it's own Github repo: https://github.com/ianchanning/neural-network-js
View .eslintrc.json
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
@ianchanning
ianchanning / self-driving-cars-should-replace-amateur-instead-of-professional-drivers.md
Last active Jun 15, 2018
Self-driving cars should replace amateur instead of professional drivers
View self-driving-cars-should-replace-amateur-instead-of-professional-drivers.md
View keybase.md

Keybase proof

I hereby claim:

  • I am ianchanning on github.
  • I am ianchanning (https://keybase.io/ianchanning) on keybase.
  • I have a public key ASB0bBCnW44BV-yA8TYmgkCqhxaDA-WYBGwTSBp9kkWGnQo

To claim this, I am signing this object:

@ianchanning
ianchanning / monad.md
Last active Mar 12, 2018
Yet another monad explanation
View monad.md

tl;dr Here's a really short explanation for JavaScript, as in just the flatmap part.

map is pretty well understood in JavaScript (and I'm assuming you understand it).

So you 'just' need to make the leap to flatmap. Which is mapping something and flattening the result.

Flattening a JavaScript array is concatenating a 2D array into an array.

Longer Python example

Another attempt at explaining monads, using just Python lists and the map function. I fully accept this isn't a full explanation, but I hope it gets at the core concepts.

View datatables.json
{
"data": [
{
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
@ianchanning
ianchanning / .vimrc
Last active Apr 24, 2017
.vimrc hacks
View .vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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 Apr 23, 2017
Translating Sublime Text into Vim
View sublimetext-to-vim-translation.md

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
Bowie discography scraping
View casper-google-disco-v2.js
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
internationalized version of wp-bcrypt
View wp-bcrypt.php
<?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
*
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