Skip to content

Instantly share code, notes, and snippets.

View afonsomota's full-sized avatar

Afonso Oliveira afonsomota

  • IST - Instituto Superior Técnico
  • Lisbon, Portugal
View GitHub Profile
@jcmgray
jcmgray / sgd-for-scipy.py
Created June 18, 2020 19:33
Stochastic gradient descent functions compatible with ``scipy.optimize.minimize(..., method=func)``.
import numpy as np
from scipy.optimize import OptimizeResult
def sgd(
fun,
x0,
jac,
args=(),
learning_rate=0.001,
@eclosson
eclosson / pdf_merger.rb
Created January 11, 2013 18:29
Merging PDFs with Prawn
class PdfMerger
def merge(pdf_paths, destination)
first_pdf_path = pdf_paths.delete_at(0)
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf|
pdf_paths.each do |pdf_path|
pdf.go_to_page(pdf.page_count)