Kite – Programming copilot

Pretty interesting

Pretty interesting for me considering that I have a really bad memory for functions, I use to program with the reference/module open and autocompletion does help, but having this is good.

What worries to me is the fact that Kite uses internet to be more accurate on what you type, so, it has to query about the modules you are writing, and since it have access to your editor there is a chance it is sending what you type over internet ?.

But let’s face it, it will be the future… the young users will use it because it’s easy face it, new programmers are not used to code without a framework, why?, because it is easier!. read more

(Reblog) HotKeys on Windows using Python

This post comes  from the old blog.

A few weeks ago, I have to write a program in PyGTK that was supposed to be all the time in the background. This application needs to run over Microsoft Windows, and hide in the notification area, wich in Windows is near to the clock.

One of challenges for me in this application is that as it must run in the background there must be a way to raise it, the most easy way to do it is by force the user to click on the small icon in the notification area, but in this case, that was impossible because the computer don’t have any mouse, everything is done with the keyboard. read more

Python: Simple HTTP Server on python.

(Repost from old blog)

Python have several modules that help you to achieve your goals. This week, on my spare time that is getting every day more scarce I spend time figuring out how to create a Python Web Server, I was planing to use it over an application that I’m developing on ICT Consulting. At the end I didn’t use it because I didn’t want a “passive” communication, but probably I will use this code on the CRM Desktop application that we use here.

Anyway, this code may be helpful for you too. I found that creating a small web server is really simple, It starts getting bigger as you add functions to that web server, but the basis is quite simple.

import os import cgi import sys from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class customHTTPServer(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write('<HTML><body>Get!</body></HTML>') return def do_POST(self): global rootnode ctype,pdict = cgi.parse_header(self.headers.getheader('Content-type')) if ctype == 'multipart/form-data': query = cgi.parse_multipart(self.rfile, pdict) self.send_response(301) self.end_headers() self.wfile.write('Post!') def main(): try: server = HTTPServer(('',8080),customHTTPServer) print 'server started at port 8080' server.serve_forever() except KeyboardInterrupt: server.socket.close() if __name__=='__main__': main() read more

Image as background in a Gtk Application.

(Reposted from the old blog)

This time I’m going to talk about putting an image as the application background in Gtk. In Gtk we are used to leave the colors of the application to the theme, but sometimes we will need to use an image as background. I already wrote how to draw a pixbuf in a gtk.DrawingArea (Esp), we could use that, but we will “draw” directly on the widget window instead.

Yes, I said the widget’s window instead the widget itself. You should know that every widget that has been packed in a container has a gtk.gdk.window object and is the responsible for containing your widget. Well, we can draw on that object.

What we need is to create a simple gtk.gdk.Pixbuf and call the gtk.gdk.window.draw_pixbuf method using your widget.window object on the expose-event.

The code should look like this:

#!/usr/bin/env python import gtk def draw_pixbuf(widget, event): path = '/home/markuz/wallpapers/WMwall1024x768.gif' pixbuf = gtk.gdk.pixbuf_new_from_file(path) widget.window.draw_pixbuf(widget.style.bg_gc[gtk.STATE_NORMAL], pixbuf, 0, 0, 0,0) window = gtk.Window() window.set_title('Drawing Test') window.set_size_request(640,480) window.connect('destroy',gtk.main_quit) hbbox = gtk.HButtonBox() window.add(hbbox) hbbox.connect('expose-event', draw_pixbuf) button = gtk.Button('Press Me!') hbbox.pack_start(button, True, False, 10) window.show_all() gtk.main() read more

Python trick: How to make lazy objects?

Reposting from the old blog.

Hay una versión de este post en español, si lo prefieres puedes léerla aquí: Truco de Python, como crear objetos “flojos” (Lazy objects)

This time I’m about to talk about lazy object, I called like that because they are more or less similar to what we use in lazy treeviews (In Gtk) where the Tree shows expanders but didn’t load the child nodes until you expand the node). What I want to do is create objects and count them, but don’t load any data until I need it. read more

Find (and remove files) with find

find is a great tool to find things, but not only to find them, but to work on them. I have a small collection of music, which I presume at some point will be removed from my computer hard drive (maybe if I can get a new one it won’t be there at all) because I mostly listen to music from internet and I have a copy of the music in a external hard drive. read more

Accelerate your macports upgrade/install by using ramdisk

The main problem when compiling is the tons of disk access that compile involves from compiling, linking, stripping etc… if you have a regular hard disk you know this may take a lot of time, most if the project is large. If you have an SSD the problem is not the speed, but still the lots of read/write access even when SSDs are pretty much more reliable that they were years ago. read more

Vim Pro tip – Edit the current buffer in a new tab

Quite often I found in vim that I would like the current buffer in a new tab, I use a lot the vertical and horizontal splits in vim, then I reach the limit (my screen limit) for the vertical/horizontal splits, this means: if I add a new vertical split the code looks ugly even if it respects the 80 columns width, or if add a new horizontal split there would be just too few lines that is not worth to keep the buffer.

Then I used open a new tab, type

:e

then type the path to the buffer I like to edit. Until now, now I open a new tab, then type

:ls

check then number of the buffer I want in this new tab and then type

:bX

being “X” the number of the buffer, ej “:b2“. Another trick is to type

:bn

for the next buffer or

:bp

for the previous.

Kivy

The last couple of days I’ve been working with Kivy. For those that don’t know is a framework to create applications in graphical environments and in multiple platforms, all of these in the most easy to use programming language: Python, (And I mean programming language, JavaScript doesn’t count).

Well, its interesting to work with it, basically because I have the influence of GTK+ and having no windows but calling to widgets creates some confusion. Also, there is this Kivy language which is something like what Glade is In GTK but a lot easier to read (actually everything is easier to to read than XML).

I’m just starting to do this, this post is not a “how to do things in Kivy”, but I hope I can write some of those in the next weeks.