Older blog entries for ralsina (starting at number 579)

Nikola-as-a-service demo

One of the things I hacked at during this PyCamp is trying to figure out a nice workflow for Nikola, something that will enable users that are not so technical, to use it.

One first step is Nikola-as-a-service, which is meant for technical users anyway but lays down the infrastructure for this to work semi-nicely.

In the video below, you will see me do this:

  • Go to GitHub
  • Take a starter's blog I provided, and do a clone
  • Go to the nikola-as-a-service site, and login (via twitter)
  • Create a site using my fork's repo URL
  • Get a "webhook" URL, and add it to my fork's admin as a post-commit hook
  • Edit a file in github's web UI and commit it (you can of course just push from any github client)
  • Automatically, the site nikola-as-a-service publishes gets updated.

Please don't try to use this service yet because:

  1. It's running in a $4.50/month server
  2. It's the same server my own blog uses
  3. I will turn it off, delete everything, etc. every once in a while
  4. I am editing the code on the server, so no guarantees it will not just stop working.

So, here's the video:


Syndicated 2012-07-09 11:18:00 from Lateral Opinion

PyCamp 2012 - Day 3

So, day 3 and next-to-last of PyCamp is done.

  • Great day, sunny, not all that cold
  • Empanadas at lunch, pizza for dinner, cake for tea. Feeling kinda spoiled today.
  • Lots of hacking at Nikola-as-a-service (details below)
  • PyAr meeting by a huge, somewhat scary bonfire earlier tonight

So: Nikola-as-a-service is an idea where you can keep your blog somewhere, and this service will get the data, and publish a nice site for you.

Here's the current workflow, which is just one of a dozen that can be implemented because this thing is quite simple:

  1. The authenticator

    Currently it has twitter authentication. You never need to create an account, just login with some service you already have accounts with. Anything with OAuth will work.

  2. The data provider

    Currently, github. Soon, Ubuntu One. Later, who knows. A data provider is something from where we can grab data, and that can notify us (automatically or by having the user click on a button) when we should get that data and rebuild the site.

  3. The renderer

    I am doing it with Nikola, of course :-)

  4. The infrastructure

    Jobs using Redis and Celery, server app using Flask, rendering using Nikola

  5. How does it work?

    You go to github, clone a barebones blog. Do your modifications. Go to nikola-as-a-service, and login via something. Then you give Nikola your github repo's URL, and you get a webhook URL. Go back to github, and configure the webhook.

    From that moment on, every time you push to github, your blog is updated :-)

    In the future: every time you save to Ubuntu One, your blog is updated. In the further future: Every time you X to Y, your blog is updated.

It's going to be cool :-)


Syndicated 2012-07-09 01:45:00 from Lateral Opinion

PyCamp 2012: Day 2

Finishing Day 2, here's the update.

https://p.twimg.com/AxO0roICMAAfLJd.jpg

That is one large spider, dude.

  • Woke up 10 time because David Litvak doesn't know how to turn off his alarm. Now hating "Good Day Sunshine" by The Beatles. Sorry Ringo!
  • Learned about Celery/Flask/Juggernaut. Tomorrow will try to hack on the Nikola server idea using that. Hugo Ruscitti already did a lot of work!
  • Helped Martín Gaitán do Nikola gallery improvements (looking much nicer now!)
  • Implemented code listings for Nikola
  • Had a huge spider walk up my leg.
  • Had asado for dinner!
  • Played with remote controlled cars.
  • Saw a guy juggle while riding a monocycle
  • Played in the ping pong tournament (record 1-1, out in the group phase)
  • Fixed a bunch of bugs that popped while implementing stuff.

Tomorrow: will hack all day in the nikola hosting idea.


Syndicated 2012-07-08 00:22:00 from Lateral Opinion

New Nikola Feature: code listings

This is a new feature in Nikola, my static website and blog generator.

It's aimed at showing pieces of files in the posts, and giving you a link to the full file, does reasonable syntax highlight thanks to pygments, and the syntax for embedding in your posts is not excessively awful, so I can use it for some of my tutorial / book projects.

