Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

The shortest URL you will find anywhere

For exam­ple, this blo­g's URL would be http://➡.ws/콢

As you can see the­re is a tiny arrow (thus the na­me of the ser­vi­ce) and a see­min­gly ko­rean cha­rac­te­r.

The do­main na­me is le­ga­l, tha­t's just a one-­cha­rac­ter uni­co­de na­me, whi­ch see­ms to be le­gal ac­cor­ding to the ru­les of the ws TL­D. Then a uni­co­de pa­th, again just one cha­rac­te­r.

Sin­ce uni­co­de has se­ve­ral thou­sand gl­y­phs, it is con­cei­ba­ble that about a tri­llion URLs could be do­ne using on­ly a 3-­le­tter pa­th, whi­ch is pre­tty awe­so­me.

Of cour­se you pro­ba­bly can't ty­pe the damn things, but you can co­p­y&­pas­te the­m.

If any of this does­n't wo­rk for you, get on the uni­co­de wa­gon al­read­y!

PyQt by example (Session 2)

I am fi­nal­ly pub­lish­ing my Lati­noWare 2008 tu­to­ri­al, in re­vised and ex­pand­ed for­m. It will prob­a­bly be a 10-­part se­ries, and here is ses­sion 2.

See al­so ses­sion 1.

Using assistant from PyQt

The uRSSus doc is slow­ly grow­ing, so I hooked as­sis­tant to the UI. Not dif­fi­cult, but I have not seen it else­where.

Here's how:

As­sume the "Hand­book ac­tion" is called ac­tion_Hand­book. Set win­dow.as­sis­tant to None in __init__.

def on_action_Handbook_triggered(self, i=None):
    if i==None: return

    if not self.assistant or \
       not self.assistant.poll()==None:

        helpcoll=os.path.join(os.path.abspath(os.path.dirname(__file__)),\
                              'help',\
                              'out',\
                              'collection.qhc')
        cmd="assistant -enableRemoteControl -collectionFile %s"%helpcoll
        self.assistant=subprocess.Popen(cmd,
                                        shell=True,
                                        stdin=subprocess.PIPE)
    self.assistant.stdin.write("SetSource qthelp://urssus/doc/handbook.html\n")

And that's it. Now I ned to fig­ure out con­text help.

Rawdog is flexible: using Mako templates

Wh­y? It's ba­si­ca­lly un­do­cu­men­te­d, it looks ugly and it does­n't su­pport tem­pla­te inhe­ri­tan­ce, whi­ch in this ca­se is ve­ry use­fu­l, be­cau­se I am ac­tua­lly doing two ve­ry si­mi­lar pla­ne­ts: 1 2.

So, sin­ce I saw a plu­gin to use Ve­llum tem­pla­tes, I thou­gh­t, why not use my fa­vou­ri­te tem­pla­ting li­bra­ry (Mako) ins­tea­d?

It turns out to be ve­ry ea­sy to do!

Just put this in your plu­gins fol­der and start using Mako tem­pla­tes (ye­s, the pla­ne­t's con­fig and stu­ff is in gi­thub. Why no­t?).

# -*- coding: utf-8 -*-
import rawdoglib.plugins

from mako.template import Template
from mako.lookup import TemplateLookup
from mako import exceptions

class MakoPlugin:
    def __init__(self):
        self.lookup = TemplateLookup(directories=['.'],\
                              output_encoding='utf-8',\
                              encoding_errors='replace')

    def fill_template(self,template, bits, result):
        self.lookup.put_string('actual',template)
        t=self.lookup.get_template('actual')
        try:
            r=t.render_unicode(**bits)
        except:
            r=exceptions.html_error_template().render()
        result.value=r
        return False

p = MakoPlugin()
rawdoglib.plugins.attach_hook("fill_template",\
                              p.fill_template)

Yu­p, 20 li­nes of co­de!


Contents © 2000-2023 Roberto Alsina