09 Dec
Many people often want What You See Is What You Get (WYSIWYG) editors when creating content from within their web applications. This can be either in the Django admin control panel or for the end user. One of the most flexible and useful of the WYSIWYG editors currently available is TinyMCE due to its extensive plugin library and robust feature set. Integration with Django is relatively simple given that you extend the functionality of built in classes.
The first thing we will need to do is create a custom widget from forms.Textarea found in the django.forms module. We accomplish this by inheriting the Textarea class and overriding the constructor and render methods. Defining the relative path (on your web server) to the TInyMCE javascript source is also required here. So be aware that you will need to change that path to suite your environment. You may also want to change the content_css variable to include your sites’ main CSS file. The following is the source code for widgets.py which should be place in your projects root directory.
Read more »
26 Nov
Within the PC gaming community, it is quite useful to be able to control or monitor your servers programmatically. The almost universal standard being Rcon or “Remote Connection.” The protocol is overall very simple, it only requires a standard UDP socket and that you send a packet header with the login credentials per each request you make.
We will start by importing the python socket module and creating a UDP connection to the server.
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Connect to CoD4 server at 8.9.17.24:28960
# Will also work for most other games in a similar fasion
sock.connect(("8.9.17.24", 28960))
Read more »
10 Jun
Ever since the DBUS API change (more like overhaul) during the development of Banshee 1.0 and developers haven’t yet started supporting it in their plugins so I decided that I would play around with it. From what I have seen, it seems that the perception is that DBus is hard and complicated but its actually really easy and makes things very simple. Essentially you use a DBus debugger (because in most cases, documentation for an applications’ DBus API is not available) like D-Feet to look up which interfaces, methods, properties, and signals are available to you. Then use them to do what you want.
Read more »
09 May
Back when I wrote ProxyBot, I was frustrated by the fact that there was a lack of maintained and documented third party libraries for the IRC client protocol. So I essentially wrote my own implementation of the IRC client protocol for use with the bots that I write. Well I wrote the library to take advantage of OOP (Object Oriented Programming for those who don’t know) which in turn made it really quick and easy for me to throw together a bot.
So this is a simple little tutorial on how to write a basic “Hello World” bot using PyBotlib. The library itself is only a single file so I have not bothered to repackage it or write setup scripts as you will only need import that single file within your application. You may get the latest source code for the library at any time here (google code/SVN) or here (blog). So here we go…
Read more »
08 Feb
Recently, some of my friends had inspired me to start looking into how to make IRC bots. Well I did, and honestly I was fascinated by it. So anyway, I made my own implementation of the IRC specification as well as my first bot in python within a day or so. Since then I’ve made a bot which I called ProxyBot which allows a user to do things like portscans or an IP range/hostname and or a port range. If the bot finds a port open, it logs it to a PgSQL database which can then be searched later on for all IPs which have a given port open. It will also do standard hostname resolution. I will be releasing the source code under the GPLv3 and it will be avalible for download shortly.