I love iFixit ! Highly recommended !

Last week the HD in my mother-in-law’s hand-me-down iMac went the way of the dodos and crashed, loosing all the information on it.

Did you know you can burn a copy of Ubuntu (I used 12.10) to a CD and it will load and boot on a mac, even with EFI firmware ? This helped me verify that the disk was indeed dead and non-salvagable (it was the /Users directory that was totally destroyed !).

The 24 inch screen is still great, the CPU (an 2,16 Ghz Intel Core 2 Duo) is a bit slow nowadays but still more than good enough for surfing and showing photos and playing music, so I figured why not replace the hard disk and save some money ?

I visited iFixit.com and checked if they had a repair guide for that particular iMac model and sure enough it was there. I bought the necessary hard drive and Torx screwdrivers, and I have just now succesfully replaced the failed 500 GB disk with a 2TB disk.

When I subsequently booted from the Snow Leopard disk, it couldn’t see the drive, but a quick trip to the disk utility made it show itself, and I was able to format it and continue the installation – everything is just fine, thanks to those iFixit people !

Note that iFixit is a free service, but you can help them out by buying repair tools or hard disks from them, or writing your own guide.

I figured I could help point some people in the right direction – they have an amazing amount of DIY repair manuals !

PS – for those who break the temperature sensor on the HD or the wires (I didn’t) : there’s a software solution for that !

Devolo Powerline AV500+ network problems (2)

In a recent post I wrote about the persistent network problems that I had with my Devolo Powerline and that I solved it.

Wrong ! Turns out that the firmware update was not the answer – I now have anywhere between 1 and 4 days before I have to pull the devolo plug. I have contacted Devolo support, but they only sent me a faq about what to do when you have a slow network connection and how to solve it.

But this is not my problem – everything works fine, at reasonable to very good speeds, when *suddenly* the network connection drops. Bam, no more network connection. Usually when I’m copying something to the NAS. Like I’ve suddenly reached a limit on file size or file transfers and everything is cut off.

The only way to solve it is to remove the devolo powerplug (that is downstairs and connected to the router) from the mains, wait 10 seconds or so and reinsert it. That does the trick just about every time (sometimes it is the Telenet router that hangs, but that only happens once in a while).

Update : in the comments on this post people have found an alternate solution : using the devolo management software, you can restart the device remotely, and then it works again (the connection over the powerline keeps working so you can reach the device that way).

I’ll try and keep a count here on how many times I have to restart the devolo plug.

20121118 : reset devolo powerplug
20121125 : reset at least 4 times (doing heavy moving of content to NAS)
20121128 : reset 2 times (telework today, only citrix connection)

Update December 29 2012 : this problem has kept on appearing intermittently – either after a week or several times a day. It seems to indicate that there is a problem with the amount of data throughput.

Update April 09 2013 : I’ve received a new firmware from Devolo to test out, and applied it to all the Devolo AV500 devices I have. The problem is *less* when the network is stable (ie low usage, mail check and such) but worse when actually *using* the network. I now need to reset the AV device about 5 times on a work-from-home day instead of 1 or 2 times.

Update April 14 2013 : received another mail from Devolo to test out the devolo boxes. The test consisted of plugging in 2 devolo boxes on an extension cord so that they are connected via the same socket. A good linkage apparantly is that both the “power” and “home” icon on both devices give a “green” light. I’ve taken a picture of this and added this to the mail I sent back to them. I honestly don’t think I’ve gotten to the second level support as yet, all the things I’ve done until now have been the basic “check this, do that, there is a bad connection, you must be doing something wrong” type of answers that a typical first level support tends to give. I am persisting in keeping in contact with them, and hopefully I will get some more technical requests…

