Skip to content

Instantly share code, notes, and snippets.

View lucacerone's full-sized avatar

Luca Cerone lucacerone

View GitHub Profile
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
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
@daroczig
daroczig / impala.R
Last active February 2, 2017 17:10
Connect and query Imapala via SSH and Impala-shell from R
#' Connect and query Imapala via SSH and Impala-shell
#' @param query SQL query to run
#' @param host server hostname or IP
#' @param log enable or disable logging of debug/trace messages
#' @return data.table object
#' @export
query_impala <- function(query, host = 'localhost', log = require(futile.logger)) {
## measure time of query
timer <- proc.time()
@lucacerone
lucacerone / pdfcompress
Created February 26, 2014 13:22
Simple bash script to compress pdf files using Ghostscript
#!/usr/bin/env bash
# Compress a pdf using gs.
# Requires in input the compression type, the name of the file to compress and the name of the output file (in this order).
# Example:
# pdfcompress screen MyHighResDocument.pdf MyLowResDocument.pdf
#
# Possible values for compression types are:
# screen , selects low-resolution output similar to the Acrobat Distiller “Screen Optimized” setting.
# ebook , selects medium-resolution output similar to the Acrobat Distiller “eBook” setting.
# printer , selects output similar to the Acrobat Distiller “Print Optimized” setting.
@gabraganca
gabraganca / output_toggle_html.tpl
Last active February 15, 2017 17:37
Template to use with `ipython nbconvert` when generating HTML. With this, all input cell are hidden. Thanks @damianavila for the initial setup (http://www.damian.oquanta.info/posts/hide-the-input-cells-from-your-ipython-slides.html). I have also take some code from the `custom.css` of @olgablot published in http://nbviewer.ipython.org/5357268.
{%- extends 'full.tpl' -%}
{% block input_group -%}
<div class="input_hidden">
{{ super() }}
</div>
{% endblock input_group %}
{%- block header -%}
{{ super() }}
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@rduplain
rduplain / app.py
Created January 19, 2012 17:28
Plot a PNG using matplotlib in a web request, using Flask.
"Plot a PNG using matplotlib in a web request, using Flask."
# Install dependencies, preferably in a virtualenv:
#
# pip install flask matplotlib
#
# Run the development server:
#
# python app.py
#
@wilsaj
wilsaj / flaskplotlib.py
Created March 9, 2011 13:09
Example of rendering a matplotlib image directly to Flask view
from flask import Flask, make_response
app = Flask(__name__)
@app.route("/simple.png")
def simple():
import datetime
import StringIO
import random
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas