Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Wallkötter FirefoxMetzger

View GitHub Profile
View openssl.cnf
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
x509_extensions = v3_ca # The extentions to add to the self signed cert
string_mask = utf8only
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = AU
countryName_min = 2
View generate.sh
#!/bin/bash
openssl genrsa > certs/private.key
openssl req -new -x509 -config openssl.cnf -key certs/private.key -days 10000 > certs/certificate.crt
openssl x509 -in certs/certificate.crt -text -noout
@FirefoxMetzger
FirefoxMetzger / fully_connected_reader.py
Created Nov 21, 2017
fully_connected_reader.py using Dataset instead of Queues to feed into Tensorflow
View fully_connected_reader.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@FirefoxMetzger
FirefoxMetzger / upload_data.py
Created Jan 17, 2018
How to insert scores to scoreboard
View upload_data.py
import requests
# to be filled in by you
token = "" # if you have signed up at https://scoreboard-190810.appspot.com
# you can find it on the top left corner of the page
environment = "Test-v0" # name of the environment the agent is for
data = {
"name": "My Agent Name", # you wrote it, you get to name it =)
"score": "1337", # replace with actual score
View Dockerfile
version: '3'
services:
registry:
image: registry:2
ports:
- "443:5000"
volumes:
- "/var/lib/boot2docker/certs:/certs"
- "registry_data:/data"
View deploy.sh
#!/bin/bash
docker-machine scp -r . myRegistry:~
docker-machine ssh myRegistry docker load -i registry.tar
docker-machine ssh myRegistry sudo cp -r certs /var/lib/boot2docker
docker-machine ssh myRegistry docker stack deploy --compose-file=docker-compose.yml registry
@FirefoxMetzger
FirefoxMetzger / faster_fully_connected_reader.py
Created Feb 16, 2018
A modification to the tensorflow how_to fully_connected_reader.py that significantly improves performance
View faster_fully_connected_reader.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@FirefoxMetzger
FirefoxMetzger / Residual_Layer.py
Created Mar 31, 2018
Create a residual layer in Keras to be used with Sequential() models
View Residual_Layer.py
from keras.engine.topology import Layer
from keras.layers importActivation, Conv2D, Add
class Residual(Layer):
def __init__(self, channels_in,kernel,**kwargs):
super(Residual, self).__init__(**kwargs)
self.channels_in = channels_in
self.kernel = kernel
def call(self, x):
@FirefoxMetzger
FirefoxMetzger / model_comparison.py
Last active Apr 1, 2018
Comparing two small networks using dense layers. According to Keras' documentation both should be identical
View model_comparison.py
from keras.models import Sequential
from keras.layers import Dense, Flatten
model1 = Sequential()
model1.add(Dense(1, input_shape=(10,10)))
model2 = Sequential()
model2.add(Flatten(input_shape=(10,10)))
model2.add(Dense(1))
@FirefoxMetzger
FirefoxMetzger / parser.py
Created Apr 5, 2018
A small parser with some visualization for go .sgf replays
View parser.py
import numpy as np
import sgf # pip install sgf -- simple parser for the file format
def decode_position(pos_string):
# position in .sgf is char[2] and row-first, e.g. "fd"
positions = "abcdefghijklmnopqrs"
x = positions.index(pos_string[0])
y = positions.index(pos_string[1])
return y, x