Skip to content

Instantly share code, notes, and snippets.

View lukem512's full-sized avatar

Luke lukem512

View GitHub Profile
// Sort the strings alphabetically, then sort the strings by length
// Naively compare each string to the others and try to find anagrams.
function hasAnagram(strings) {
const sorted = strings.map(s => s.split("").sort().join("")).sort();
return sorted.some((s, i) => {
const sliced = sorted.slice(0, i).concat(sorted.slice(i+1));
return sliced.find(s2 => s == s2);
});
}
@lukem512
lukem512 / logs.sh
Created July 14, 2016 10:21
Some command-line kung-fu
#! /bin/bash
# View the most recent Forever log file
logs=($(ls -t ~/.forever/logs)); less $logs[1]
@lukem512
lukem512 / plasma.html
Last active July 13, 2016 15:50
A JavaScript plasma visualiser
<html>
<head>
<title>Plasma</title>
<meta name="author" content="Luke Mitchell" />
<style>
body {
margin: 0;
padding: 0;
}
@lukem512
lukem512 / midtermproj.m
Last active July 12, 2016 10:25
Genetic Algorithms: Mid-term Project
%% Luke Mitchell, April 2016
%% Question 3
p.('a') = 1/2;
p.('c') = 1/6;
p.('g') = 1/6;
p.('t') = 1/6;
seq = 'acgtacgtacgt';
@lukem512
lukem512 / finalproj.m
Last active July 12, 2016 10:25
Genetic Algorithms: Final Project
% Final Project
% Luke Mitchell (lm0466)
% Main MATLAB script
function finalproj
% Retrieve mtDNA from GenBank
killerwhale = getgenbank('NC_023889');
disp(['Using ', killerwhale.Definition]);
% All organisms are vertebrates
@lukem512
lukem512 / critical.js
Created May 1, 2016 12:19
Find the critical value of the Mann-Whitney U Test (or the Robust Rank Order) using a Monte Carlo simulation
// Luke Mitchell, 2016
"use strict"
var mwu = require('mann-whitney-utest');
const DEFAULT_COUNT = 1000000
const DEFAULT_P = 0.05
function min (us) {
if (us[0] < us[1])
@lukem512
lukem512 / Keybase.md
Created February 25, 2016 16:06
Verification for my Keybase.io Profile

Keybase proof

I hereby claim:

  • I am lukem512 on github.
  • I am lukemitchell (https://keybase.io/lukemitchell) on keybase.
  • I have a public key whose fingerprint is D83E 1825 CCA2 1F1B 0216 3D39 9177 EEC4 EDED 967C

To claim this, I am signing this object:

@lukem512
lukem512 / Shell
Last active February 20, 2016 12:58
Convert an image into a favicon with multiple sizes using ImageMagick
convert image.png -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
-delete 0 -colors 256 favicon.ico
@lukem512
lukem512 / tree.c
Last active August 29, 2015 14:19
Binary Tree ADS
/*
*
* Principles of programming, coursework 1 [100%]
* Luke Mitchell - lm0466
* 08/12/2011
*
*/
#include <stdio.h>
#include <string.h>
@lukem512
lukem512 / elf_hash.c
Created April 13, 2015 09:47
Hash Table ADS
int hash (int table_size, char* data)
{
unsigned h = 0, g;
int len = strlen (data);
int i;
for ( i = 0; i < len; i++ ) {
h = ( h << 4 ) + data[i];
g = h & 0xf0000000L;