Rescan Channels in MythTV Remotely

From time to time I need to rescan channels for my parents’ MythTV box. It happens so rarely that I forget what to do, so, for future reference:

Use a particularly fast X-forwarding over ssh:

ssh -c arcfour,blowfish-cbc -XC mymyththtv.home

Start mythtv-setup in a small window:

mythtv-setup -w --geometry 640x480

It will ask to stop the backend, but that doesn’t always work, so be sure to check that there are no mythtv backends or frontends running before you do the channel scan.

Go to [Channel Inputs] select the card and run a full scan. This takes ages, and maybe a few attempts.

For where my folks live, the channels it finds correspond to the mux channels listed on:
http://www.2rn.ie/wp-content/uploads/2013/10/2RN-DTT-Television-Transmission-Network-Oct-2013.pdf

So, I could probably save a lot of time by doing a Full Scan (tuned) instead of a Full Scan. In my case, it shows that it finds channels on Channel 23 and 26 (Mount Leinster). I’ll try that next time.

Advertisements

Setting up Samsung 840 EVO SSDs on Linux

The Samsung 840 EVO SSD is a bit tricky to set up so here are some notes on the process.

Update the firmware

I first tried creating a bootable USB stick using Samsung’s .iso and unetbootin. This didn’t work, it threw an error “PANIC: mcb chain corrupted”. Then I found a great post which described how to use the standard FreeDOS to get it to work. After the update was complete the application warned “FIRMWARE UPDATE UNSUCCESSFUL!!!” although it had actually worked correctly 😀

Partition alignment

Apparently, it’s quite important to align the partitions, especially on SSDs. If it’s wrong the disks can perform poorly and wear out more quickly. This disk uses a new technology (TLC) which has an unusual erase block size of 1536kb. I can’t find anywhere online which explicitly says to use that as the value for the sector boundary, but I guess it would be OK.

http://www.thessdreview.com/Forums/showthread.php?t=3630

I did find a question about aligning the partitions for these disks which explains how to use gdisk to do it. The answer suggests to use the lowest common multiple of 1.5 and 2 to be on the safe side: 6MiB. In brief, you use `gdisk /dev/sdX`, hit “X” for expert mode, “L” to set the sector alignment, and use 6144 as the value. Hit “m” to return to normal mode. Now “p” will show “Partitions will be aligned on 6144-sector boundaries” so you’re ready to create new partitions.

I also created a BIOS boot partition, since my machine uses BIOS rather than UEFI following the instructions from the Arch Linux wiki.

IPython notebook with Plone

IPython notebook is a browser based python shell with lots of nice features. Almost every presentation at Pycon.ie featured it in some way or other. If you’re a fan of using IPython with plone, you may find notebook interesting too.

It’s easy to get it working via buildout, just add an extra argument to the initialization:

[ipzope-notebook]
recipe = zc.recipe.egg
eggs = 
    ipython
    ${instance:eggs}
initialization =
    import sys, os
    os.environ["INSTANCE_HOME"] = "${instance:location}"
    sys.argv[1:1] = "notebook --profile zope2".split()
scripts = ipython=ipzopenb

Image

Legal, global video streaming options which help fund independent movie productions

I dream of the day when I can easily, financially support people who
make great things and share them freely. Whether that be media, tools
or, more radically, social systems, infrastructure or field trips to
Mars. Right now it’s a challenge to be able to legally acquire movies
that I want to watch at all, but it is slowly getting better.

I live in Germany, so, thanks to regional distribution restrictions my
choices for watching movies which haven’t been dubbed are really
limited. I can rent DVDs online, which seems comical to me in this day
and age. The selection isn’t great and it’s über cumbersome. There is
one streaming service in Germany which has some titles in English, but
again the selection is very limited and it’s also a terribly clunky
system which depends on Microsoft Silverlight (a technology even
Microsoft has turned its back on).

The other thing that bothers me about the mainstream services is that
I doubt the creators see much of the money themselves. The kinds of
indie movies which can actually make it into such distribution
networks have already sold their souls to corporate giants so the
rental fee I pay mostly gets gobbled up by the suits.

Technologically, it’s such a trivial task to share data globally that
the powers that be feel the need to artificially impose restrictions
and limitations which don’t make any sense. It’s a perverse form of
backwards compatibility which attempts to keep things working within
the slow moving legal and financial structures. Indeed, it’s dangerous
to support such distribution systems because they seriously infringe
on our personal privacy and human rights. To ensure that you can only
read an electronic book a certain number of times before it
“disintegrates” means that they need to keep track of your reading
habits. As long as consumers accept these terms and conditions such
practises have no reason to change.

Enough with the waffle, I really just wanted to mention some movie
streaming services I’ve been using recently which I hope are a sign of
things to come.

http://www.indiepixfilms.com/on-demand has some good ones. I quite
liked http://www.indiepixfilms.com/film/5476 Williamsburg and a
documentary http://www.indiepixfilms.com/film/4023 Hell On Wheels
about roller derby, a must for anyone who loved Whip It (only
available from indiepixfilms on DVD, sadly).

Then there’s http://www.vhx.tv which has some great independent
movies. Bizarrely, it doesn’t list them all on the website which is
obviously geared more towards movie creators than consumers. I asked
them if there was any available listing but didn’t get a
response. They obviously intend for each movie to have its own URL and
themed version of their interface. I did figure out a very silly way
to find films they host. I search the Internet for an exact phrase
from the terms and conditions page. With some movies you have the
option of paying more than the minimum price, which is cool, and they
also offer DRM free downloads. Here are some films I can highly
recommend:

Birth Story: http://watch.birthstorymovie.com
Sleepwalk With Me: http://watch.sleepwalkmovie.com
We Are Legion: http://wearelegionthedocumentary.com
TPB AFK: http://watch.tpbafk.tv
Beauty is Embarrasing: http://buy.beautyisembarrassing.com
I AM NOT A HIPSTER: http://www.iamnotahipster.com

Some of these are also available on the new vimeo on-demand service
https://vimeo.com/ondemand which is brilliant. Some Girl(s)
https://vimeo.com/ondemand/somegirls is a great film which isn’t
available on VHX.

These services all fall considerably short of my dream, and I can only
think of one example which doesn’t, Nina Paley’s ground breaking: Sita
Sings the Blues: http://www.sitasingstheblues.com/. Crowd funded
movies such as Iron Sky are also a step in the right direction.

Of course, there is no technical reason why creatives can’t tell the
world what they want to create, add a bitcoin wallet address and
continue pushing until they get enough people to back it, then make
the thing, pay everyone involved handsomely, and share it for everyone
to enjoy. There’s really no need for these intermediate services
except that society isn’t there yet.

Even though Free software is widely used, it can hardly be held up as
an example of a system where developers are rewarded financially by
end users for the work they share freely. Many improvements are funded
by large companies, perhaps by loosely related services such as
support, or even indirectly by means of spy-ware and ad-ware services
which rely on them. I guess I’m just an incurable optimist, but I sure
hope that will change.

DIY Standing Desks

I’ve just finished my second standing desk and I’m really happy with it, so I thought I’d throw up some photos. Materials cost about €60 and it took about four hours to slap it together, although it took another five hours to tweak it so that my monitor was in the right place.

Image
My new action station!
Image
Half way
Image
In the end, I removed the top board and mounted my monitor directly to the back

Image

And for some pics of the last desk I made. This one was way simpler and quicker to make, it also tilts like a draghtsman’s desk. Only 5 wooden boards are needed for the construction, and it cost about €35 for the wood. I think it took about three hours to stick it together.

IMG_20130630_131104
You may be able to see one of the two hinges here, on the left

IMG_20130630_131031 IMG_20130630_131052

Using a recursive generator and ZopeFind to walk the Zope database

For migrating a very large Plone 3 instance to Plone 4 we wanted to walk through the Zope database and avoid using the Plone catalog. Looping through the results for ZopeFind with search_sub=1 (which includes sub folders) means that it takes a long time to generate a massive list of results first, before it can do anything with them. With a large database this also uses a lot of RAM. What we needed was a recursive generator, but it took me a long time to wrap my head around how to write one. This article explains it nicely: http://linuxgazette.net/100/pramode.html.

I didn’t get it until I realized that when you call the function you get back a generator (because you yield a value). This is why you have to loop through your recursive call. Python generators were introduced about 10 years ago, I’m only starting to realize what I’ve been missing!

portal = app.portal

def walk(node):
    for idx, sub_node in node.ZopeFind(node, search_sub=0):
        yield sub_node
        if getattr(sub_node, "meta_type", "") in ['ATBTreeFolder', 'ATFolder']:
            for sub_sub_node in walk(sub_node):
                yield sub_sub_node

walker = walk(portal)

Incidentally, I came across a very creative solution to traversing the Zope database in collective.solr:

https://github.com/Jarn/collective.solr/blob/master/src/collective/solr/utils.py#L126

The trick here is that it loops over a list of paths, which it updates inside the loop!

Command line xml queries for Plone configuration using xmlstarlet

One of the nice things about having declarative configuration in xml files is that you can use standard xml tools to do interesting things with them. XMLStarlet is a handy command line tool for manipulating xml. For a migration from a Plone 3 site to Plone 4 I wanted to check some things e.g. Portlets Generic Setup syntax changes explains that the use of the “for” attribute in a portlet element is deprecated. I would like to know if we have any Generic Setup xml with a portlet element which has a “for” attribute:

$ xmlstarlet sel -t -m //portlet[@for] -c . some.xml

This uses the XPath expression “//portlet[@for]” to select any >portlet< elements which have a “for” attribute. It returns a copy of any elements which match. Let’s combine this with find:

$ find . -name "*.xml" -exec xmlstarlet sel -t -m //portlet[@for] -f -n -c . -n {} \;

Here we also output the filename with “-f” and add a few newlines to make it easier to read “-n”.

You will often need to set the namespace too:

find -L . -name "*.zcml" -exec xmlstarlet sel -N x="http://namespaces.zope.org/zope" -t -m //x:vocabulary -f -n -c . -n {} \;

This can easily be adjusted for more complicated queries. The interesting parts are the XPath expression and if you want a copy of the whole matching element you can use “-c .” as above, if you want the value you can use “-v”. See http://xmlstar.sourceforge.net/doc/xmlstarlet.txt for more info.

A nice tutorial:
http://www.freesoftwaremagazine.com/articles/xml_starlet

EDIT:

To print the value of an attrtribute you can use -c “string(@attrname)”

<?xml version="1.0"?>
<phonebook>
 <contact>
  <name>John Doe</name>
  <phone type="home">555-1234</phone>
  <phone type="work" class="emphasis">555-9876</phone>
  </contact>
</phonebook>
xmlstarlet sel -t -m "//contact/phone[@type='work']" -c "string(@class)"  test.xml