Here's an example:

.. listing:: md.py python
   :start-at: def compile_html
   :end-before: output =

md.py

def compile_html(source, dest):
    try:
        os.makedirs(os.path.dirname(dest))
    except:
        pass
    with codecs.open(dest, "w+", "utf8") as out_file:
        with codecs.open(source, "r", "utf8") as in_file:
            data = in_file.read()

This is not merged into master yet, but should be soon.


Syndicated 2012-07-07 23:51:00 from Lateral Opinion

PyCamp Day 1

Going to sleep, so here's a quick rundown of my 1st day at Pycamp:

  • Woke up at 6AM, and after taking trains, buses and automobiles, arrived around noon. Place is nice, wheather is cold. Beds are bunks.
  • Presented ideas, voted working slots
  • Implemented a Nikola feature to get themes from http://bootswatch.com
  • Implemented first draft of pipelines for post-processing generated files
  • Martín Gaitán is working on improving the image galleries
  • Hugo Ruscitti is doing some celery+flask magic to create a Nikola hosting service
  • Had fun with lots of other things and talking with a lot of people.
  • Played some table tennis (won 1, lost 1)
  • Got a firefox t-shirt
  • Got a Ninja-IDE mug that changes colour with temperature.

Now, exhausted, going to bed.


Syndicated 2012-07-06 23:54:00 from Lateral Opinion

BA Chili Cookoff

Last saturday I attended the 2nd Buenos Aires Chili Cookoff. Lots of people, lots of great food. I was with my kid and he can't eat anything that spicy, but hey, there were cookies :-)

http://lateral.netmanagers.com.ar/galleries/random/chili.thumbnail.jpg

How crowded was it? About three times this crowd was there.

I had little experience with Chili, becuase it's not exactly a common dish around here, so, surprised by the variety, and most were quite nice, and despite exhaustive warnings by the cooks, none was unedibly spicy (the dreaded Zombie Chili which promised to melt my mouth? Kinda sweet and bland.)

Favourite? Lafitte's revenge, which really was a sort of bean-free bourguignon. Also, the smoked veggie chili was quite awesome. And the cookies were killers!

Next year, my wife is talking about cooking for it. I have had her chili, and I trust she can do better than 80% of the contestants this year. Plus I get to beta test her recipes, so win/win for me.


Syndicated 2012-07-05 16:41:00 from Lateral Opinion

Nikola Ideas for PyCamp

This friday is the beginning of PyCamp, four days of python hacking without distraction or pause. And I want to code a lot. My main target is features for Nikola my static blog generator.

If you are attending PyCamp (or even if you are not), you are welcome to join me in implementing these in a marathon of kickass coding starting this friday and lasting all weekend.

I have a few ideas in my head, but I want more. These are the ones I have, please add more in the comments if you have any:

Code Gallery
Like image galleries but for code. Put code in a folder and it will be beautifully displayed. With the addition of a "listings" docutils directive, it will make showing code in detail and in context easy and powerful, and make Nikola more attractive to programmer-bloggers.
Gallery Polishing
Image galleries are implemented and work, but they could use a lot of polish. From making them more network-efficient, to image RSS feeds, recursive galleries, gallery metadata, image texts, and much more.
File Pipelines

Want to minimize your CSS? Tidy your HTML? pngcrush your images? apply HTML transformations? Other things I can't imagine?

File pipelines would bring the power of the unix shell to a site generator, letting you connect lego-like filters, some provided, some from the community, into a powerful machinery.

Online Editing (Alva)
While static site generators have lots of benefits, they have one significant downside: you edit the files in your own device. A online editor for Nikola lets you edit them through a web interface for blogging-from-aywhere goodness.
Nikola Hosting (Shoreham)
Why not create a service where the user feeds posts to a server and then the server publishes them? The feeding can be via a DVCS, or a file sync service, or via online editors, and the output is published automatically or at the push of a button.
Drafts
I don't do drafts. I type and that's it. But others prefer more cautious and sane approaches. So, how should drafts work? While the feature may be easy to implement, it's a good beginner programmer's task, where you have to think more about what you want to achieve and providing a good user experience than about just banging code.

