Saturday 31 August 2013

Facebook, Youtube, LinkedIn and other CSS and JavaScript files from CDNs not loading on Ubuntu

I used to live in a dormitory in Warsaw. Many times there was a problem with a DNS server. It was broken regularly and it was blooming ridiculous as the building was a property of a technical university.

Anyway, there was a problem with DNS on my own router. It occurred that Ubuntu automatically assigned primary DNS setting to my router and it was broken. I found the solution here: http://bit.ly/17tDSQG Then according to my "standard" procedure changed the DNS settings for my local connection: http://bit.ly/1dvAuuP and "voila" it worked. Facebook, Youtube, LinkedIn and some other big players could load their CSS files and other resources!

My current settings:


Thursday 29 August 2013

The simplest RPC call ever in Python:

Server (file xmlrpc.py):
def fibonacci_naive(n):
    if n == 0:
        return 0
    if n == 1:
        return 1
    return fibonacci_naive(n-2) + fibonacci_naive(n-1)

import SimpleXMLRPCServer
server = SimpleXMLRPCServer.SimpleXMLRPCServer(('192.168.0.104', 8000))
server.register_function(fibonacci_naive)
server.serve_forever()

################################################################

$ python xmlrpc.py 

Client:
>>> import xmlrpclib
>>> server = xmlrpclib.ServerProxy('http://192.168.0.104:8000')
>>> print server.fibonacci_naive(10)
55

Tuesday 27 August 2013

Pythonic

Pythonic
return multiple values from functions using tuples

Un­Pythonic 
output parameters

What is Pythonic? The answer can be found here:
http://blog.startifact.com/posts/older/what-is-pythonic.html


Take a look at these slides (they're worth reading):
http://jacek.web.cern.ch/jacek/courses/python-intro/course.html#slide0