You Are Here Home > November 2008

November 2008

Problems with Google AdSense

I use AdSense on 1 of my websites and a while back I discovered some things about this service from Google.

One thing that I think is awful and shows how big corporates ONLY care about money was that I knew a website that was banned (black listed) by Google because they were “violating Google’s terms of services” by helping people buy and sell text link ads ;) and now when I search for the name of the site, it doesn’t show up in normal search results. The messed up part is that this particular website bought AdWords ads and their name shows up in sponsored links section right on the top of the search results.

This means 2 things: 1 – Google doesn’t care much about what you do when you pay, 2 – You can BUY the first spot on Google SERPs!!!

What they could do is to check the URLs against their banned list but…

The other thing about AdSense is this: Have you ever clicked on an AdSense link with confidence? have you ever seen anything valuable in those links?
Many of them are links that take you to irrelevant pages and many of the people who buy these keywords have so much money that they want the traffic in anyway they can, by bidding on keywords that have nothing to do with their pages.

This could be very bad, you are sending your visitors away with AdSense in the first place, but sadly you are sending them to pages that are not good.

It’s unfortunate but it’s what it is for now.

Problems with Google AdSense
Comments (0)   Filed under: Annoying Stuff, General, Search Engines   Posted by: Codehead

How PHPCache saved us from buying another server

I developed a large website for a client and in the past month we were getting a lot of traffic.

It was in a way that the server had problems handling the traffic and my client wanted to get another server to load balance the traffic between the two.

Pages on this site are generated from 10 to 25 MySQL queries and these queries are optimized but consider this, if there are 1,000 request for a page with 25 queries in a very small period of time, that would be 25,000 queries. 25,000 queries + processing them could lead to huge server loads.

So we used PHPCache to cache the results of those queries for just 1 minute, not an hour or a day, just one minute and it made a huge difference.

The difference was that we cached all 25 queries plus the time it took to process them using PHPCache and now to handle 1,000 requests we were querying the database only 1,000 times.

I think this site can easily handle 10 times more traffic now.

How PHPCache saved us from buying another server
Comments (0)   Filed under: MySQL, PHP, Server Performance, Web Development   Posted by: Codehead

Python ImportError: cannot import name X

This was strange, I had a bunch of classes in a file and was trying to import one of them from a file in a child folder.

The package looked like this:

/main_classes.py <– “import child” was in here way on top
/child/__init__.py <– For every file in this folder, import it
/child/some_file.py <– Import a class in main_classes.py *Error*

The reason was that I was doing “import child” way on top before implementing the class I was importing in some_file.py.

I moved the “import child” line from the top of the main_class.py to the constructor of the class I was implementing and it fixed the issue.

I hope this made sense :) (and I know it will to the person with this problem ;) )

Python ImportError: cannot import name X
Comments (8)   Filed under: Python   Posted by: Codehead

My favorite TED talk

Watch all of it ;)

My favorite TED talk
Comments (0)   Filed under: Fun, General, Space, Technology   Posted by: Codehead

Schools *kill* creativity

Schools *kill* creativity
Comments (0)   Filed under: General   Posted by: Codehead

Decorating Python’s sys.stdout

Try this:

class stdoutflip:
 
    def __init__(self, sys):
        self.stdout = sys.stdout
        sys.stdout = self
 
    def write(self, txt):
        txt = list(txt)
        txt.reverse()
        self.stdout.write(''.join(txt))
 
 
class stdoutupper:
 
    def __init__(self, sys):
        self.stdout = sys.stdout
        sys.stdout = self
 
    def write(self, txt):
        self.stdout.write(txt.upper())

To test it do this:

out = stdoutupper(stdoutflip(sys))

Now try printing stuff:

print "Hello Python!"

:)

Decorating Python’s sys.stdout
Comments (0)   Filed under: Fun, Programming, Python   Posted by: Codehead

How to fix transparent PNGs in Internet Explorer

You might know already that there are some issues with transparent GIFs but PNGs don’t have those issues.
The problem with transparent PNGs is that Internet Explorer doesn’t like them so much and gives them a funny background.

So here is the solution that works great:
http://homepage.ntlworld.com/bobosola/index.htm

How to fix transparent PNGs in Internet Explorer
Comments (0)   Filed under: Annoying Stuff, JavaScript, Web Browsers, Web Design, Web Development   Posted by: Codehead

Computers of the future

They are going to be just a monitor, a touch screen monitor, there will be a keyboard on the screen if you want to type anything, there will be no keyboard, mouse or touch pad.
Probably in the next 5 years they will be everywhere, you might not be able to buy one of these either :)

Computers of the future
Comments (0)   Filed under: Fun, General, Operating Systems   Posted by: Codehead

My problem with Microsoft and their products

A while back, I wrote two posts about Microsoft and I wrote them when I was upset so it might have offended people.

To be honest with you, I was a fan of Microsoft and their products up until Internet Explorer 7 came along.
I installed it on two computers and I had to disable all the addons other than the essentials in order to make them run smoothly and without so much issues.

Right now, my Internet Explorer process grows until it’s 1GB in size!!! and it then gets so slow or crashes and I loose all my open tabs and what ever I was doing.
It also crashed every once in a while for some reason and it’s still not standard compliant.

About Windows Vista; we also bought four computers with Vista and every single one, without an exception had issues right out of the box, big issues that I think Microsoft should have known about but shipped the product anyway.

Honestly, this is disappointing for me, because I liked Windows and it’s openness and the ability for everyone to write great applications for it and it’s huge documentation on Microsoft website.

I also think that Microsoft contributed a lot to the industry and I hope that this is not the end of it.

I’m a software developer and I don’t consider myself to be the best one but I know one thing, we don’t EVER ship until we fix all the obvious bugs, if we did, we wouldn’t have any clients right now.

Good Luck :)

My problem with Microsoft and their products
Comments (0)   Filed under: Annoying Stuff, General, Programming, Web Browsers   Posted by: Codehead

Python as CGI and Error 500, Internal Server Error

If you have this problem on *nix systems, these are the things to look for:

1 – Make sure your line breaks are \n not \r\n you can set this in almost all editors, you will have to either select *nix like line breaks or \n somewhere in your editor preferences.

2 – After the first step you will have to make sure that your FTP client uploads the files in ASCII format and this will insure that \n will stay \n.

3 – If it still doesn’t work, make sure your Python script’s permissions are 755. You can try:
chmod 755 your_python_script.py

Or use your FTP client to fix this. (Refer to it’s documentation but usually you can right click on the file, on your server and click properties)

4 – If you still have the problem, you will have to have the right shebang line in the beginning of your script, the most common one is:
#!/usr/bin/env python
If this doesn’t work try:
#!/usr/bin/python
Or:
#!/usr/local/bin/python
Note that, this must be the first line

5 – If none of these worked and you have root access to your server, try:
tail -f /usr/local/apache/logs/error_log (Note that, the path to Apache error log might be different on your server)
And look for the error message associated with your request.

6 – If you still can’t figure it out, write to your hosting company and ask them.

I hope this helps :)

Python as CGI and Error 500, Internal Server Error
Comments (4)   Filed under: Annoying Stuff, Python   Posted by: Codehead
Older Posts »