Update April 28 2013 :¬† I’ve received a few more questions about how my devolo boxes are setup, what type of modem that I use (a eurodocsis 3.0) and so on. I’ve sent those on, and they have now asked me to switch the devolo’s about to see if the problem is located in one physical devolo item or if this problem is caused by a network situation. I have yet to do so, but will do that in the following days. The questions have become more technical, the solution (switch em around) not yet, but it’s a logical thing to test.

Update May 19 2013 : on request of devolo support, I’ve switched my dlan AV500 plus around with my dlan AV500 Triple plus. So the dlan device with the 3 ports is now connected to the router and the single-port dlan which was connected to the router¬† device is now on the other end. For two weeks I have not had a single crash !¬† For me that confirms that the problem lies with the single-port AV500 plus. Maybe it has to process all the other traffic and can’t cope while the 3-port device can ? I don’t know.
I’ve informed Devolo of the results and am awaiting their reply. I hope they take this serious and do an in-depth investigation and fix this with a new firmware release. After all, I’m not the only one that is having these problems, seeing all the comments below this post. And putting a 3-port dlan switch on your router where only one port can be used is a bit useless to me.

Update June 9, 2013 : ¬† Devolo support thinks that it is just one faulty device and have asked me to reswitch back the devices to the original locations to confirm that this is the case. I’ve done that and do have the same problems again. This is on the latest published firmware. I’ve also pointed them to this blog and have asked them to read the comments in this post. It seems very unlikely that it is just one faulty device when all the people below leave comments with a “me-too” message – or perhaps there is a whole batch of them ? I still hope a firmware update will solve the problem.

The problem evidently still has not been solved. And there are now 5 6 11 19 people who have left a comment saying they have a similar problem…

Update August 4, 2013 :¬†Devolo support has concluded that the device has a hardware fault and that it needs to be replaced. They told me to bring it back to the shop and ask for a new one. They determined that it was faulty because when it crashes it does not show it on the device (!) as all the lights stay green. I’m disgusted by this lack of customer support and have written a (long) blog post about this. I’m also solving my problem at my expense by buying another device from D-LINK to replace my faulty devolo with. ¬†No more devolo or devolo support for me.

Update November 12, 2013 : in a comment below, Arturo has found that the devolo 500 units have a cooling problem – they shut down when too hot. Removing the cover as he did so they can get more air (or alternately, perhaps drilling holes in the cover) could also be a solution for you. But be careful – don’t get electrocuted !

Devolo Powerline AV500+ network problems

I recently moved my buro up one level to the first floor, next to our bedroom. As I don’t want our bedrooms to be bathed in wifi radiation all the time, I’ve bought and installed 3 develo powerlines AV500+.

Devolo DLAN 500 AVplus
Devolo DLAN 500 AVplus

You connect one of these devices to your router via a network cable, and plug it in a socket. Then you connect up the others. Your network data is passed along via the powerlines, without needing to put wifi everywhere (plus it’s a hell of lot faster – these ones can go to up to 500Mbit per seconds, fast enough to stream movies to your ps3 !).

I used to have 2 older Devolo devices, but those were manual setups – you needed to connect them to your computer, and run a config program to set the network ip address and other settings. It worked, but it was a nerd tool.

These AV500 ones are much more sophisticated and just work out of the box. Plug them in, hook up the network cables, and they just work. Excellent !

Additionally, if you want to, you just press a button on each and they set up an encryption between the devices. This is a way to prevent your neighbour – who may be on the same power network as you – from plugging in a similar device and getting access to your computers and NAS (Network Attached Storage).

You can also configure them via the DLAN cockpit program, which scans for them and shows them in a graphical way letting you change settings, etc.

The one I bought have integrated plugs that have an integrated filter that filters out the oscillations of the computers / networked devices that they work for.

The problem

The problem I had was that upstairs I was constantly loosing my network connection. It worked for a time, and then suddenly would shut down again. The other devolo in the living room worked just fine.

After some trial and error (involving a switch, a router and some reboots) I noticed that I had to unplug the devolo downstairs connected to the router, and then it would work again when I reconnected it.

