Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
import matplotlib.pyplot as plt
import numpy as np
import os
dir_path = os.getcwd()
r, l, t = np.loadtxt(dir_path+'/results/jerk-agentv10/monitor.csv', delimiter=',', unpack=True, skiprows=1)
fig = plt.figure(num=None, figsize=(14, 6), dpi=80, facecolor='w', edgecolor='k')
ax = fig.add_subplot(111)
ax.plot(t, r, c='b', label='Reward',linewidth=0.5)
import numpy as np
import os
dir_path = os.getcwd()
import sys
firstarg=sys.argv[1]
r, _, _ = np.loadtxt(dir_path+'/results/'+firstarg+'/monitor.csv', delimiter=',', unpack=True, skiprows=1)
l, _ = np.loadtxt(dir_path+'/results/'+firstarg+'/log.csv', delimiter=',', unpack=True, skiprows=1)
print('%f%% done, reward: %f' % (max(l)/10000 ,np.mean(r)))
#!/usr/bin/python
import sys
import retro
import numpy as np
from os import listdir
from os.path import isfile, join, isdir, dirname, realpath
from PIL import Image
@tristansokol
tristansokol / starcount.js
Created May 4, 2018 17:23
Sum all stargazers for an entire page of repos for an org, such as github.com/square
Array.prototype.map.call( document.querySelectorAll('a.mr-3[href*="stargazers"]'), function(n){
return Number(n.text.replace(',',''))
}).reduce(function(total,num){return total+num});
@tristansokol
tristansokol / venv jupyter.sh
Created May 7, 2018 00:36
Virtual evironment jupyter notebook
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
(venv) jupyter notebook
# Kernel > Change Kernel > projectname
<template>
<div>
<div id="sq-ccbox">
<!--
You should replace the action attribute of the form with the path of
the URL you want to POST the nonce to (for example, "/process-card")
-->
<form id="nonce-form" novalidate action="path/to/payment/processing/page" method="post">
<div class="errorbox">
<div class="error" v-for="error in errors">
<script>
export default {
name: "paymentForm",
data: function() {
return {
errors: [],
masterpass: false,
applePay: false
};
},
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tristansokol
tristansokol / calc-reward.py
Last active June 5, 2018 04:12
OpenAI Retro Contest tools!
##############################################################
# Calculate the average reward of a set of runs by averaging all the runs, similar to the contest scoring
#
# $ python3 ./scripts/calc_reward.py jerk-agentv12
# 99.900000% done, reward: 6970.131268
#
# https://medium.com/@tristansokol/making-fun-visuals-history-maps-and-other-tool-improvements-eb5ffe187fd3
##############################################################
import numpy as np
@tristansokol
tristansokol / linear-regression-tensorflow.html
Created June 30, 2018 03:53
linear regression with tensorflow
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<div style="width:400px;">
<canvas id="myChart" width="400" height="400"></canvas>
</div>
<button onclick="train()">Train the model 1 step</button>
<script>
const trainX = [
3.3,