Skip to content

Instantly share code, notes, and snippets.

hasherezade /
Last active Jul 11, 2020
Helper script for decoding some .NET cryptor
import argparse
def decode(data, key, offset, extra_rounds):
maxlen = len(data)
keylen = len(key)
j = 0 #key index
num2 = (maxlen - 1) * (extra_rounds + 1)
decoded = bytearray()
karpathy /
Created May 30, 2016
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
martinmoene / value-semantics-sean-parent.cpp
Created Aug 18, 2015
Code from talk: Inheritance Is The Base Class of Evil by Sean Parent at Going Native 2013
View value-semantics-sean-parent.cpp
// Sean Parent. Inheritance Is The Base Class of Evil. Going Native 2013
// Video:
// Code :
Copyright 2013 Adobe Systems Incorporated
Distributed under the MIT License (see license at
This file is intended as example code and is not production quality.
karpathy /
Last active Aug 19, 2022
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
# taken from
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
mridgers / pdbdump.c
Created Jun 21, 2012
Small tool to list and query symbols in PDB files.
View pdbdump.c
// pdbdump.c - dump symbols from .pdb and executable files (public domain).
// - to compile; cl.exe /Ox /Zi pdbdump.c
// -
// - Martin Ridgers, pdbdump 'at'
#include <stdio.h>
#include <Windows.h>
#include <DbgHelp.h>
mridgers / mandel.bat
Created Feb 12, 2012
Mandelbrot set generator in 332 bytes of batch script (with Unix line endings).
View mandel.bat
@echo off
setlocal enabledelayedexpansion
set r=set /a
for /l %%y in (-16,1,16) do (
set l=
for /l %%x in (-57,1,21) do (
set u=0
set v=0
set "j=M.-+l$?+*:="'~-. "
for /l %%i in (0,1,15) do (