Further investigation via the DLAN cockpit program showed that there was one thing different – the version number of the upstairs devolo was lower than the others.

So I upgraded this one to the same version as the other Devolo’s and hey presto the problem seems to be solved – my network connection has been consistently up for the last 48 hours !

So, the conclusion is that all Devolo’s need to be at the same firmware level. ¬†Thought I would share it with you for those who might have similar problems.

[Please note that this did *not* solve all my problems completely, please read the followup if you are still having problems]

 

Bootstrap from twitter is very cool

A few months ago I mentioned Foundation from ZURB which to me was a pretty neat way to write some functional html and css code for a quick setup of a website or setting up a basic layout.

These last few days I’ve been busy with learning Bootstrap, which is made by the guys from Twitter, and while Foundation was definitely cool, I must admit that Bootstrap just fits me better and offers me more possibilities. YMMV ofcourse.

It may be because I had Foundation as a basis, and thus was already accustomed to the way things worked, but I learned the methods used much quicker than with Foundation.

I’ve made a decent, good-looking one-page landingpage website with a image Carousel in less than a day, and as a test I’ve reworked an existing website to see what it could do.

In less than a day I had a fully navigational website : full navbar, with menu, fluid rows that resized in most browsers on the fly with buttons and a good layout.

I am really impressed with the speed I’ve managed to make these websites, and I can see myself using bootstrap to built other sites in the future.

 

Boxee, Plex, Majestic, XMBC on your mac mini for streaming to your TV or ps3 ?

I just spent the past few days installing and playing around with a few media center softwares that you can install on your mac mini.

The aim : streaming my media directly from the mac mini to either my Samsung SmartTV or to the PS3 connected through it. The mac mini is installed in another location, so streaming is either wireless to the PS3 or via a UTP-cable to the TV (although I can switch them easily enough, this is the current setup).

Anything else (streaming to iOS, for example) is a bonus. But my main itch to scratch was that I wanted to stop running around with portable disks and usb keys, and just centralize everything in one location, and my mac mini seemed the ideal place for that.

I’ve tried the following software so you don’t need to :

  • XMBC¬†: I was very impressed with it finding the media quickly and the indexing done on it, retrieving additional information from online internet databases as well as with the local “front end” experience. However, I was disappointed in it’s streaming capabilities : it did not appear on either my TV or my PS3. Although it advertises that you should just activate ‘media sharing’ and that’s all, it just didn’t work for me – some forum browsing shows that others have had similar experiences, depending on what type of router, etc, though for many it works just fine. I would have stopped here if the streaming worked as this seems to be an excellent open-source package. Certainly if your mac mini is sitting right next to your telly this seems to be a good solution.
  • Boxee¬†: while Boxee now sells it own hardware, the software available as-is has been discontinued. The software is still available on google code¬†though (last update was jan 2012 as of this writing). The boxee software is not installed through drag’ndrop, so not sure how this uninstalls. It worked, but after seeing XMBC I was slightly less impressed. Integration with the web works fine though. The interface consists of only icons instead of text, making it slightly harder for a first-timer to muddle through although this is only a slight problem.
  • Majestic Media Server : I found a reference to this on one or other forum, but couldn’t seem to find a download link on their website. Seems that is for sale (trial version), so not free to download. It’s only for streaming, nothing fancy. In the end I found a version on CNET. Very simple interface, just a small window. This didn’t work at all, complaining of a port that was occupied by another process.
  • Plex¬†: This was the final media center solution I tried, mainly because it is not open-sourced and is a spin-off from XMBC. It is however, free to download, and it works just beautifully. ¬†It does come in two parts : the media server which does just what it says, serving your media to whatever device, and the media center which is the front-end to play the stream. If you are only interested in streaming to your PS3 just get the media server, which provides everything you need to add your media to the plex database. It also provides a basic webpage that shows you an overview of all your media and allows you to change your metadata. On your PS3 the Plex server immediately shows up and you can browse your media and start playing it. The accompanying front-end can be installed on another mac for example. You can also buy an iOS app that allows you to stream from the Plex media server to your iPhone or iPad.

