Keeping on my hard search for a professional an lightweight IDE for my Linux box i have finally decided for VIM(VI Improved). It have 34 years of continuous development and is powerfull and stable. I haved used Eclipse for years but i never have been so happy with it due to its great memory consuming and my computer is a Pentium M with only 512 MB of RAM. I have found VIM some time ago on the internet but i thinked it is very hard, thats an erroneus idea, some time ago i decided switch and everything goes nice. I think i have lot of triks to learn still but now i see it better than Eclipse(In my opinion) due to its powerfull customization features and shocuts that prevent from loosin time giving click to do most operations. For now im using VIM for web and Open ERP development. It use is better and better while more you learn.
Vim basically works on 2 modes that can be switched by ESC key(That is my config mapping). The Insert mode is for editing text and the command mode for making operation on text by shorcuts or commands. I think is better work on basic mode to learn it and add more features as you learn. My current configuration includes:
- File explorer
- HTML editing features with ZEN Coding plugin
- PHP debugging with Xdebug
- Code completion
- PHPDoc Support
- VCS Support(Mercurial and BZR)
Reggards to all visitors and any question please contact me on comments and i will respond soon. On future post i will write about features and tricks im going discovering on VIM.Vim is very documented online and on editor help itself. Here you can check a few links:
Check Online Docs
My VIM in Action
Now im working on a little applicatithat have to send emails with attachments in python, I make that code that can be reusable to someone:
# -*- coding: iso-8859-1 -*-
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP
msg = MIMEMultipart()
msg['Subject'] = 'Email From Python jajaja'
msg['From'] = 'firstname.lastname@example.org'
msg['Reply-to'] = 'otroemail@dominio'
msg['To'] = 'email@example.com'
# That is what u see if dont have an email reader:
msg.preamble = 'Multipart massage.\n'
# This is the textual part:
part = MIMEText("Hello im sending an email from a python program")
# This is the binary part(The Attachment):
part = MIMEApplication(open("file.pdf","rb").read())
part.add_header('Content-Disposition', 'attachment', filename="file.pdf")
# Create an instance in SMTP server
smtp = SMTP("smtp.domain.cu")
# Start the server:
# Send the email
smtp.sendmail(msg['From'], msg['To'], msg.as_string())
For security reasons, mainly in school are completely disabling USB storage devices on the computers at lab. It is important because students can bring a virus or also can leave with any private information. There is an easy way to do it in linux blacklisting the kernel driver:
- Open /etc/modprobe.d/blacklist.conf file.
- Type that line at end of file blacklist usb-storage.
Now nobody can use a USB memory stick in that computer. To enable it again comment or delete that line.
One of the things that i dont like of Gnome Desktop is the keyboard indicator applet that not show country flags like KDE desktop. Searching in San Google i found a solution to fix it, by default gnome support flags but most distributions dont have this feature enabled, to enable it follow this steps:
- Press ALT+F2 and it open the Execute App Dialog. Type gconf-editor and press Enter.
- Now, go to Desktop>Gnome>Peripherals>Keyboard>Indicator and check the box on the right side that says “showFlags”. (If you have an older gnome desktop and u dont find it, try: Apps->gswitchit->Applet->showFlags).
- Download the flags of languages that you use(You can download SVG files from Wikipedia searching the country name). Scale it to 64×43 size and move to /usr/share/pixmaps Directory with name XX.png, where XX is the iso country name not the language name, for example i use es.png with cuban flag and my language is Spanish(Spain).
- Now restart your session and you will see the flags in your panel:
I do this script to make recursive searches in a specified folder in Ubuntu
Server.I shere it and hope will be usefull to someone:
#! /usr/bin/env python
files = os.listdir(path)
trunk = 0
print “Access Denied: ” + path
trunk = 1
if trunk == 0:
for f in files:
if os.path.isdir(path + f):
search(path + f + ‘/’,file_name)
if file_name == f:
print ‘Found : ‘ + path + f
if __name__ == ‘__main__’:
path = raw_input(”Search Folder: “)
file = raw_input(”File to Search: “)
The use of php “short tags”( example: <? echo “Hola Mundo!” ?>) is a bad and common practice that many PHP developers still use. The shortags format is only aviable using the function short_tags() in PHP3 or activating the short_open_tag in php.ini configuration file(it comes activated by default). I dont recommend to use it when you develop applications to redistribute or use in external servers because it can cause conflicts for user if short tags are not enabled. In the official PHP manual and the Zend Framework manual recommends not use “short tags” and it going to be deleted in version 6 of PHP. Remember that clearness is very important to a professional coder: use ever <?php echo “Hola Mundo!” ?>.
Hello linux users: in this post i will show how to join two or more PDF files into one. You have to install the Ghostscript driver to do that, typing in a terminal(is for Debian and Ubuntu):
apt-get install gs
apt-get install pdftk
Now we join the PDFs with this command:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=unidos.pdf file1.pdf file2.pdf
Here is the explanation of command:
gs: Call to the Ghostscript program.
-dBATCH: Close the Ghostscript when terminate the process.
-dNOPAUSE: Dont pause the program to aks for user interaction.
-q: Dont show messages during the process.
-sDEVICE=pdfwrite: Use Ghostscript PDF generator to do the process.
-sOutputFile=unidos.pdf: The name of the result file.
You can also join all PDF files in a directory typing *.pdf.