Skip to content

Instantly share code, notes, and snippets.

View pnmartinez's full-sized avatar

Pablo pnmartinez

  • Spain
View GitHub Profile
@astrojuanlu
astrojuanlu / juego-vida.py
Created November 6, 2012 16:40
Juego de la vida de Conway en Python
# coding: utf-8
"""Juego de la vida de Conway.
Autor: Juan Luis Cano <juanlu001@gmail.com>
El tablero es un array de NumPy, donde 0 significa célula muerta y 1 célula
viva. Se muestra una animación con matplotlib.
"""
@demisjohn
demisjohn / Pickle: Save+Load MPL Figures to file.py
Last active February 11, 2021 15:14
How to use Python's `pickle` to save/load matplotlib Figures to/from a file.
'''
To save python objects of any sort, to a file.
'''
import pickle as pkl
pkl.dump( fig, open('FigureObject.pickle', 'wb') )
pkl.dump( fig, open('FigureObject.pickle', 'wb'), fix_imports=True ) # fix_imports makes it py2x compatible - untested
'''
Load python objects from file
@AtulKsol
AtulKsol / db_backup_commands.md
Last active July 23, 2024 16:33
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@studiotomi
studiotomi / python_profile.sh
Created October 7, 2019 14:23
profile a python process
python3 -m cProfile -s cumulative script.py > profile.txt