Skip to content

Instantly share code, notes, and snippets.

View d5's full-sized avatar

daniel d5

  • Los Angeles, CA
View GitHub Profile

The Game

The concept of PBR is very simple. You program your bot(s) to defeat all other bots on a 2-dimensional grid field. It is a turn-based war simulation game, where each bot decides the action per each turn, and, the simulation continues until there's only one the last bot left in the game.

When the game starts, it places all participating bots in random locations on the map, and, per each game turn, it executes the code of each bots and runs the simulation in a sequential order. Each bot needs to determines which action it wants to perform for each turn:

  • Move: move up/down/left/right
  • Hold: hold in defensive mode
  • Attack: attack another bot
  • Clone: spawn a new clone of itself on the map
@d5
d5 / aerospike
Created July 26, 2015 23:07
Benchmarks: aerospike vs. aerospike-p
$ node main.js -h 192.168.59.103 -T 10s
Sun, 26 Jul 2015 23:01:55 GMT write(tps=5700 timeouts=0 errors=0) read(tps=5695 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=7486 timeouts=0 errors=0) read(tps=7464 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=6740 timeouts=0 errors=0) read(tps=6788 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=7827 timeouts=0 errors=0) read(tps=7820 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=7201 timeouts=0 errors=0) read(tps=7179 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=6062 timeouts=1 errors=0) read(tps=6021 timeouts=3 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=6329 timeouts=0 errors=0) read(tps=6341 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=6244 timeouts=0 errors=0) read(tps=6218 timeouts=0 errors=0)
Sun, 26 Jul 2015 23:01:55 GMT write(tps=7128 timeouts=0 errors=0) read(tps=7160 timeouts=0 errors=0)
'use strict';
const Etcd = require('node-etcd'),
P = require('bluebird'),
async = P.coroutine,
_ = require('lodash'),
assert = require('assert');
function keyToPath(key) {
return '/' + key.replace(/\./g, '/');
@d5
d5 / ec2.js
Last active October 6, 2022 07:30
AWS Node.js SDK; EC2 instance creation and termination example
var aws = require('aws-sdk');
aws.config.update({
accessKeyId: 'YOUR_ACCESS_KEY',
secretAccessKey: 'YOUR_SECRET_KEY',
region: 'us-west-2'
});
var ec2 = new aws.EC2();
@d5
d5 / gist:8343821
Last active January 2, 2016 18:29
{% if help || help == "" %}
help
{% endif %}
@d5
d5 / nginx.sh
Last active January 2, 2016 13:49
op: install, start, stop, restart, status example: curl "https://gist.sh/8313139?op=stop,install,start" | sudo sh
#!/bin/sh
info() { echo "INFO: $1"; }
die() { echo "ERROR: $1. Aborting!"; exit 1; }
{% for o in split(op, ",") %}
{% if o.value == "install" %}
if type yum > /dev/null 2>&1; then
yum install -y nginx
{% else %}
@d5
d5 / update_all.sh
Last active January 2, 2016 13:49
curl "https://gist.sh/8313028" | sudo sh
#!/bin/sh
# RHEL 64bit/32bit
# SUSE 64bit/32bit
# Amazon Linux 64bit/32bit
# Ubuntu 64bit/32bit
info() { echo "INFO: $1"; }
die() { echo "ERROR: $1. Aborting!"; exit 1; }
@d5
d5 / gist:8312325
Last active January 2, 2016 13:49
curl -L "https://gist.sh/8312325" | sudo sh
#!/bin/sh
# Params
# update_all: whether or not to update all packages
info() { echo "INFO: $1"; }
die() { echo "ERROR: $1. Aborting!"; exit 1; }
# stop nginx
curl -L "https://gist.sh/8313139?op=stop" | sudo sh 2> /dev/null
@d5
d5 / nginx.conf
Last active January 2, 2016 04:49
user nginx;
worker_processes {{ worker_procs || 1 }};
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
# max_clients = worker_processes * worker_connections / 4
worker_connections {{ worker_conns || 1024 }};
}
@d5
d5 / bootstrap.sh
Last active December 11, 2019 02:51
#!/bin/sh
info() { echo "INFO: $1"; }
die() { echo "ERROR: $1. Aborting!"; exit 1; }
SRC_ROOT=/usr/local/src
SRC_DIR=$SRC_ROOT/{{ proj_name }}
STATIC_DIR=/usr/share/nginx/html
# stop node apps if they're running