Index :: FAQ :: Contact

Featured Media: Basenet Radio

The show has been dormant for some time (years) but its back.

Latest HackerMedia:

May 01, 2016

Hacker Public Radio
HPR2021: HPR Community News for April 2016
New hosts Welcome to our new hosts: Joe, brian. Last Month's Shows Id Day Date Title Host 2000 Fri 2016-04-01 How to Point a Satellite Dish Ken Fallon 2001 Mon 2016-04-04 HPR Community News for March 2016 HPR Volunteers 2002 Tue 2016-04-05 Just got a Raspberry Pi Zero swift110 2003 Wed 2016-04-06 Using the Incron file watching daemon b-yeezi 2004 Thu 2016-04-07 A First Look at the Owon B35T NYbill 2005 Fri 2016-04-08 How I prepare and record my HPR Kdenlive voiceover shows. Geddes 2006 Mon 2016-04-11 Basic Audio Production - Compression Nacho Jordi 2007 Tue 2016-04-12 My new laptop Dave Morriss 2008 Wed 2016-04-13 HPR needs shows to survive. Ken Fallon 2009 Thu 2016-04-14 Understanding the GNU/Screen Hardstatus line Curtis Adkins (CPrompt^) 2010 Fri 2016-04-15 Parsing JSON with Python klaatu 2011 Mon 2016-04-18 Introduction to sed - part 4 Dave Morriss 2012 Tue 2016-04-19 Parsing XML in Python with Untangle klaatu 2013 Wed 2016-04-20 Parsing XML in Python with Xmltodict klaatu 2014 Thu 2016-04-21 A first look at the Owon B35T Part 2 NYbill 2015 Fri 2016-04-22 Linux in the Church Joe 2016 Mon 2016-04-25 Echoprint laindir 2017 Tue 2016-04-26 Here are my thoughts on a 3D printer Kit. cheeto4493 2018 Wed 2016-04-27 How to make Komboucha Tea b-yeezi 2019 Thu 2016-04-28 a pi project and an owncloud project Matt McGraw (g33kdad) 2020 Fri 2016-04-29 Automotive Billing brian Mailing List discussions Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes place on the Mail List which is open to all HPR listeners and contributors. The discussions are open and available on the Gmane archive. The main threads this month were: From: NYbill <nybill@...> Date: 2016-04-04 17:08:54 -0400 Subject: Fwd: Re: Defaults... Link: Messages: 1 From: Ken Fallon <ken@...> Date: 2016-04-05 20:20:08 +0200 Subject: Call for shows Link: Messages: 5 From: Mike Ray <mike@...> Date: 2016-04-06 13:45:38 +0100 Subject: HTML notes accessibility pointer Link: Messages: 7 From: Curtis Adkins <curtadkins@...> Date: 2016-04-09 21:26:57 -0400 Subject: Upload show issue Link: Messages: 2 From: Ken Fallon <ken@...> Date: 2016-04-12 08:12:09 +0200 Subject: Fwd: CFP for Full Stack Fest 2016 has opened! Link: Messages: 1 From: Ken Fallon <ken@...> Date: 2016-04-19 13:21:58 +0200 Subject: 11th Annual People's Podcast Awards Link: Messages: 1 From: Ken Fallon <ken@...> Date: 2016-04-21 15:46:34 +0200 Subject: Fwd: for your podcast: interview about FOSS situation in Russia Link: Messages: 1 From: Frank Bell <frankwbell@...> Date: 2016-04-21 13:37:59 -0400 Subject: Proposed New Series Link: Messages: 8 From: Carl D Hamann <carl.hamann@...> Date: 2016-04-22 10:42:04 -0500 Subject: Re: Proposed New Series Link: Messages: 2 From: Dave Morriss <perloid@...> Date: 2016-04-25 15:27:13 +0100 Subject: HPR Community News - next Saturday on 2016-04-30T18:00:00Z Link: Messages: 5 From: Fifty OneFifty <fiftyonefifty@...> Date: 2016-04-25 21:56:10 -0500 Subject: Re: Hpr Digest, Vol 91, Issue 11 Link: Messages: 3 From: Carl D Hamann <carl.hamann@...> Date: 2016-04-25 23:01:41 -0500 Subject: Re: HPR Community News - next Saturday on 2016-04-30T18:00:00Z Link: Messages: 1 From: Dave Morriss <perloid@...> Date: 2016-04-30 18:21:57 +0100 Subject: Re: HPR Community News - next Saturday on 2016-04-30T18:00:00Z Link: Messages: 1 Total messages this month: 38 Comments this month These are comments which have been made during the past month, either to shows released during the month or to past shows. There are 46 comments: hpr1987 (2016-03-15) "Pomodoro Timer - The Evolution of a Script (pt 1)" by Nacho Jordi. Comment 2: David L. Willson on 2016-04-17: "changed my life" hpr1990 (2016-03-18) "Pomodoro Timer - The Evolution of a Script part deux" by Nacho Jordi. Comment 1: David L. Willson on 2016-04-17: "found it!" hpr1993 (2016-03-23) "Can your window manager do this?" by Nacho Jordi. Comment 1: sigflup on 2016-04-04: "ratpoison" hpr1996 (2016-03-28) "Xdotool magic" by Nacho Jordi. Comment 1: Urugami on 2016-04-18: "File Naming" hpr1998 (2016-03-30) "Homebrewing" by m1rr0r5h4d35. Comment 2: Ken Fallon on 2016-04-07: "Would love to hear the full recoring" hpr1999 (2016-03-31) "How I record a full band under Linux" by noplacelikeslashhome. Comment 1: Jon Kulp on 2016-04-01: "More on Ardour!" Comment 2: Ken Fallon on 2016-04-06: "More detail" hpr2000 (2016-04-01) "How to Point a Satellite Dish" by Ken Fallon. Comment 1: Mike Ray on 2016-04-04: "I tried very hard..." Comment 2: droops on 2016-04-04: "Very Good" Comment 3: Frank on 2016-04-05:"[no title]" Comment 4: Ken Fallon on 2016-04-06: "Beep" hpr2001 (2016-04-04) "HPR Community News for March 2016" by HPR Volunteers. Comment 1: Jon Kulp on 2016-04-04: "Not a Timing Belt" hpr2002 (2016-04-05) "Just got a Raspberry Pi Zero" by swift110. Comment 1: Ken Fallon on 2016-04-06: "I'm so jealous" hpr2003 (2016-04-06) "Using the Incron file watching daemon" by b-yeezi. Comment 1: Ken Fallon on 2016-04-06: "Installing this now" hpr2004 (2016-04-07) "A First Look at the Owon B35T" by NYbill. Comment 1: Ken Fallon on 2016-04-07: "daisy chain" Comment 2: NYbill on 2016-04-07: "Americanism's?" Comment 3: Dave Morriss on 2016-04-07: "Not an Americanism to my knowledge" Comment 4: Ken Fallon on 2016-04-08: "Why not what" Comment 5: NYbill on 2016-04-08:"[no title]" hpr2005 (2016-04-08) "How I prepare and record my HPR Kdenlive voiceover shows." by Geddes. Comment 1: NYbill on 2016-04-10: "Well done." Comment 2: Ken Fallon on 2016-04-17: "Such Effort" hpr2006 (2016-04-11) "Basic Audio Production - Compression" by Nacho Jordi. Comment 1: Ken Fallon on 2016-04-17: "Great Addition" hpr2007 (2016-04-12) "My new laptop" by Dave Morriss. Comment 1: Ken Fallon on 2016-04-17: "Suspect" Comment 2: Dave Morriss on 2016-04-18: "I dunno what you're talking about" Comment 3: Alpha32 on 2016-04-26: "Interesting show" hpr2008 (2016-04-13) "HPR needs shows to survive." by Ken Fallon. Comment 1: 0xf10e on 2016-04-13: "But Ken, " Comment 2: Jonathan Kulp on 2016-04-14: "sure you can!" Comment 3: Ken Fallon on 2016-04-17: "Thanks" hpr2009 (2016-04-14) "Understanding the GNU/Screen Hardstatus line" by Curtis Adkins (CPrompt^). Comment 1: Ken Fallon on 2016-04-22: "Great show" hpr2010 (2016-04-15) "Parsing JSON with Python" by klaatu. Comment 1: Zen_Floater2 on 2016-04-14: "squirrel" Comment 2: Ken Fallon on 2016-04-22: "Don't like xpath !" hpr2011 (2016-04-18) "Introduction to sed - part 4" by Dave Morriss. Comment 1: b-yeezi on 2016-04-18: "Wow" Comment 2: Dave Morriss on 2016-04-19: "Thanks" Comment 3: Ken Fallon on 2016-04-22: "Nice one" hpr2012 (2016-04-19) "Parsing XML in Python with Untangle" by klaatu. Comment 1: Ken Fallon on 2016-04-22: "Normal Parsers" hpr2013 (2016-04-20) "Parsing XML in Python with Xmltodict" by klaatu. Comment 1: sigflup on 2016-04-19: "cool" Comment 2: Ken Fallon on 2016-04-22: "large complex files " hpr2014 (2016-04-21) "A first look at the Owon B35T Part 2" by NYbill. Comment 1: Mike Ray on 2016-04-21: "Great Show" Comment 2: NYbill on 2016-04-21: "Its a brand new bench! " Comment 3: Ken Fallon on 2016-04-25: "Logging in android" hpr2015 (2016-04-22) "Linux in the Church" by Joe. Comment 1: jan on 2016-04-24:"[no title]" Comment 2: Ken Fallon on 2016-04-25: "Great episode" hpr2016 (2016-04-25) "Echoprint" by laindir. Comment 1: Ken Fallon on 2016-04-25: "Thank you Thank you Thank you Thank you " hpr2019 (2016-04-28) "a pi project and an owncloud project" by Matt McGraw (g33kdad). Comment 1: Matt (g33kdad) on 2016-04-23: "Some photos" Comment 2: Jonathan Kulp on 2016-04-30: "Muttonchop too" hpr2020 (2016-04-29) "Automotive Billing" by brian. Comment 1: Frank on 2016-04-30:"[no title]"

April 28, 2016

Hacker Public Radio
HPR2020: Automotive Billing
I get a call to look at my friend's broke down car.

Phone Losers
Lube Job Customers Still Aren't Angry
Today is yet another episode of car dealership prank calls where nobody gets very angry or confused about our calls to them. You can thanks Ty A. for that, who is the sponsor of today's show.

April 27, 2016

Hacker Public Radio
HPR2019: a pi project and an owncloud project
HPR - A couple of Projects I've been working on Intro Please record a show!!!!! Couple of Projects Pi Project Love of Music Digital, of course and webradio Sonos, other proprietary solutions Got a Pi2 for XMas Pi Music Box RuneAudio Arch Based underlying tech is MPD flash SD Card boot with network cable attached add music and webradios to library .pls and .m3u files PhotoFrame Project proprietary items tablet/smart phone lying around ownCloud update for my parents on the road Links and other Goodies Pi Project SomaFM Capital Public Radio Sonos Samsung Shape PiMusicBox Rune Audio Music Player Daemon USB Audio Dongle (amazon link... NOT an affiliate link) PicFrame Project ownCloud Kindle Fire HD 6 PicFrame PicFrame Android App Contact Info Matt McGraw - matty at the strangeland dot net Stay-At-Home G33k Dad ~ Fatherhood in the digital age @sahg33kdad Google+ The following link includes a photo of the RPi in the bookshelf with the stereo as well as a screenshot of the Rune Audio app running on my Android phone.

Off the Hook
Off The Hook - Apr 27, 2016

The Linux Link Tech Show
The Linux Link Tech Show Episode 656
joels review of the remix jide tablet, good stuff.

April 26, 2016

Hacker Public Radio
HPR2018: How to make Komboucha Tea
How to Make Kamboucha Tea Makes about 1 gallon Ingredients Ingredient US Metric water 3 1/2 quarts ?? white sugar 1 cup ?? black tea 8 bags (or 2 tablespoons loose tea) ?? starter tea from last batch of kombucha or store-bought 2 cups ?? scoby 1 per fermentation jar N/A Optional flavoring extras for bottling: 1 to 2 cups chopped fruit, 2 to 3 cups fruit juice, 1 to 2 tablespoons flavored tea (like hibiscus or Earl Grey), 1/4 cup honey, 2 to 4 tablespoons fresh herbs or spices Equipment Stock pot 1-gallon glass jar or two 2-quart glass jars Bottles: Six 16-oz glass bottles with plastic lids, 6 swing-top bottles, or clean soda bottles Instructions Note: Avoid prolonged contact between the kombucha and metal both during and after brewing. This can affect the flavor of your kombucha and weaken the scoby over time. 1. Make the Tea Base: Bring the water to a boil. Remove from heat and stir in the sugar to dissolve. Drop in the tea and allow it to steep until the water has cooled. Depending on the size of your pot, this will take a few hours. You can speed up the cooling process by placing the pot in an ice bath. 2. Add the Starter Tea: Once the tea is cool, remove the tea bags or strain out the loose tea. Stir in the starter tea. (The starter tea makes the liquid acidic, which prevents unfriendly bacteria from taking up residence in the first few days of fermentation.) 3. Transfer to Jars and Add the Scoby: Pour the mixture into a 1-gallon glass jar (or divide between two 2-quart jars, in which case you'll need 2 scobys) and gently slide the scoby into the jar with clean hands. Cover the mouth of the jar with a few layers of cheesecloth or paper towels secured with a rubber band. 4. Ferment for 7 to 10 Days: Keep the jar at room temperature, out of direct sunlight, and where it won't get jostled. Ferment for 7 to 10 days, checking the kombucha and the scoby periodically. It's not unusual for the scoby to float at the top, bottom, or even sideways. A new cream-colored layer of scoby should start forming on the surface of the kombucha within a few days. It usually attaches to the old scoby, but it's ok if they separate. You may also see brown stringy bits floating beneath the scoby, sediment collecting at the bottom, and bubbles collecting around the scoby. This is all normal and signs of healthy fermentation. After seven days, begin tasting the kombucha daily by pouring a little out of the jar and into a cup. When it reaches a balance of sweetness and tartness that is pleasant to you, the kombucha is ready to bottle. 5. Remove the Scoby: Before proceeding, prepare and cool another pot of strong tea for your next batch of kombucha, as outlined above. With clean hands, gently lift the scoby out of the kombucha and set it on a clean plate. As you do, check it over and remove the bottom layer if the scoby is getting very thick. 6. Bottle the Finished Kombucha: Measure out your starter tea from this batch of kombucha and set it aside for the next batch. Pour the fermented kombucha (straining, if desired) into bottles, along with any juice, herbs, or fruit you may want to use as flavoring. Leave about a half inch of head room in each bottle. (Alternatively, infuse the kombucha with flavorings for a day or two in another jar covered with cheesecloth, strain, and then bottle. This makes a cleaner kombucha without "stuff" in it.) 7. Carbonate and Refrigerate the Finished Kombucha: Store the bottled kombucha at room-temperature out of direct sunlight and allow 1 to 3 days for the kombucha to carbonate. Until you get a feel for how quickly your kombucha carbonates, it's helpful to keep it in plastic bottles; the kombucha is carbonated when the bottles feel rock solid. Refrigerate to stop fermentation and carbonation, and then consume your kombucha within a month. 8. Make a Fresh Batch of Kombucha: Clean the jar being used for kombucha fermentation. Combine the starter tea from your last batch of kombucha with the fresh batch of sugary tea, and pour it into the fermentation jar. Slide the scoby on top, cover, and ferment for 7 to 10 days. Additional Notes: • Batch Size: To increase or decrease the amount of kombucha you make, maintain the basic ratio of 1 cup of sugar, 8 bags of tea, and 2 cups starter tea per gallon batch. One scoby will ferment any size batch, though larger batches may take longer. • Putting Kombucha on Pause: If you'll be away for 3 weeks or less, just make a fresh batch and leave it on your counter. It will likely be too vinegary to drink by the time you get back, but the scoby will be fine. For longer breaks, store the scoby in a fresh batch of the tea base with starter tea in the fridge. Change out the tea for a fresh batch every 4 to 6 weeks. • Other Tea Options: Black tea tends to be the easiest and most reliable for the scoby to ferment into kombucha, but once your scoby is going strong, you can try branching out into other kinds. Green tea, white tea, oolong tea, or a even mix of these make especially good kombucha. Herbal teas are ok, but be sure to use at least a few bags of black tea in the mix to make sure the scoby is getting all the nutrients it needs. Avoid any teas that contain oils, like earl grey or flavored teas. • Avoid Prolonged Contact with Metal: Using metal utensils is generally fine, but avoid fermenting or bottling the kombucha in anything that brings them into contact with metal. Metals, especially reactive metals like aluminum, can give the kombucha a metallic flavor and weaken the scoby over time. Troubleshooting Kombucha • It is normal for the scoby to float on the top, bottom, or sideways in the jar. It is also normal for brown strings to form below the scoby or to collect on the bottom. If your scoby develops a hole, bumps, dried patches, darker brown patches, or clear jelly-like patches, it is still fine to use. Usually these are all indicative of changes in the environment of your kitchen and not a problem with the scoby itself. • Kombucha will start off with a neutral aroma and then smell progressively more vinegary as brewing progresses. If it starts to smell cheesy, rotten, or otherwise unpleasant, this is a sign that something has gone wrong. If you see no signs of mold on the scoby, discard the liquid and begin again with fresh tea. If you do see signs of mold, discard both the scoby and the liquid and begin again with new ingredients. • A scoby will last a very long time, but it's not indestructible. If the scoby becomes black, that is a sign that it has passed its lifespan. If it develops green or black mold, it is has become infected. In both of these cases, throw away the scoby and begin again. • To prolong the life and maintain the health of your scoby, stick to the ratio of sugar, tea, starter tea, and water outlined in the recipe. You should also peel off the bottom (oldest) layer every few batches. This can be discarded, composted, used to start a new batch of kombucha, or given to a friend to start their own. • If you're ever in doubt about whether there is a problem with your scoby, just continue brewing batches but discard the kombucha they make. If there's a problem, it will get worse over time and become very apparent. If it's just a natural aspect of the scoby, then it will stay consistent from batch to batch and the kombucha is fine for drinking.

April 25, 2016

Hacker Public Radio
HPR2017: Here are my thoughts on a 3D printer Kit.
I purchased a 3D printer kit from AliExpress. Here are some after thoughts on how I liked it, a little overview of 3D printers and why I bought this one. Pictures of the printer as assembled, and a few items I printed I hope to make this into a series about software, tips and modifications, and other thoughts I have to share about it. Links

April 24, 2016

Hacker Public Radio
HPR2016: Echoprint
Ken's message asking about programmatically checking for the intro and outro: The Echoprint website: Codegen source code: Echoprint - An Open Music Identification Service: Server source code

Phone Losers
Falling Off The Potato Wagon
UtahKurt is responsible for RBCP falling off the potato wagon today and calling up a bunch of lube job customers who refused to get angry about the horrible things I did inside their cars.

April 21, 2016

Hacker Public Radio
HPR2015: Linux in the Church
Linux has been my exclusive OS for many years. When I became the tech director at my church I wanted to utilize the power and freedom of Open Source so I'm gradually implementing it on many of my project.

April 20, 2016

Hacker Public Radio
HPR2014: A first look at the Owon B35T Part 2
In this episode of HPR you get to hear more of the things on NYbill's electronics bench that make clicking noises. The review of the Owon B35T's continues. Bluetooth is now working. And we get an inside look at the meter. The Owon B35T: Pics for the episode:

Off the Hook
Off The Hook - Apr 20, 2016

Phone Losers
Microwave Beam Experiments For Science
Jeff sponsors today's educational edition of The Snow Plow Show. Thanks, Jeff! In this episode we notify members of a homeowner's association that we're beaming microwaves at their house and there's nothing they can do about it.

The Linux Link Tech Show
The Linux Link Tech Show Episode 655
reactions to intel insecurity, rich and his apple woes

April 19, 2016

Hacker Public Radio
HPR2013: Parsing XML in Python with Xmltodict
If Untangle is too simple for your XML parsing needs, check out xmltodict. Like untangle, xmltodict is simpler than the usual suspects (lxml, beautiful soup), but it's got some advanced features as well. If you're reading this article, I assume you've read at least the introduction to my article about Untangle, and you should probably also read, at some point, my article on using JSON just so you know your options. Quick re-cap about XML: XML is a way of storing data in a hierarchical arrangement so that the data can be parsed later. It's explicit and strictly structured, so one of its benefits is that it paints a fairly verbose definition of data. Here's an example of some simple XML: <?xml version="1.0"?> <book> <chapter id="prologue"> <title> The Beginning </title> <para> This is the first paragraph. </para> </chapter> <chapter id="end"> <title> The Ending </title> <para> Last para of last chapter. </para> </chapter> </book> And here's some info about the xmltodict library that makes parsing that a lot easier than the built-in Python tools: Install Install xmltodict manually, or from your repository, or using pip: $ pip install xmltodict or if you need to install it locally: $ pip install --user xmltodict Xmltodict With xmltodict, each element in an XML document gets converted into a dictionary (specifically an OrderedDictionary), which you then treat basically the same as you would JSON (or any Python OrderedDict). First, ingest the XML document. Assuming it's called sample.xml and is located in the current directory: >>> import xmltodict >>> with open('sample.xml') as f: ... data = xmltodict.parse( If you're a visual thinker, you might want or need to see the data. You can look at it just by dumping data: >>> data OrderedDict([('book', OrderedDict([('chapter', [OrderedDict([('@id', 'prologue'), ('title', 'The Beginning'), ...and so on... Not terribly pretty to look at. Slightly less ugly is your data set piped through json.dumps: >>> import json >>> json.dumps(data) '{"book": {"chapter": [{"@id": "prologue", "title": "The Beginning", "para": "This is the first paragraph."}, {"@id": "end", "title": "The Ending", "para": "This is the last paragraph of the last chapter."}] }}' You can try other feats of pretty printing, if they help: >>> pp = pprint.PrettyPrinter(indent=4) >>> pp.pprint(data) { 'book': { 'chapter': [{'@id': 'prologue', 'title': 'The Beginning', 'para': 'This is the ... ...and so on... More often than not, though, you're going to be "walking" the XML tree, looking for specific points of interest. This is fairly easy to do, as long as you remember that syntactically you're dealing with a Python dict, while structurally, inheritance matters. Elements (Tags) Exploring the data element-by-element is very easy. Calling your data set by its root element (in our current example, that would be data['book']) would return the entire data set under the book tag. We'll skip that and drill down to the chapter level: >>> data['book']['chapter'] [OrderedDict([('@id', 'prologue'), ('title', 'The Beginning'), ('para', 'This is the first paragraph.')]), OrderedDict([('@id', 'end'), ('title', 'The Ending'), ('para', 'Last paragraph of last chapter.')])] Admittedly, it's still a lot of data to look at, but you can see the structure. Since we have two chapters, we can enumerate which chapter to select, if we want. To see the zeroeth chapter: >>> data['book']['chapter'][0] OrderedDict([('@id', 'prologue'), ('title', 'The Beginning'), ('para', 'This is the first paragraph.')]) Or the first chapter: >>> data['book']['chapter'][1] OrderedDict([('@id', 'end'), ('title', 'The Ending'), ('para', 'Last paragraph of last chapter.')]) And of course, you can continue narrowing your focus: >>> data["book"]["chapter"][0]['para'] 'This is the first paragraph.' It's sort of like Xpath for toddlers. Having had to work with Xpath, I'm happy to have this option. Attributes You may have already noticed that in the dict containing our data, there is some special notation happening. For instance, there is no @id element in our XML, and yet that appears in the dict. Xmltodict uses the @ symbol to signify an attribute of an element. So to look at the attribute of an element: >>> data['book']['chapter'][0]['@id'] 'prologue' If you need to see each attribute of each chapter tag, just iterate over the dict. A simple example: >>> for c in range(0,2): ... data['book']['chapter'][c]['@id'] ... 'prologue' 'end' Contents In addition to special notation for attributes, xmltodict uses the # prefix to denote contents of complex elements. To show this example, I'll make a minor modification to sample.xml: <?xml version="1.0"?> <book> <chapter id="prologue"> <title> The Beginning </title> <para class="linux"> This is the first paragraph. </para> </chapter> <chapter id="end"> <title> The Ending </title> <para class="linux"> Last para of last chapter. </para> </chapter> </book> Notice that the <para> elements now have a linux attribute, and also contain text content (unlike <chapter> elements, which have attributes but only contain other elements). Look at this data structure: >>> import xmltodict >>> with open('sample.xml') as g: ... data = xmltodict.parse( >>> data['book']['chapter'][0] OrderedDict([('@id', 'prologue'), ('title', 'The Beginning'), ('para', OrderedDict([('@class', 'linux'), ('#text', 'This is the first paragraph.')]))]) There is a new entry in the dictionary: #text. It contains the text content of the <para> tag and is accessible in the same way that an attribute is: >>> data['book']['chapter'][0]['para']['#text'] 'This is the first paragraph.' Advanced The xmltodict module supports XML namespaces and can also dump your data back into XML. For more documentation on this, have a look at the module on What to Use? Between untangle, xmltodict, and JSON, you have pretty good set of options for data parsing. There really are diferent uses for each one, so there's not necessarily a "right" or "wrong" answer. Try them out, see what you prefer, and use what is best. If you don't know what's best, use what you're most comfortable with; you can always improve it later. [EOF] Made on Free Software.

April 18, 2016

Hacker Public Radio
HPR2012: Parsing XML in Python with Untangle
XML is a popular way of storing data in a hierarchical arrangement so that the data can be parsed later. For instance, here is a simple XML snippet: <?xml version="1.0"?> <book> <chapter id="prologue"> <title> The Beginning </title> </chapter> </book> The nice thing about XML is that it is explicit and strictly structured. The trade-off is that it's pretty verbose, and getting to where you want to go often requires fairly complex navigation. If you do a quick search online for XML parsing in Python, your two most common results are lxml and beautifulsoup. These both work, but using them feels less like opening a dictionary (as with JSON) to look up a definition and more like wandering through a library to gather up all the dictionaries you can possibly find. In JSON, the thought process might be something like: "Go to the first chapter's title and print the contents." With traditional XML tools, it's more like: "Open the book element and gather all instances of titles that fall within those chapters. Then, look into the resulting object and print the contents of the first occurrence." There are at least two libaries that you can install and use to bring some sanity to complex XML structures, one of which is untangle. Untangle With untangle, each element in an XML document gets converted into a class, which you can then probe for information. Makes no sense? well, follow along and it will become clear: First, ingest the XML document. Assuming it's called sample.xml and is located in the current directory: >>> import untangled >>> data = untangle.parse('sample.xml') Now our simple XML sample is sitting in RAM, as a Python class. The first element is <book> and all it contains is more elements, so its results are not terribly exciting: >>> Element(name = book, attributes = {}, cdata = ) As you can see, it does identify itself as "book" (under the name listing) but otherwise, not much to look at. That's OK, we can keep drilling down: >>> Element(name = chapter, attributes = {'id': 'prologue'}, cdata = ) Now things get more interesting. The next element identifies itself as "chapter", and reveals that it has an attribute "id" which has a value of "prologue". To continue down this path: >>> Element(name = title, attributes = {}, cdata = The Beginning ) And now we have a pretty complete picture of our little XML document. We have a breadcrumb trail of where we are in the form of the class we are invoking ( and we have the contents of our current position. Sniping That's very linear; if you know your XML schema (and you usually do, since XML is quite strict) then you can grab values without all the walking. For instance, we know that our chapters have 'id' attributes, so we can ask for exactly that: >>>['id'] 'prologue' You can also get the contents of elements by looking at the cdata component of the class. Depending on the formatting of your document, untangle may be a little too literal with how it stores contents of elements, so you may want to use .strip() to prettify it: >>> 'The Beginning' Dealing with More Than One Element My example so far is nice and tidy, with only one chapter in the book. Generally you'll be dealing with more data than that. Let's add another chapter to our sample file, and some content to each: <?xml version="1.0"?> <book> <chapter id="prologue"> <title> The Beginning </title> <para> This is the first paragraph. </para> </chapter> <chapter id="end"> <title> The Ending </title> <para> Last para of last chapter. </para> </chapter> </book> Accessing each chapter is done with index designations, just like with a dict: >>>[0] Element(name = chapter, attributes = {'id': 'prologue'}, cdata = ) >>>[1] Element(name = chapter, attributes = {'id': 'end'}, cdata = ) If there is more than one instance of a tag, you must use a designator or else untangle won't know what to return. For example, if we want to access either the title or para elements within a chapter: >>> Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'title' Oops. But if we tell it which one to look at: >>>[0].title.cdata.strip() 'The Beginning' >>>[1].title.cdata.strip() 'The Ending' Or you can look at the paragraph instead of the title. The lineage is the same, only instead of looking at the title child, you look at the para child: >>>[0].para.cdata.strip() 'This is the first paragraph.' >>>[1].para.cdata.strip() 'Last para of last chapter.' You can also iterate over items: >>> COUNT = [0,1] >>> for TICK in COUNT: ... print([TICK]) Element <chapter> with attributes {'id': 'prologue'} and children [Element(name = title, attributes = {}, cdata = The Beginning ), Element(name = para, attributes = {}, cdata = This is the first paragraph.)] Element <chapter> with attributes {'id': 'end'} and children [Element(name = title, attributes = {}, cdata = The Ending ), Element(name = para, attributes = {}, cdata = Last para of last chapter.)] And so on. Easy and Fast I'll admit the data structure of the classes does look odd, and you could probably argue it's not the cleanest and most elegant of all output; it's unnerving to see empty cdata fields or to constantly run into the need to strip() whitespace. However, the ease and speed and intuitiveness of parsing XML with untangle is usually well worth any trade-offs. [EOF] Made on Free Software.

Phone Losers
Milkbrain sponsors today's show where we talk to homeowners about their roofs and their front yard in ground pools.

April 17, 2016

Hacker Public Radio
HPR2011: Introduction to sed - part 4
Introduction to sed - part 4 In the last episode we looked at some of the more frequently used sed commands, having spent previous episodes looking at the s command, and we also covered the concept of line addressing. In this episode we will look at how sed really works in all the gory details, examine some of the remaining sed commands and begin to build useful sed programs. To read the rest of the notes for this episode follow this link: Links Introduction to sed - part 1: Introduction to sed - part 2: Introduction to sed - part 3: Some further Bash tips: GNU sed manual: Wikipedia entry for sed: "Sed - An Introduction and Tutorial" by Bruce Barnett: Wikibooks sed wiki: Example files: Demonstration Bash script: Demonstration of 'M' modifier: Wikipedia entry for "Pig Latin":

April 14, 2016

Hacker Public Radio
HPR2010: Parsing JSON with Python
JSON is a popular way of storing data in a key/value type arrangement so that the data can be parsed easily later. For instance, here is a very simple JSON snippet: { "name":"tux", "health":"23", "level":"4" } If you are like me, three questions probably spring to your mind: That looks an awful lot like a Python dictionary. Yes, it looks exactly like a Python dictionary. They are shockingly similar. If you are comfortable with Python lists and dictionaries, you will feel right at home with JSON. I don't feel comfortable with dictionaries, can't I just use a delimited text file? You can, but you will have to write parsers for it yourself. If your data gets very complex, the parsing can get pretty ugly. That is not to say that you should not use a simple delimited text file if that is all that your programme needs. For example, I would not want to open a config file as a user and find that I have to format all my options as valid JSON. Just know that JSON is out there and available, and that the JSON Python module has some little features that make your life easier when dealing with sets of data. Why not use XML instead? You can. Mostly one should use the most appropriate format for one's project. I'm a big fan of XML, but sometimes JSON makes more sense. I am not going to make this post about teaching the JSON format. If you need clarification on how to structure data into JSON, go through a tutorial on it somewhere; there are several good ones online. Honestly, it's not that complex; you can think of JSON as nested dictionaries. Starting from scratch, let's say that you write a programme that by nature gathers data as it runs. When the user quits, you want to save the data to a file so that when the user resumes the app later, they can load the file back in and pick up where they left off. Storing Data as JSON At its most basic, the JSON data structure is basically the same as a Python dictionary, and in fact the nice thing about JSON is that it can be directly imported into a Python dictionary. Usually, however, you are resorting to JSON because you have somewhat complex data, so in the sample code we will use a dictionary-within-a-dictionary: #!/usr/bin/env python game = {'tux': {'health': 23, 'level': 4}, 'beastie': {'health': 13, 'level': 6}} # you can always add more to your dictionary game['konqi'] = {'health': 18, 'level': 7} That code creates a ditionary called game which stores the player name and a corresponding dictionary of attributes about how the player is doing in the progress of the game. As you can see after the comment, adding new players is simple. Now let's see how to save that data to a save file. ## continued... import json with open('dosiero.json', 'w') as outfile: json.dump(game, outfile) That would be your save command. Simple as that, all the structured content of your game dictionary is committed to a file on your hard drive. Reading Data from a JSON File If you are saving data to JSON, you probably will evenually want to read the data back into Python. For this, Python features the function json.load import json dosiero = open('dosiero.json') game = json.load(dosiero) print game['tux'] # prints {'health': 23, 'level': 4} print game['tux']['health'] # prints 23 print game['tux']['level'] # prints 4 # when finished, close the file json_data.close() As you can see, JSON integrates surprisingly well with Python, so it's a great format when your data fits in with its model. Have fun! [EOF] Made with Free Software.

April 13, 2016

Hacker Public Radio
HPR2009: Understanding the GNU/Screen Hardstatus line
Links (CPrompt's .screenrc file) (GNU Man page on String Escapes)

Off the Hook
Off The Hook - Apr 13, 2016

The Linux Link Tech Show
The Linux Link Tech Show Episode 654

April 12, 2016

Hacker Public Radio
HPR2008: HPR needs shows to survive.
You can help out the Hacker Public Radio project by recording a show today. See for more information.

April 11, 2016

Hacker Public Radio
HPR2007: My new laptop
My new laptop I attended OggCamp15 in Liverpool at the end of October 2015. As usual I bought some raffle tickets as a contribution to the expenses of the (un-)conference, not paying much attention to the prizes. Actually, the star prize was a laptop donated by Entroware, a significant sponsor of the event, one of the most impressive prizes ever offered at OggCamp. There was quite a lot of excitement about this prize. I attended the drawing of the raffle at the end of proceedings on the Sunday. Dan Lynch (of Linux Outlaws, and a frequent organiser of OggCamp) was in attendance overseeing the selection of the raffle tickets. Various smaller prizes were won and the tension built up as the final drawing approached. Things got very tense when the first number drawn for the laptop was called and nobody responded. Then another draw was made. Imagine my shock and surprise when I realised I had the winning ticket! I had won the star prize in the OggCamp raffle! See the full show notes here for the details of the laptop. Links OggCamp15: Entroware Ltd.: Wikipedia article on "Ubuntu Netbook Edition": Wikipedia article on "CrunchBang Linux": TuxJam:

Link to us! is provided by:
Binary Revolution | Infonomicon Computer Club