So, is there something you saw in another static blog generator and Nikola lacks? Any cool ideas and want a friendly codebase to hack them on? Do you have any crazy ideas noone would touch with a ten-foot-pole but you think would be awesome to have?

Well, now's a good time to talk about it!


Syndicated 2012-07-04 22:28:00 from Lateral Opinion

Python is Not a Configuration File Format

There is a large thread in reddit about using Python as configuration file format. I want to be clear about that:

DON'T DO THAT, UNLESS YOU HAVE A VERY GOOD REASON.

If you need to ask if it's a good idea, then you don't have a good reason. If you are sure that you have a good reason, then maybe you have a good reason.

There are many reasons for it, but I will explore just two, then offer a suggestion.

Python is read-only, and configuring is not programming.

Sure, it's easy to use python as a config file. You just import the thing, and there you go, all the data is there. But now your configuration syntax is a general purpose language that can do things like pop up dialogs when you parse it.

Your config can now depend on the whole internet, the hardware, the weather, and interactive input. Powerful? Sure. Good idea? Maybe, sometimes. But your application is now not able to configure itself.

If your application wants to store any kind of setting, it won't be able to. So most interactive, desktop apps, just should not use python for this, ever.

But what about non-interactive tools? Well, using python means that other tools can't write to the config file, either, which makes the tool less powerful. The power to have tools use tools is one of the cornerstones of modern computing, and you just cut your app off that ecosystem. Depending on what language the tool uses it may not even be able to parse your config file.

And what happens when someone is told "use this config fragment to achieve X"? Well, odds are, if the recipient has done anything that takes advantage of using python as a config format, then the fragment will not work. It would be like doing copy/paste from random code in github into your own program and expecting it to work.

So, you can't write to it from the app, you can't get configuration tips from the internet, you can't use other tools to modify config files, and other tools have a hard time parsing your files.

Also, it means that to handle the general case of configuring your app, you need a programmer. That is almost certainly overkill. Very few apps need that kind of thing. If your app can only be configured by programmers, you may have failed at making a good app (exceptions exist).

And what's the advice? Well, the advice is "don't do that" and the corollary is "configure using data, not code". use INIs, or XML, or YAML, or JSON, or plain text files, or whatever. But not code.

PS: My latest project, Nikola uses python as a configuration language. I thought I had a good reason. I didn't.


Syndicated 2012-07-03 21:46:00 from Lateral Opinion

The Future of PyQt by Example

Three years ago, I started a series of long posts called "PyQt by Example". It reached five posts before I abandoned for a series of reasons that don't matter anymore. That series is coming back starting next week, rewritten, improved and extended.

It will do so in a new site, and the "old" posts will be retired to an archive page. Why? Well, the technologies used in some of them are obsolete or don't quite work nowadays. So, the new versions will be the preferred ones.

And while I am not promising anything, I have enough written to make this something quite longer, more nicely layouted, more interesting and make it cover more ground. BUT, while doing some checks on the traffic statistics for the old posts, some things popped out.

This was very popular
About 60% of my site's traffic goes to those five posts. Out of about 1200 posts over 12 years, 60% of the viewers go to the 0.4% of the pages. That is a lot.
It's a long tail
The traffic has not decreased in three years. If anything, it has increased
https://p.twimg.com/Aw0MHhoCAAAXmro.png:large

A long and tall tail.

So, all this means there is a desire for PyQt documentation that is not satisfied. I am not surprised: PyQt is great, and the recommended book is not free, so there is bound to be a lot of demand.

And, here's the not-so-rosy bit: I had unobtrusive, relevant, out-of-the-way-but-visible ads in those pages for more than two years. Of the 70000 unique visitors, not even one clicked on an ad. Don't worry, I was not expecting to get money out of them (although I would love to some day collect a $100 check instead of having google hold my money for me ad eternum).

But really? Not even one ad click? In more than two years, thousands of people? I have to wonder if I just attract cheap people ;-)


Syndicated 2012-07-02 22:17:00 from Lateral Opinion

570 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!