Skip to content

Instantly share code, notes, and snippets.

@hasherezade
hasherezade / msil_dec.py
Last active Jul 11, 2020
Helper script for decoding some .NET cryptor
View msil_dec.py
#!/usr/bin/python2.7
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
karpathy / pg-pong.py
Created May 30, 2016
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
View pg-pong.py
""" 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
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: https://www.youtube.com/watch?v=bIhUE5uUFOA
// Code : https://github.com/sean-parent/sean-parent.github.io/wiki/Papers-and-Presentations
/*
Copyright 2013 Adobe Systems Incorporated
Distributed under the MIT License (see license at
http://stlab.adobe.com/licenses.html)
This file is intended as example code and is not production quality.
@karpathy
karpathy / min-char-rnn.py
Last active Aug 19, 2022
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
View min-char-rnn.py
"""
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)
View simple-https-server.py
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@mridgers
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' fireproofgravy.co.uk
//------------------------------------------------------------------------------
#include <stdio.h>
#include <Windows.h>
#include <DbgHelp.h>
@mridgers
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 (