Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from pprint import pprint | |
class Graph: | |
def __init__(self, directed=False): | |
self._adj_matrix = np.zeros([0,0]) | |
self._nodes = [] | |
self._directed = directed | |
def debug(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nodes = []; | |
const adjMatrix = {}; | |
function breakPieces (shape){ | |
shape = shape.split('\n'); | |
let height = shape.length; | |
let width = shape[0].length; | |
// create a list with the co-ordinates of each '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in {80..20000}; do | |
VBoxManage modifyvm "default" --natpf1 "tcp-port$i,tcp,,$i,,$i"; | |
VBoxManage modifyvm "default" --natpf1 "udp-port$i,udp,,$i,,$i"; | |
done |
WAL-E needs to be installed on all machines, masters and slaves.
Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf
is:
archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
Get Git log in JSON format
git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
The only information that aren't fetched are:
%B
: raw body (unwrapped subject and body)%GG
: raw verification message from GPG for a signed commit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Router = Ember.Router.extend({ | |
location: config.locationType, | |
init: function () { | |
this._super.apply(this, arguments); | |
// Listen for the first transition, and trigger the `setupMapOnFirstLoad` action when it's complete. | |
this.one('willTransition', function (transition) { | |
transition.then(function () { | |
// do something.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gnn (cases, wide, tall, population, iterations, error_fn, error_thresh) { | |
var inputs = cases[0][0].length; | |
var outputs = cases[0][1].length; | |
// declare net, provide input layer | |
var net = [new Array(inputs)]; | |
// create input neurons in input layer | |
for (var i = 0; i < inputs; i++) | |
net[0][i] = {output: 0} | |
// create hidden layers | |
for (var x = 0; x < wide; x++) { |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float[][] verticies = {{ 0 , 0 , 12 }, | |
{ 0.931306 , -2.86627 , 11.6154 }, | |
{ 3.01377 , 0 , 11.6154 }, | |
{ 1.94952 , -6 , 10.2078 }, | |
{ 4.34164 , -3.15439 , 10.7331 }, | |
{ 6.30877 , 0 , 10.2078 }, | |
{ 2.79392 , -8.5988 , 7.89016 }, | |
{ 5.36656 , -6.30877 , 8.68328 }, | |
{ 7.65836 , -3.15439 , 8.68328 }, | |
{ 9.04131 , 0 , 7.89016 }, |