The result : in short, only Plex fulfilled my needs. All the others gave either errors or did not show up on either the Samsung TV or on the PS3. Only Plex showed up in both, immediately, and while the Samsung crashed when I selected “Movies” in the interface, on the PS3 it works perfectly and streaming even over wireless worked perfectly.

I’ll probably buy the iOS app as well, and start consolidating all my media on my mac mini.

The verdict : while not open-sourced, and while some component are to be purchased (e.g. the iOS app) Plex is well worth the install.

Woes in Python 2.x : UnicodeEncodeError : ‘ascii’ codec can’t encode

Phew ! This is a reminder to myself…

I’ve wrapped my head once already around unicode, but it was so long ago that I had to do it all over again when the error suddenly came up again.

The error I had was the dreaded “UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa1′ in position 0: ordinal not in range(128)” error which does not really explain what you are doing wrong but leaves you scratching your head wondering where in heaven’s name you should start looking.

I read the following articles :

But what really solved the problem for me was this StackOverflow answer by Alex Martelli (Bless You Joel Spolsky for this idea and Bless all the people answering there!)

I was in a similar position code-wise : I had a unicode object that I wanted to convert tot utf-8, but I was using the “decode” function.

I actually should have been using the “encode to <codec>” function !

Duh ! Once you have a unicode object, you need to encode it into utf-8 or whatever encoding you need. I was using decode !!!

Oh. Well, perhaps my unicode fu is still not as good as it should be…

Proof of concept for a simple webserver running python code

Here is a small code example using CherryPy to run a very simple webserver that

  • generates a simple math question
  • compares the answer to the solution.

It’s meant as a proof of concept, so there is no security built in. It’s running on localhost on port 8888 (modifiable in the main part of the code).
It allows you to play around and test out your ideas.

Do not use this code on an outside network !

It’s simply an example showing how easy it is to set up a web server and how you can create pages for it using python and CherryPy. It’s been cobbled together in an evening from previous programming so there’s some cruft left in. I’ve also extensively commented the code.

Requirements:

  • python 2.7 ( 2.5 will work as well is my guess )
  • cherrypy 3.2.2 ( use easy_install or pip to download and install the latest version)
  • site.py ( the file containing the python code )

You start the server in a command prompt using : python site.py which will start the server. Leave the command prompt open.

You can then visit the webserver by opening a browser and going to http://localhost:8888 to see the index page and play around with it.

#
# MathPoc : Proof of concept of a simple math problem, bringing it to the browser
#
# Alex Boschmans
#
# Version 0.2, February 2011
#
# 0.2 Added some error checks and expanded math to not just adding but also 
# subtraction and multiplication and divisions. Extensively commented code.

header = """<HTML>
            <HEAD>
                <title>MATH Proof of Concept</title>
            </HEAD>
            <BODY>
        """
footer = "</BODY></HTML>"

indexhtml = """
        <H1>Math Proof of Concept</H1>
        <p>Please answer the following question</p>
                <p>How much is %d %s %d ? </p>
                
                <form action="/response" method="post">
                Answer: <input type="text" name="answer" />
                <input type="hidden" name="number1" value="%d">
                <input type="hidden" name="number2" value="%d">
                <input type="hidden" name="operation" value="%s">
                <input type="submit" value="Submit" />
                </form>
                
        """

