Resurrecting the blink tag

August 7th, 2013

After today's news that the <blink> tag will be deprecated in Firefox, I decided to re-implement it in html5 / CSS3 (no Javascript required). Now it's all modern again, you are free to use <blink> liberally in your web application.

<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
blink
{
animation:blink 1s;
animation-iteration-count: infinite;
-webkit-animation:blink 1s;
-webkit-animation-iteration-count: infinite;
}
@keyframes blink
{
0%{opacity:0.0;}
50%{opacity:0.0;}
50.01%{opacity:1.0;}
100%{opacity:1.0;}
}
@-webkit-keyframes blink
{
0%{opacity:0.0;}
50%{opacity:0.0;}
50.01%{opacity:1.0;}
100%{opacity:1.0;}
}
</style>
</head>
<body>

The <blink>Blink Tag</blink>, re-implemented!

</body>
</html>

Be sure to give attribution for the above code, so your users will know where to go to thank me…

Edit: Just to demonstrate that it works!

Inspect the code if you don't believe me...

 

Where are those Print statements?

December 9th, 2012

When I'm debugging Python I tend to sprinkle my code liberally with print statements. Trouble is, I forget which files I added those print statements to and have to waste a few minutes tracking them down. Time which could be better spent doing pretty much anything else.

Not sure why I didn't think of this before, but I hacked together something that automatically prints the file and line of the print statement next to the output.

Here's the code:

import inspect
import sys
import os


class DebugPrint(object):
    def __init__(self, f):
        self.f = f

    def write(self, text):
        frame = inspect.currentframe()
        filename = frame.f_back.f_code.co_filename.rsplit(os.sep, 1)[-1]
        lineno = frame.f_back.f_lineno
        prefix = "[%s:%s] " % (filename, lineno)
        if text == os.linesep:
            self.f.write(text)
        else:
            self.f.write(prefix + text)

if not isinstance(sys.stdout, DebugPrint):
    sys.stdout = DebugPrint(sys.stdout)

To use it, save it as ‘debugprint.py’ then imported it somewhere. That's all you need to do. Works on Python 2.7 and probably other 2.X Pythons.

Here's what happens if you do it from the console:

>>> import debugprint
>>> print "Hello"
[<stdin>:1] Hello

For print statements in your app, you will get something like:

[foo.py:22] Hello
 

Spatial Bookmarking Service goes Open Source

January 9th, 2011

Locidesktop was my coffee shop coding project of last year. I was quite pleased with the results. Locidesktop.com has been happily serving link desktops to some loyal visitors for months now – with no maintenance required on my part (a good thing because I've been busy with other projects).

Rather than let the project stagnate while I do other things, I have released it as open source with the hope that other Python/Django developers will pick it up and add new features. I had never really anticipated that anyone other than myself would see the code, so it is lacking in comments and documentations, but there are some nice features that may be of interest. For instance, there's a system to expose a REST API that factors out a lot of Python bioler-plate code and corresponding javascript code exposes the desktop functionality to the browser.

There's also a pretty powerful caching system that makes rendering a desktop blindingly fast. I may have gone overboard with that, given my traffic rates. But I guess it is best to have more capacity than you need.

If you want to look through the code or fork the project, it is available on Github:

Locidesktop code

The only thing missing from the open source version is a single-site theme I purchased from themeforest.net, used in a few pages such as the about & privacy urls. The desktops themselves are identical to the live site because I did those myself. You can tell because of the minimalist design reflecting my artistic abilities (minimal).

There's a README in the project that will help you get started, but other than that you may have to figure things out for yourself. It's a pretty standard Django project, although I do use Jinja templates rather than Django templates. If you have any questions, please ask them in the comments, so at least there is a central repository for issues.

For more information on Locidesktop, see my previous posts on the subject.

Update: I had to recreate the repos to remove a bunch of temp files and mercurial data. If you forked before 9am GMT, 10th Jan, you may want to get this new repos.

 

“ I love those blissful minutes between fixing #bugs, when you think your #code actually works! ”

0
 
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan