Skip to content

Instantly share code, notes, and snippets.

View vehrka's full-sized avatar

Pedro-Juan Ferrer vehrka

View GitHub Profile
@vehrka
vehrka / config.yml
Created November 10, 2017 08:28
JIRA REST API Worklogs
server: 'jira.yourserver.com'
author: 'workloguser'
apiuser: 'apiuser'
apipass: 'apipass'
@vehrka
vehrka / print_mapproxy.py
Created May 24, 2016 12:34
Print using Tilemill, Mapnik and Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# sudo add-apt-repository ppa:mapnik/nightly-2.3
# sudo apt-get update
# sudo apt-get install libmapnik libmapnik-dev mapnik-utils python-mapnik
# sudo apt-get install mapnik-input-plugin-gdal mapnik-input-plugin-ogr mapnik-input-plugin-postgis mapnik-input-plugin-sqlite mapnik-input-plugin-osm
import psycopg2
@vehrka
vehrka / jinja2_report.py
Last active February 10, 2016 12:39
Quick jinja2 report
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
from jinja2 import Environment, FileSystemLoader
from collections import namedtuple
env = Environment(loader=FileSystemLoader("."))
def render_template(template_file, **kwargs):
@vehrka
vehrka / flask_gunicorn_apache_proxy.rst
Created December 15, 2015 09:48
Flask on Gunicorn behind Apache Proxy

Apache conf

<Proxy *> 
  Order deny,allow 
  Allow from all 
</Proxy> 
ProxyPreserveHost On 
@vehrka
vehrka / gist:c33c65ab366e7aec14ad
Created April 14, 2015 07:23
How to create hexagonal grids in PostGIS
-- Function: makegrid_epsg3857(text, text, text, numeric)
-- DROP FUNCTION makegrid_epsg3857(text, text, text, numeric);
CREATE OR REPLACE FUNCTION makegrid_epsg3857(schemaname text, boundingbox text, gridtable text, halfwidth numeric)
RETURNS text AS
$BODY$
DECLARE
tbl_cnt int;
XMIN numeric;
@vehrka
vehrka / df2pg.py
Created March 3, 2015 08:10
Python 3: Pandas to Postgres / Postgres to Pandas
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import psycopg2
from basiclogger import pyLogger
#from datetime import datetime
from pandas import DataFrame
from sqlalchemy import create_engine
FILENAME = 'dataframetopostgres.log'
@vehrka
vehrka / ocr.sh
Created January 28, 2015 07:24
OCR de documentos con Imagemagick y Tesseract
#!/bin/sh
STARTPAGE=1 # set to pagenumber of the first page of PDF you wish to convert
ENDPAGE=11 # set to pagenumber of the last page of PDF you wish to convert
SOURCE=source.pdf # set to the file name of the PDF
OUTPUT=destination.txt # set to the final output file
RESOLUTION=75 # set to the resolution the scanner used (for B/W and good scans 75 suffice)
touch $OUTPUT
for i in `seq $STARTPAGE $ENDPAGE`; do
@vehrka
vehrka / remove_kernels.sh
Created December 15, 2014 08:32
Removing old kernels from Ubuntu
#!/bin/bash
if [ `id -u` -ne 0 ]; then
echo "Please run as root"
exit
else
kernelsv=`ls /boot | grep vmlinuz | cut -d'-' -f2,3`
nkernv=0
out=''
for kernv in ${kernelsv[@]}
@vehrka
vehrka / gist:11247688
Created April 24, 2014 09:14
keybase.md
### Keybase proof
I hereby claim:
* I am vehrka on github.
* I am vehrka (https://keybase.io/vehrka) on keybase.
* I have a public key whose fingerprint is 8A26 D429 AF4A 6DED 6EB8 0649 D3F8 129B 2FE3 8E6B
To claim this, I am signing this object:
@vehrka
vehrka / gist:10878885
Last active August 29, 2015 13:59
A function to automatize calls to the OCR
#!/usr/bin/python
from PIL import Image
import sys
import pyocr
import pyocr.builders
def ocrimage(imagename, threshold = 127, lang = 'spa', tlayout=3):