Skip to content

Instantly share code, notes, and snippets.

View luiscberrocal's full-sized avatar
👽
Happy since I left the circus...

Luis Carlos Berrocal luiscberrocal

👽
Happy since I left the circus...
View GitHub Profile
@luiscberrocal
luiscberrocal / gist:1273781
Created October 9, 2011 15:03
Eclipse Templates
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<templates>
<template autoinsert="true" context="java" deleted="false" description="Debug log" enabled="true" name="debug_log">Log.d(TAG + ".${enclosing_method}:" + Thread.currentThread().getStackTrace()[2].getLineNumber(), ${msg});</template>
<template autoinsert="true" context="java" deleted="false" description="Singleton pattern" enabled="true" name="singleton">private static ${enclosing_type} instance;
public static ${enclosing_type} getInstance(){
if(instance == null){
instance = new ${enclosing_type}();
}
return instance;
@luiscberrocal
luiscberrocal / build.xml
Created November 29, 2011 16:32
ANT Build File for numbering versions
<?xml version="1.0" encoding="UTF-8"?>
<project name="Numbers" default="dist" basedir=".">
<property name="version.file" location="${basedir}/build.properties"/>
<target name="inc.revision.properties" unless="no.increment.revision">
<propertyfile file="${version.file}">
<entry key="minor.number" default="0" operation="=" type="int"/>
<entry key="major.number" default="1" operation="=" type="int"/>
<entry key="build.number" default="0" operation="+" type="int"/>
</propertyfile>
</target>
@luiscberrocal
luiscberrocal / clean_white_spaces.py
Created January 9, 2012 15:43
Clean White Spaces for Blogger
## By: L. C. Berrocal
import sys;
fd = open(sys.argv[1])
contents = fd.readlines()
fd.close()
new_contents = []
of = open(sys.argv[2], "w")
print "Eliminanting white spaces from " + sys.argv[1] + " to " + sys.argv[2]
@luiscberrocal
luiscberrocal / insert_route_data.sql
Created January 11, 2012 14:03
Insert route data for web service tutorial
INSERT INTO `mroute` (`id`, `name`) VALUES
(1, 'Route 1-2'),
(2, 'Route 2-3'),
(3, 'Route 4-5');
INSERT INTO `point` (`id`, `route_id`, `name`, `x`, `y`, `pType`) VALUES
(1, 1, 'Punto 1', '-79.125', '9.08', 'STOP'),
(2, 1, 'Punto 2', '-79.185', '9.12', 'STOP'),
(3, 2, 'Punto 3', '-79.122', '9.081', 'STOP'),
@luiscberrocal
luiscberrocal / httpd.conf
Created July 2, 2012 14:20
WAMP Apache 2.2.11 configuration
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
@luiscberrocal
luiscberrocal / encryptor.py
Created July 17, 2012 19:07
Encrypto using pycrypt
import os, base64
from Crypto.Cipher import AES
import hashlib
class Encryptor(object):
# the block size for the cipher object; must be 16, 24, or 32 for AES
block_size = 32
padding = '{'
def __init__(self, secret):
self.secret = hashlib.sha256(secret).digest()
@luiscberrocal
luiscberrocal / pydev_templates.xml
Created August 1, 2012 15:03
Python editor templates
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<templates>
<template autoinsert="true" context="org.python.pydev.editor.templates.python" deleted="false" description="csv reader" enabled="true" name="vib_csv_reader">csv_filename= r''&#13;
csvreader = csv.reader(open(csv_filename, 'rb'), delimiter=',', quotechar='|')&#13;
rc = 1&#13;
for row in csvreader:&#13;
if rc != 1:&#13;
regexp = re.compile('[\s\(\)\[\]/{}.,]+')&#13;
clean_value = regexp.sub('', row[6]).strip()&#13;
rc += 1</template>
########## LOGGING CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
@luiscberrocal
luiscberrocal / django_project_setup.sh
Created August 9, 2015 19:49
Bash script to create a Django project and a virtual environment for Python3
#!/bin/bash -e
VIRTUAL_ENVIRONMENT_FOLDER=~/virtual_environments
PYCHARM_PROJECT_FOLDER=~/PycharmProjects/
cd $VIRTUAL_ENVIRONMENT_FOLDER;
/usr/local/Cellar/python3/3.4.1_1/bin/python3 /usr/local/lib/python3.4/site-packages/virtualenv.py --no-site-packages $1_env;
source $VIRTUAL_ENVIRONMENT_FOLDER/$1_env/bin/activate
@echo off
SET VIRTUAL_ENVIRONMENT_FOLDER=C:\python_environments
SET PYCHARM_PROJECT_FOLDER=%USERPROFILE%\PyCharmProjects
SET PYTHON_PROJECT=%~1
SET PROJECT_ENVIRONMENT=%VIRTUAL_ENVIRONMENT_FOLDER%\%PYTHON_PROJECT%_env
cd %VIRTUAL_ENVIRONMENT_FOLDER%
REM echo %PYCHARM_PROJECT_FOLDER%
echo %PROJECT_ENVIRONMENT%
C:\Python34\python.exe C:\Python34\Lib\site-packages\virtualenv.py --no-site-packages %PROJECT_ENVIRONMENT%