Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan gustafsson

View GitHub Profile
@gustafsson
gustafsson / pg-pong.jl
Created Feb 23, 2019 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
View pg-pong.jl
# Translation of @karpathy's pg-pong.py from Python to Julia
# https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5
# Note that it takes several days to learn a policy that wins most games.
# Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym through Gym.jl and PyCall.jl.
using Gym
using Serialization
using StatsBase: mean, std
# hyperparameters
View mydeamon.sh
#!/usr/bin/env sh
# ./mydeamon.sh TIMEOUT CHILDAPP
#
# Creates a watchdog file WATCHDOG and executes CHILDAPP WATCHDOG.
# If CHILDAPP exits it is restarted.
# If CHILDAPP does not touch WATCHDOG within TIMEOUT seconds it is killed and restarted.
# This script stops CHILDAPP when it is aborted (Ctrl-C or SIGTERM).
set -e # abort this script if anything fails
SECONDS_UNTIL_KILL=$1
@gustafsson
gustafsson / numeric_palindromes.m
Last active Aug 29, 2015
Number of numeric palindromes in different bases
View numeric_palindromes.m
%% Number of numeric palindromes in different bases
N = zeros(4096,36);
for i=2:size(N,1)
N(i,:) = N(i-1,:);
for b=2:size(N,2)
s = dec2base(i,b);
if all(s == fliplr(s))
N(i,b) = N(i,b) + 1;
end
end
@gustafsson
gustafsson / .gitignore
Created Jun 25, 2013
A .gitignore for Unity Projects. Worked for us. Might completely break your project. To remove previously tracked but now ignored files, run (from a clean working directory): git rm -r --cached .; git add .
View .gitignore
obj
Temp
*.suo
*.user
*.pidb
*.userprefs
*.sln
*.csproj
Library/cache
@gustafsson
gustafsson / freqtime.m
Created May 31, 2012
Illustration of sinusoid in time and frequency domain (Octave script)
View freqtime.m
function freqtime(f)
% The fourier transform below assumes that y is a periodic signal which it is if 'f' is an integer (i.e we don't do any windowing)
if 0==nargin
f = 2;
end
A = 1;
View gist:367790
int MicrophoneRecorder::
writeBuffer(const void *inputBuffer,
void */*outputBuffer*/,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo */*timeInfo*/,
PaStreamCallbackFlags /*statusFlags*/)
{
BOOST_ASSERT( inputBuffer );
const float **in = (const float **)inputBuffer;
const float *buffer = in[0];
View gist:301498
Här är ett exempel på hur man kan hantera textdokument med git i en webbläsare.
Man behöver inget konto för att skapa en gist eller redigera den.
You can’t perform that action at this time.