Archive for the 'website' Category


i’m learning web development

In the past few weeks, I had many job offers. All of them were related to web design/web application development. Because my web skills are pretty much non-existent, I had to turn them down.

So, in an effort to become a better developer, I’m learning webpy as a web framework, and mootools as a javascript framework.

Because I don’t want to be reading books and tutorials related to building “web skills”, I decided to learn them by writing an application. I decided to write a microblogging application. Things are going somewhat well … I have a textarea that “resembles” the ones used in this kind of applications ( somewhat functional ). I still have a long way to go, and I’m pretty excited.


a pretty simple way to highlight any type of code on your blog

As a non-web programmer, almost everything that has to do with CSS is beyond me. For some reason, I find CSS to be one of the most difficult things I ever saw.

I’m not confortable working with styles on this blog either. It used to take me about 30 minutes just to put some color in my code and to format it so that it would look right. I think there’s a way to do this from the plugins somehow, but I’m afraid that if I start to change the code, I’d do more harm than good.

So, I started to search for an alternative solution…

… and this is how I stumbled upon pygments. For me, this is the greatest python library I’ve ever used. The capacity to color almost any type of syntax is amazing, and the lexers it provides are great. I’ve even wrote a java source indenter based on the java lexer pygments provides ( I’ll talk about this in another post ).

You know the old saying, Two hours of debugging can save 10 minutes of reading? Unfortunately for me, I kind of keep living by this quote. Coding and reading documentation provided me with a very nasty habit: skimming. So, after skimming through the documentation, I found a sample code that made use of pygments.

I ran a script’s source through that code, and it outputted html. The only downside ( at least for me ) was that in order for it to work, I would have had to use a CSS file. Being the CSS guru that I am, that solution was unacceptable to me. I needed to use internal styles. One of the steps I took to fix that, was to write a script that would color python files, that made use of the python lexer. I had no problem with the script, but I would have had to write scripts for each type of programming language I wanted to use. Not a difficult task, but a time consuming one.

So, after reading the documentation again ( while not skimming ), I found that by setting the noclasses attribute to True, I would get the output I want. Here’s the code I’m using:

import pygments
import pygments.lexers
from pygments.formatters import HtmlFormatter
import sys

	file = sys.argv[1]
	sys.exit("you must supply a source file")

content = open(file).read()
first_line = content.splitlines()[0]
lexer = pygments.lexers.guess_lexer_for_filename(file,first_line)
if not lexer is None:
	formatter = HtmlFormatter()
	formatter.noclasses = True
	print pygments.highlight(content,lexer,formatter)
	print content
	sys.exit("could not provide highlighting for this type of source file")

You can use this code for almost any type of source file you may have ( as long as pygments has a lexer for it ). The way it works is that pygments will try to guess what lexer to use with your source file. It will try to do that based on the filename you provide it, but, it is my believe that by supplying another argument ( as the first line of your code ) you can help pygments a lot more in deciding what lexer to use.

pygments is a great library, one that I like very much. I warmly recommend it!


some anti-phishing tips

I’m receiving dozens of phishing mails each day, like :

  • the bank’s database has been compromised, please register again
  • I had tried to login too many times, my account has been disabled, please register again
  • the bank decided to provide users with an application through which they will login, please run this file
  • the bank’s database has been lost, please register again
  • … and countless more

I’m sure many of you receive the same type of mails each day. Here are some tips that will help you decide whether such an email is true or not :

  • each mail in this category will have at least one link in it. Place your mouse over it, and check to see if the address it points to is really the bank’s address. If for example, your bank is Bank ABCDEF ( a fictional bank ), and your bank’s website is, then, when you hover the mouse over the link, you should see a link that belongs to that domain. If for example, you see something completely different, such as, DO NOT VISIT THAT SITE, because it surely will be a phishing attempt
  • if your mail service provider accepts javascript in the e-mails ( which is, in my oppinion, a terrible security flaw ), disable javascript. Javascript has a function named onMouseOver which can be used to spoof a link’s address
  • NEVER download & run any files you did not request
  • if, for example, the e-mail seems legitimate and has a phone number, I would suggest you don’t call that number. Instead use google to find the bank’s website, and get the phone number from there. Then, call the bank to check and see about possible account problems.
  • your browser will sometimes identify sites that are not what they claim to be, be cautious when that happens.

I hope these tips will help you !


how to detect spiders/web crawlers

In the previous posts, I’ve written about the techniques one could use to perform web scraping. I feel it’s important that developers know how to detect spiders and how to restrict them.

I think that the StackOverflowquestion “How do you stop scripters from slamming your website hundreds of times a second?” compiles the best information related to this topic. You can read the whole thing here.


nice site

I recently found Java Specialists. It covers pretty interesting topics.

Blog Stats

  • 262,482 hits