Skip to content

Instantly share code, notes, and snippets.

View ivanelson's full-sized avatar

Ivanelson Nunes ivanelson

  • Teresina, PI - BR
View GitHub Profile
@ivanelson
ivanelson / gist:46c259d5586913a28f51
Created October 9, 2014 20:52
Apache settings of the Django App / Slackware 14
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mfd.claudinosa.com.br
DocumentRoot /var/www/django/portal_mfd/
WSGIScriptAlias / /var/www/django/portal_mfd/portal_mfd/mfd.wsgi
Alias /static/admin/ /var/www/django/portal_mfd/portal_mfd/static/admin/
Alias /static/ /var/www/django/portal_mfd/portal_mfd/static/
<Directory /var/www/django/portal_mfd/portal_mfd>
@ivanelson
ivanelson / postgresql.conf
Created August 29, 2014 17:53
postgresql.conf
# Version 9.1
log_destination = 'stderr' # Valid values are combinations of
logging_collector = all # Enable capturing of stderr and csvlog
log_directory = 'pg_log' # directory where log files are written,
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
log_file_mode = 0600 # creation mode for log files,
@ivanelson
ivanelson / ssh_paramiko.py
Created June 17, 2014 02:58
Python SSH via Paramiko
#-*- encoding: utf-8 -*-
""" test_paramiko.py - tests paramiko library on
localhost connection"""
import paramiko
paramiko.util.log_to_file('paramiko.log')
s = paramiko.SSHClient()
@ivanelson
ivanelson / pickle_ctypes.error
Created April 10, 2014 18:16
Pickled error with ctypes
Traceback (most recent call last):
File "teste.py", line 9, in <module>
ecf=base.Base()
File "/u1/caixa.manaus/pyECF/base.py", line 86, in __init__
self._lib()
File "/u1/caixa.manaus/pyECF/base.py", line 100, in _lib
pickle.dump(self.iDrv, f)
File "/usr/lib/python2.6/pickle.py", line 1362, in dump
Pickler(file, protocol).dump(obj)
File "/usr/lib/python2.6/pickle.py", line 224, in dump
@ivanelson
ivanelson / check_hlink.sh
Created January 20, 2014 19:41
I will check the integrity of hardlink's
@ivanelson
ivanelson / ValidComment.py
Last active January 1, 2016 01:39
Just close the ticket(Trac), if you insert a comment. http://trac.edgewall.org/
#-*- encoding: utf-8 -*-
from trac.core import Component, implements
from trac.ticket.api import ITicketManipulator, ITicketChangeListener
from trac.ticket.model import Ticket
class ValidComment(Component):
implements(ITicketManipulator, ITicketChangeListener)
def prepare_ticket(self, req, ticket, fields, actions):
@ivanelson
ivanelson / cons.py
Created November 21, 2013 23:06
Connect Oracle with Python + Apache CGI + cx_Oracle
#-*- encoding: utf-8 -*-
import os
os.putenv('ORACLE_HOME', '/usr/lib/oracle/11.2/client64')
os.putenv('LD_LIBRARY_PATH', '/usr/lib/oracle/11.2/client64/lib')
os.environ['ORACLE_HOME'] = "/usr/lib/oracle/11.2/client64"
os.environ['LD_LIBRARY_PATH'] = "/usr/lib/oracle/11.2/client64/lib"
import cx_Oracle
con = cx_Oracle.connect('user/pass@IPADDRESS/orcl')
@ivanelson
ivanelson / ticket_update_by_subject_new
Created August 14, 2013 22:38
email2trac - Integration Trac and GLPI
def ticket_update_by_subject(self, subject):
"""
This list of Re: prefixes is probably incomplete. Taken from
wikipedia. Here is how the subject is matched
- Re: <subject>
- Re: (<Mail list label>:)+ <subject>
So we must have the last column
"""
self.logger.debug('function ticket_update_by_subject')
@ivanelson
ivanelson / ticket_update_by_subject
Created July 17, 2013 23:50
Integration Email2Trac + Trac + GLPI
#-*- encoding: utf-8 -*-
def ticket_update_by_subject(self, subject):
"""
This list of Re: prefixes is probably incomplete. Taken from
wikipedia. Here is how the subject is matched
- Re: <subject>
- Re: (<Mail list label>:)+ <subject>
So we must have the last column
@ivanelson
ivanelson / regex_reply_mail
Created July 17, 2013 21:09
Regex for mail reply
found_id = None
if self.parameters.ticket_update and self.parameters.ticket_update_by_subject:
SUBJECT_RE = re.compile(r'^(?:(?:RE|AW|VS|SV|FW|FWD):\s*)+(.*)', re.IGNORECASE)
result = SUBJECT_RE.search(subject)
LOG = open("/tmp/regex.log", "a")
LOG.write("<<INICIO>>\n")
LOG.write("INICIO UPDATE_BY_SUBJECT: %s -> %s\n" % (subject.encode('utf8'), result))
LOG.close()