Skip to content

Instantly share code, notes, and snippets.

Daniel d5

Block or report user

Report or block d5

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pbr-reference.md

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 / main.go
Last active Nov 1, 2018
Golang int-valued Min Heap implementation (https://play.golang.org/p/Nr9vYuTCWa) / this code is illustration purpose only / use https://golang.org/pkg/container/heap/ instead /
View main.go
package main
import (
"fmt"
"time"
"math/rand"
)
func main() {
valMax := 100
@d5
d5 / aerospike
Created Jul 26, 2015
Benchmarks: aerospike vs. aerospike-p
View aerospike
$ 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)
View etcd-options.js
'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 Aug 15, 2019
AWS Node.js SDK; EC2 instance creation and termination example
View ec2.js
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();
View gist:8343821
{% if help || help == "" %}
help
{% endif %}
@d5
d5 / nginx.sh
Last active Jan 2, 2016
op: install, start, stop, restart, status example: curl "https://gist.sh/8313139?op=stop,install,start" | sudo sh
View nginx.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 %}
View update_all.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; }
View gist:8312325
#!/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
View nginx.conf
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 }};
}
You can’t perform that action at this time.