Skip to content

Instantly share code, notes, and snippets.

View jredrejo's full-sized avatar

José L. Redrejo Rodríguez jredrejo

View GitHub Profile
@jredrejo
jredrejo / pr.md
Created April 6, 2020 18:26 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jredrejo
jredrejo / pdf-thumbnail-php.md
Created February 24, 2020 18:09 — forked from umidjons/pdf-thumbnail-php.md
Creating PDF thumbnails in PHP

Creating PDF thumbnails in PHP

Install Ghostscript

Download and install right version of ghostscript. In my case my PHP was x86 architecture, so I download Ghostscript 9.14 for Windows (32 bit).

Enable ImageMagick

@jredrejo
jredrejo / class_attribute_test.py
Last active September 18, 2015 15:55 — forked from sente/class_attribute_test.py
Example of how to use __getattribute__(self,name) and __setattr__(self,name,val)
class Foo(object):
def __getattribute__(self, name):
print "getting attribute %s" % name
return object.__getattribute__(self, name)
def __setattr__(self, name, val):
print "setting attribute %s to %r" % (name, val)
return object.__setattr__(self, name, val)
@jredrejo
jredrejo / orm.py
Last active August 29, 2015 14:24 — forked from cxrlospxndo/orm.py
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
# configuracion
# http://docs.sqlalchemy.org/en/rel_0_8/orm/tutorial.html#connecting
eng = create_engine('postgresql://127.0.0.1:5432/erpgenerator?user=erpgenerator&password=erpgenerator')
Session = sessionmaker(bind=eng)
# creando una session
@jredrejo
jredrejo / postgres
Last active October 9, 2017 01:56 — forked from mmrwoods/postgres
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# or dump only ONE database every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dump searchprice --clean" | gzip -9 > /var/local/backup/postgres/searchprice_db.sql.gz
# dump only ONE table every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dump -t track_item_click searchprice --clean" | gzip -9 > /var/local/backup/postgres/track_item_click.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"