Skip to content

Instantly share code, notes, and snippets.

View ecarreras's full-sized avatar
💡
IT for utilities

Eduard Carreras ecarreras

💡
IT for utilities
View GitHub Profile
for DB in `psql -lAt | grep -v 'eduard' | cut -d '|' -f1`; do if [ -f $DB.sql.bz2 ]; then echo "$DB already dumped"; else echo "Dumping and bziping $DB"; pg_dump $DB | bzip2 | pv > $DB.sql.bz2; fi done
@ecarreras
ecarreras / gist:2991011
Created June 25, 2012 20:26
Postgres 8.3 -> 8.4
--- 8.3/main/postgresql.conf 2010-11-18 18:12:51.000000000 +0100
+++ 8.4/main/postgresql.conf 2012-06-25 18:02:13.000000000 +0200
@@ -21,11 +21,14 @@
# take effect.
#
# Any parameter can also be given as a command-line option to the server, e.g.,
-# "postgres -c log_connections=on". Some paramters can be changed at run time
+# "postgres -c log_connections=on". Some parameters can be changed at run time
# with the "SET" SQL command.
#
Index: releases/general/1.15/bin/sql_db.py
===================================================================
--- releases/general/1.15/bin/sql_db.py (revision 3979)
+++ releases/general/1.15/bin/sql_db.py (revision 3980)
@@ -56,6 +56,8 @@
self.obj = db.cursor()
self.con = con
self.dbname = dbname
+ if tools.config.get('readonly', False):
+ self.obj.execute("SET TRANSACTION READ ONLY")
@ecarreras
ecarreras / tamany_taules.sql
Created August 1, 2012 12:45
Tamany de taules de la base de dades
SELECT
schemaname, tablename, pg_size_pretty(size) AS size_pretty,
pg_size_pretty(total_size) AS total_size_pretty
FROM
(SELECT *, pg_relation_size(schemaname||'.'||tablename) AS size,
pg_total_relation_size(schemaname||'.'||tablename) AS total_size
FROM pg_tables where schemaname = 'public') AS TABLES
ORDER BY total_size DESC;
@ecarreras
ecarreras / mk_github_issue.sh
Last active October 8, 2015 19:28
Make a github issue from a created branch
#!/bin/bash
d_repo=( $(git remote -v | grep '\(push\)' | cut -d':' -f 2 | \
cut -d' ' -f 1 | cut -d '.' -f 1) )
d_base="developer"
d_from=gisce:$(git branch --no-color 2> /dev/null | grep '^\*' | \
cut -d ' ' -f 2)
read -p "User:" user
read -sp "Password:" password
echo
@ecarreras
ecarreras / .gitignore
Created August 20, 2012 13:16
Checking local and remote md5
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
@ecarreras
ecarreras / running_instances.diff
Created September 7, 2012 05:54
Spawn oop running instances
diff --git a/spawn_oop/__init__.py b/spawn_oop/__init__.py
index cbae3cc..23da04f 100644
--- a/spawn_oop/__init__.py
+++ b/spawn_oop/__init__.py
@@ -7,6 +7,7 @@ import sys
import time
import tempfile
from datetime import datetime
+from hashlib import sha1
@ecarreras
ecarreras / del_dups.py
Created September 12, 2012 07:35
Eliminem duplicats quan s'ha apretat més d'una vegada el botó
fids = O.AccountInvoice.search([('date_invoice', '=', '2012-08-31']))
delete = []
done = []
for factura in O.AccountInvoice.read(fids, ['name']):
if factura['name'] in done:
delete.append(factura['id'])
else:
done.append(factura['name'])
O.AccountInvoice.unlink(delete)
@ecarreras
ecarreras / pr.md
Created September 17, 2012 09:50 — forked from kennethreitz/pr.md
Checkout github pull requests locally

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

Now add this lines:

[remote "github"]
	url = git@github.com:joyent/node.git
	fetch = +refs/pull/*/head:refs/remotes/github/pr/*
@ecarreras
ecarreras / crontab
Created September 22, 2012 20:11
Some backup scripts
0 0 * * * /usr/bin/duplicity --no-encryption /home scp://$(hostname -s)@vampir//mnt/backup/servers/$(hostname -s)