Skip to content

Instantly share code, notes, and snippets.

View pabloh007's full-sized avatar

Pablo Hernandez pabloh007

  • Compton, CA
View GitHub Profile
@pabloh007
pabloh007 / Dockerfile
Created December 18, 2015 23:31 — forked from jmorton/Dockerfile
Install Python 3.4.2 + mod_wsgi on CentOS
FROM centos:centos6
MAINTAINER jmorton@usgs.gov
# Apache
RUN yum install -y httpd httpd-devel
RUN chkconfig httpd on
RUN apachectl start
# Dependencies
RUN yum groupinstall -y "Development tools"
@pabloh007
pabloh007 / install_pythons.sh
Last active February 25, 2016 18:26 — forked from voodoonofx/install_pythons.sh
Install Python 2.x and 3.x with enable-shared
#!/bin/bash
### Python
# Setup python from source, for multiple versions of it. This only works with whole version numbers, not alpha releases.
# CentOS requires these packages:
# sudo yum -y install gcc automake autoconf
# yum groupinstall -y "Development tools"
# yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline
# yum install -y tar
# sudo yum -y install readline-devel ncurses-devel openssl-devel sqlite-devel tk-devel gdbm-devel bzip2-devel
@pabloh007
pabloh007 / render_query.py
Last active January 30, 2016 01:31 — forked from gsakkis/render_query.py
Generate an SQL expression string with bound parameters rendered inline for the given SQLAlchemy statement.
from datetime import datetime, date
from sqlalchemy.orm.query import Query
def render_query(statement, bind=None):
"""
Generate an SQL expression string with bound parameters rendered inline
for the given SQLAlchemy statement.
WARNING: This method of escaping is insecure, incomplete, and for debugging
purposes only. Executing SQL statements with inline-rendered user values is
@pabloh007
pabloh007 / AsyncNotify.py
Created June 27, 2016 16:34 — forked from pfote/AsyncNotify.py
postgres LISTEN/NOTIFY psycopg2/twisted
import psycopg2
import psycopg2.extensions
from select import select
from twisted.internet import threads
class AsyncNotify():
"""
based on http://divillo.com/, adapted to newer psycopg version
Class to trigger a function via PostgreSQL NOTIFY messages.
@pabloh007
pabloh007 / udevprotocol.py
Created July 14, 2016 22:27 — forked from dpnova/udevprotocol.py
udev and twisted together. repasting from: http://pastebin.com/TnrsS15s by @ralphm
import pyudev
from twisted.internet import abstract
class UDevMonitor(abstract.FileDescriptor):
"""
Protocol wrapper for pyudev.Monitor.
@see: U{http://packages.python.org/pyudev/api/monitor.html}.
"""
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Buit-ins
import time
# PIP Installs
from celery.task import current, task
def super_long_process(c, max_count):
@pabloh007
pabloh007 / django-servers.sh
Created December 5, 2016 03:24 — forked from fwenzel/django-servers.sh
A Debian init script to run one or more FCGI-based Django applications.
#! /bin/sh
### BEGIN INIT INFO
# Provides: FastCGI servers for Django
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description: Django, in order to operate with FastCGI, must be started
# in a very specific way with manage.py. This must be done
revert-file:
local.state.apply:
- tgt: {{ data['id'] }}
- kwarg:
saltenv: dev
- arg:
- maintain_important_file
reactor:
- salt/beacon/*/inotify//tmp/important_file:
- /srv/reactor/revert.sls
important_file:
file.managed:
- name: /tmp/important_file
- contents: |
important_config: True