def generatequestion():
    # This generates the question that we will pose using the random function
    # Generate a random question using 2 random numbers between 1 and 10
    number1 = random.randint(1,10) 
    number2 = random.randint(1,10)
    # Now we choose an operatioin
    ops = ["+", "-", "x", "/"]
    operation = random.choice(ops)
    # Let's check the division
    if operation == "/":
        # Prevent divisions with remainders using the modulo operator
        # Using module on the two numbers evaluates to 0 when no remainder is present
        # While the modulo remainder is not equal to 0, generate two new numbers
        while number1 % number2 <> 0:
                number1 = random.randint(1,10) 
                number2 = random.randint(1,10)
    # Assemble the html, inputting the numbers in the foreseen places in the html
    # In a more extensive project, you would keep this html in a template file and 
    # call it with a dictionary of items that need to be filled in the template
    question = indexhtml % (number1, operation, number2, number1, number2, operation)
    # Add common html like header and footer - these are defined just once and reused
    # for each page
    html = header + question + footer
    # Return the completed html to the calling function (in this case index)
    return html

# This is the class that the cherrypy server uses and where you create the views that the 
# webuser sees. After each definition there is a <function>.exposed=True that indicates if the 
# webuser can see this page or not. 
class MathPoc:
    def index(self):
        # This is the main index page that is shown to the user when he first visits the site.
        # We create the page by calling the function generatequestion (which is outside the class
        # MathPoc but accessible and we show it to the user by 'return'ing the page 
        page = generatequestion()
        return page
        # The webuser will now see the page and will have a chance to enter an answer.
        # In the html form I've specified that the submitted result will go to the url "response"
        # I've added all the values I want to receive either as hidden values (eg the 
        # original numbers, the operation) or as part of the form (eg the answer)
    index.exposed = True
    
    def response(self, answer, number1, number2, operation):
        # First check if we received an answer or if the user submitted without an answer
        if answer:
            # Calculate our own answer ourselves and generate a response to the user
            # We receive strings, so convert them to integers using int()
            number1 = int(number1)
            number2 = int(number2)
            answer = int(answer)
            # Answer is dependent on operation
            if operation == "+":
                solution = number1 + number2
            elif operation == "-":
                solution = number1 - number2
            elif operation == "x":
                solution = number1 * number2
            else:
                solution = number1 / number2
            # See if the answer is correct and display according the result
            # Using templates, you could put all this in one template and 
            # call the template with options so it knows what to show
            if solution <> answer:
                html = """
                <H1>Sorry.</H1>
                <p>The question was : %s %s %s = ?</p>
                <p>Your answer %s is wrong. The correct answer is %d.</p>
                <p><a href = "/">Try Again.</a></p>
                """ % (number1, operation, number2, answer, solution)
            else:
                html = """
                <H1>Correct !</H1>
                <p>The question was : %s %s %s = %s</p>
                <p>Your answer is correct !</p>
                <p><a href = "/">Try Again.</a></p>
                """ % (number1, operation, number2, answer)
        else:
            # We did not receive an answer
            html = """
            <h1>Sorry ?</h1>
            <p>You need to fill in an answer !</p>
            <p><a href = "/">Try Again.</a></p>
            """
        # Return the page to the user, adding the common html
        return header + html + footer
    response.exposed = True

if __name__ == '__main__':
    import random
    import cherrypy
    import os, sys
    # Set the current directory - this is probably not needed for this example, cruft.
    try:
        current_dir = os.path.dirname(os.path.abspath(__file__))
    except:
        # probably running inside py2exe which doesn't set __file__
        current_dir = os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding( )))

    # Set up site-wide config first so we get a log if errors occur.
    # Adding the setting 'environment': 'production' to the below turns off auto-reload.
    # Otherwise CherryPy monitors the code and any change to code reloads the server - handy for development !
    cherrypy.config.update({'server.socket_port':8888,
                            'server.socket_host':'127.0.0.1',
                            'log.error_file': 'site.log',
                            'log.screen': True})
    # CherryPy will complain of an empty config but will continue
    conf = {}
    cherrypy.tree.mount(MathPoc())
    #cherrypy.config.update({'server.socket_port':8888})
    cherrypy.quickstart(MathPoc(),'/', config=conf)