Craig Maloney snapl@identi.ca

Just another Linux / Ubuntu / Python hacker. Host of http://openmetalcast.com and co-host of http://lococast.net

  • [Blog] Unprocrastination challenge: Check-in #2

    2017-01-21T06:00:11Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/oYe4kMakTbo/)

    Even though I'm laid off I'm still trying to work on The Unprocrastination Challenge. I'm trying to keep myself on as many routines as I can even though my tasks aren't accountable to anyone but myself. If I don't hold myself accountable then I'll be drifting along, and that's not good for myself and the things that I want to get done.

    Overall I've not been as good blocking off the Internet using Block Focus, but I have been able to pause and give myself the breathers that lead me to want to be on social media. Recognizing that I'm feeling overwhelmed by my thoughts and my desires to keep myself in comfort. Pushing myself outside of my comfort levels is how I'm going to grow.

    I have some more thoughts on this, but I'm keeping this short so I can collect my thoughts on how to break my cycles of procrastination.

  • [Blog] Unprocrastination challenge: Check-in #1

    2017-01-21T05:00:12Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/aiPSk8bPhHo/)

    So the "unprocrastination challenge" is in full swing. Here's what I've learned so far:

    • The Block Focus extension is quite good at keeping me from dallying on social media. It's a good reminder to put my focus back to what it is that I am doing.

    • I've been using the full Pomodoro 25 minutes rather than 5 minutes, as this is something that I'm used to. Unfortunately here's a little more resistance at certain points of the day to not start up another round. So I need to get myself to not be so worried about blocking things for a spell and just do the work.

    • Once I manage to get myself focused it's tempting for me to lose focus when I have to wait for something to complete. I need to remind myself to stay focused, and at the very least pull something off of my next actions list instead of letting the internet at large satiate my boredom.

    I've not been nearly as diligent as I should be with this whole exercise, but there are clear ways for me to improve. I think I can make it work.

    More later as the month progresses.

  • [Blog] What about plan C?

    2017-01-18T13:00:09Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/T3V2fGwdVO8/)

    With the closing of The Ringling Bros. and Barnum & Bailey Circus it appears my backup plan of running away to join the circus is less of a viable option.

  • Open Metalcast Episode #146: Jump In Anytime

    2017-01-17T01:17:59Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/gXJgapfHNrE/)

    Ever have one of those moments when you don’t know when to jump into a conversation? Where the time to speak doesn’t happen for a while? That’s what happened with this episode. Normally I jump in after the first few tracks but it didn’t seem right. And really, where would you interrupt such a great line-up of music from Dantalion, Feral, Abriosis, Totem Skin, Anopheli, and Sedulity? I don’t know the answer to that, but I do know this show is ready and waiting for your podcatching software of choice to download. Just make sure to leave yourself plenty of time to listen all the way through. You’d really hate to interrupt this set of amazing Creative Commons Metal Music.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or just buy up everything they’ve ever made. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #146 (MP3)

    Open Metalcast #146 (OGG)

  • 2017-01-06T14:59:37Z via p To: Public CC: Followers

    That moment when you change your procmail filters, start checking procmail logs, and receive no mail.

    jasonriedy@fmrl.me likes this.

    LOL... know this with Postfix spam rules... But I feel your pain :)

    Freemor at 2017-01-06T19:35:10Z

    Craig Maloney likes this.

  • [Blog] mismatch_cnt, RAID1, and a clever fix

    2017-01-03T22:00:07Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/ER1lc-by0lM/)

    This past weekend my computer showed an ominous error:

    Jan 1 04:06:16 lister mdadm[8317]: RebuildFinished event detected on md device /dev/md/0, component device mismatches found: 9856 (on raid level 1)

    Huh, that doesn't look particularly good. Mismatches between drives tend to lead to bad things.

    Once the original panic subsided I checked online.

    please explain mismatch_cnt so I can sleep better at night seemed promising for an explanation of what was going on. I read through this. "Aha! Swap files cause this problem!" I exclaimed to myself. "That has to be the culprit".

    Except my machine didn't have a swap file on a RAID1 device.

    Shoot. That would have been an easy explanation.

    Much like looking up symptoms online the more I searched the more my heart sank. Data corruption seemed the most obvious cause.

    I checked the SMART data on all of the drives. Nothing looked amiss there.

    I re-ran the checks:

    echo check > /sys/block/md0/md/sync_action

    and ran:

    watch cat /sys/block/md0/md/mismatch_cnt

    My heart sank as I watched the counter tick up and up.

    So I pulled out my copy of Spinrite and ran a read-test on all of my drives. Spinrite said there was nothing wrong with the hardware. So it had to be something up with the software RAID1 itself.

    I kept reading that the problem could one of two issues. Either: 1) there was a memory-mapped file that wasn't in sync between the drives, or 2) the free space between the drives didn't 100% match. I was still holding out that it wasn't 3) corrupted data.

    At this point I could have done:

    echo repair > /sys/block/md0/md/sync_action

    but that thought scared me. I had one of the drives on this machine corrupt a Virtualbox instance before when I mirrored the bitmaps between them (one drive had issues, and suddenly both copies of the file had issues). Add to that the somewhat scary notion that it was anyone's guess which mismatch would become the canonical version. That path seemed a certain way to ensure something got corrupted.

    I'm not currently able to find the exact article but someone mentioned that one way to test to see if it's the free space of the RAID is to do a dd if=/dev/zero of=foo bs=8K and just let it fill up the disk. The reasoning is that the free space will be reclaimed and will be set to a known quantity.

    Note: If you decide to do this make sure that you do this in single-user mode (shutdown now) rather than with a running system. Filling up a filesystem while things are running can make your machine very cranky.

    So I ran dd if=/dev/zero of=foo bs=8K as root and let it fill up the remaining space on the disk. I then ran sync;sync;sync to make sure everything was synchronized before removing the file (and re-running the sync;sync;sync command again.

    I booted the machine into multi-user mode and re-ran the scrubbing check. I kept an eye on the progress and the mismatch_cnt variable.

    When it kept at a steady 0 count I breathed a sigh of relief.

    Moral of the story: The free space on RAID1 can get out of sync (especially if there's a power outage or if you have memory-mapped files like swap files). You can do a "repair" on it, but you might run into corruption if the mismatches are pointing to real data. You may want to instead create a known-good file in the free-space of the drive and see if that clears it out.

    Hope this helps someone else who runs into this. If I re-run into the original article that mentioned this nugget I'll update with a link.

    James Dearing 🐲 , Charles ☕ Stanhope , Claes Wallin (韋嘉誠) , EVAnaRkISTO like this.

    Claes Wallin (韋嘉誠) , EVAnaRkISTO shared this.

    The generic lesson from this: DON'T PANIC. A less careful response to your observation might have caused more trouble where there was originally none.

    Claes Wallin (韋嘉誠) at 2017-01-03T23:11:50Z

    James Dearing 🐲 , Craig Maloney , EVAnaRkISTO , B. Ross Ashley like this.

  • Open Metalcast Episode #145: Quietly entering 2017

    2017-01-03T04:00:05Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/EXvKphbmV8M/)

    First off, congratulations on making it to 2017. 🙂

    We decided for this episode to just shut up and announce the song titles at the end of the show. That way we can let the music speak for itself. So you’ll hear some great music from Wasted Heroes, Digger, Muldjord, Stellarvore, Zombie Destrüktion, Nimrud, Black Autumn, and Pressor. Definitely check this out and kick off 2017 with some of the best Creative Commons metal the net has to offer.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or [FUNNY]. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #145 (MP3)

    Open Metalcast #145 (OGG)

    mray shared this.

  • [Blog] War of Ashes: Fate of Agaptus

    2016-12-29T18:00:10Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/i4L__gLlBcQ/)

    War of Ashes: Fate of Agaptus cover

    • Title: "War of Ashes: Fate of Agaptus"
    • Game Creators: Sophie Lagacé, Karen Twelves, Mike Olson, Edmund Metheny, and Sean Nittner
    • Publisher: Evil Hat Productions
    • System: Fate Accelerated

    It's taken me way too long to write up a review of War of Ashes: Fate of Agaptus. I've wanted to write the perfect review, detailing just how much I love this game. I wanted to show just how much thought and world-building this book has in it, and how the different factions / characters in this book blend together to make an interesting, "lived-in" world.

    I may still write that review at some point: poring over each and every page, detailing what I found interesting.

    But I'll sum it up as best I can:

    "This is the book I wish I'd wrote."

    Not that I feel the authors did a disservice to the material that only I can fix; I mean that I wish that games that I wrote even approached how wonderful this book is.

    The source material for this book is the miniatures game "War of Ashes" by Zombiesmith games. Generally speaking miniatures games don't put a whole lot of depth into their characters. Sure they may have some backstories and motivations, but the objects of those games is to annihilate the opposing forces.

    What "War of Ashes: Fate of Agaptus" does that is so brilliant is it takes what is ostensibly a hack-and-slash game and transforms it into a living world. And the world they present is a fascinating world.

    Each "race" believes different things about their pantheon of gods. The Elvorix believe in many gods, the Vidaar believe in one god, and the Jaarl ignore their gods. (The Kuld believe in a diffuse, impersonal universal force). While on the surface that feels a bit trite, the interactions between the gods and the races is what really shines in this book. There are certain gods for which the Elvorix do not want to draw attetion. Agaptus, the God of Sky and Stars, is a bit heavy-handed whenever he arrives, so the priests do things like burn smelly incensei, and make the temples and themselves unattractive to keep the god away. The Vidaar have one god: Akka -Maas, which the Elvorix claim is another name for Agaptus and which the Vidaar vehemently deny. It's writing like this that breathes life into the world and makes for interesting interactions between characters.

    Apart from religion each society has their own ways of thinking and behaving. While they share some similarities there is enough differences between them to make for interesting interactions for characters. The world feels lived in, with reasons for each of the factions to live, work, and behave the way they do. And all throughout the book there are seeds and ideas that give direction for what sorts of adventures the characters could have.

    The book is written in the perspective of an in-world historian, along with conversations between her and other in-world participants, gives a unique flavor to each of the races and how they interact and interpret the events in the world.

    I won't go too in depth about the system itself. Suffice to say it's a stand-alone version of Fate Accelerated that I am looking at carefully for my own designs. :)

    And the artwork. I really love the artwork and the style of this book.

    In short I think "War of Ashes: Fate of Agaptus" is an excellent book, and I hold it as a standard for what I want to achieve with my own writing and design. It builds a world, shows how to best participate in it, and creates interesting obstacles for the characters to interact. I would see small skirmishes in this world, and epic campaigns. It has depth and mythology that make sense, and draws out a sense of humor that fits the characters and setting.

    Highly recommended.

    How do you feel the minis battling mechanics hold up? I followed Mike Olson's blog while he was working on that part. Tactical battles are kind of challenging in Fate sometime so I was curious how it would work in actual gameplay.

    Christopher Allan Webber at 2016-12-29T18:12:55Z

    The rules for combat add a little bit for minis but they don't distract much from the overall "Fateness" of the game. I haven't actually done much with them, and I'm pretty sure if you wanted you could completely ignore them if you wanted.

    Craig Maloney at 2016-12-29T21:20:06Z

    Christopher Allan Webber likes this.

  • [Blog] Stupid JavaScript Tricks

    2016-12-29T02:00:09Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/oGYw3Xl6x7I/)

    > bar = ['width', 'height']
    [ 'width', 'height' ]
    > bar
    [ 'width', 'height' ]  // Nothing up my sleeve
    > bar.indexOf['length']
    1  // Presto!
    

    In case you haven't guessed what's up here: JavaScript automatically surfaces a value called 'length' in all arrays. So you can get the length of bar by typing bar.length and bar['length'].

  • [Blog] Habit tracking: Shaving

    2016-12-26T18:00:34Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/MOM7-smTGD8/)

    I've been quietly implementing a new habit for myself. As part of the Habit Guide from Zen Habits I've decided to start with a ridiculously small habit in order to get myself back into the habit of making good habits. (Play along at home with the "Craig says 'habit"" game: take a drink whenever this post says habit.)

    That habit? Shaving.

    Now you may think "that habit has a natural trigger, doesn't it? If you look like a mountain-man, then you need to shave, right?" Yes, but I decided on this habit for the following reasons:

    • I grow facial hair like a pre-pubescent boy (it takes me a week to get to "mostly stubble")
    • It has an easy trigger (I see the razor, and three-minutes-later I have a clean face).
    • It has a positive effect (I have a shaved face).

    Is it a major, life-changing habit? Hardly. Most folks won't even notice the effects. But the benefits for me are making a habit that I can see results. I'm already 35% through in tracking the habit via Loop Tracker and I'm seeing progress. That's the real reason for doing this.

    I'll add different habits in the near future. But for now I'm going to enjoy a clean-shaven (or some facsimile thereof) and see where this leads.

    (And yes, it hasn't escaped me that someone could call this yak shaving. I'm OK with shaving this yak. :)

  • [Blog] Twas a few nights before Christmas...

    2016-12-24T15:21:19Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/7SdPW3fTm2w/)

    Pixel looking around the corner at the Charlie Brown Christmas Tree

    May your holidays be carefully guarded by the Christmas Kitten.

  • Open Metalcast Episode #144: Closing out 2016

    2016-12-23T19:00:30Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/xGU7Qxkj_vE/)

    It doesn’t feel like the end of 2016 is upon us. It also doesn’t feel like this should be the last regular episode of 2016. Yet, here we are.. But we’re going out with style, with brand new music from Dejadeath, Agónica, and Minenwerfer. We also have tracks from Ishmael, Silent Path, Last Dive, Dehumanizing Process, and an ear-worm from Martes Mártir. And while we bid a farewell to 2016 we’ll be back first-thing in the new year with more Creative Commons Metal Music to blast your ear-holes into the new year.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or leave a present for them. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #144 (MP3)

    Open Metalcast #144 (OGG)

  • [Blog] Happy Holidays and Merry Christmas

    2016-12-23T19:00:29Z via Spigot To: Public

  • Open Metalcast Episode #143: Cat on the Desk

    2016-12-06T22:00:14Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/TLufJVxD6ao/)

    This episode brought to you despite the efforts of Pixel to prevent it from happening.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #143 (MP3)

    Open Metalcast #143 (OGG)

  • [Blog] Soundbreaking

    2016-11-29T05:00:07Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/ZtL6FkivYyI/)

    I've been binge-watching the documentary series "Soundbreaking" (which leaves PBS streaming tonight. :( ) and overall I've enjoyed it. It's an ambitious series and I've learned a few things from it:

    • I wasn't aware of the TONTO synthesizer and Tonto's Expanding Head Band, which formed the synth periods of Stevie Wonder and The Isley Brothers.

    • That DEVO was a reaction to the music of the 1970s that lost a lot of the protest vibe of the 1960s. I thought it was more of a reaction to the sterilization of music and culture.

    • That Donna Summers' song "I Feel Love" was done by Giorgio Moroder, and who Giorgio Moroder was and his role in creating EDM.

    • How Tom Petty's "Free Falling" came about.

    There's a few others, but those really stuck out to me.

    Unfortunately with any survey of modern music there's bound to be a number of blind spots. And while this tries to cover a lot of territory there are a few places where I feel they missed out:

    • When they talk about synthesizers they give a passing nod to Wendy Carlos, and completely ignore Tangerine Dream and the Krautrock / Berlin School movement. Kraftwerk gets a nod in the section about beat.

    • The episode on sampling is dominated by rap and the genesis of hip-hop. To hear them tell it sampling was strictly the domain of rap and hip-hop and was later adopted by pop musicians in the late 2000s. The Beastie Boys get a lot of play in this arena because they (rightly) claim "Paul's Boutique" couldn't be made today without a crap-ton of sample clearance. But industrial bands are ignored.

    • The section on producers completely ignores Motown. Motown gets mentioned in the section on beat because of the amazing Funk Brothers rhythm section, but outside of Smokey Robinson and Diana Ross the Motown sound is conspicuously absent.

    • The hardest music they touch on is The Who. Prog Rock is completely ignored. Sections where they could easily talk about the virtuosity of artists in the acoustic realm are left with The Black Keys and Bruno Mars as the examples of virtuosity. Rush gets one picture. No mention is made of any metal bands that are putting out mind-blowing melding of jazz, funk, rock, and metal. Punk gets passing mentions, but when you have Rick Rubin on the show and just mention Slayer in passing? That's a missed opportunity.

    • To hear them talk you'd think EDM was where everything is happening in music. And while I won't argue there's interesting things happening there it gets a disproportionate amount of weight in this series.

    Sure they're quibbles, and "my favorite bands didn't get a mention" complaints. But the overall package is amazing. The shear amount of music in this series is amazing and had to have been a huge undertaking to compile. What's there is a compelling story about the origins of recorded music and a lot of interesting discussion about what goes into making it.

    Highly recommended if you get the chance to watch it.

    Charles ☕ Stanhope , bthall like this.

    >> Craig Maloney:

    “[...] I wasn't aware of the TONTO synthesizer and Tonto's Expanding Head Band [...]”

    Nice names xDD

    JanKusanagi at 2016-11-29T09:23:57Z

    It was the 1970s, so anything was possible. :)
    It was also an acronym (or "Backronym") for "The Original New Timbral Orchestra,"

    Craig Maloney at 2016-11-29T13:05:35Z

  • Open Metalcast Episode #142: Thankful

    2016-11-22T03:00:21Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/sccAnmEHIas/)

    We’re coming up on the Thanksgiving holiday here in the USA and I wanted to take a moment to thank you for listening to this humble podcast of Creative Commons Metal Music. It’s a privilege to bring you this episode every couple of weeks and though some episodes take a little more to put together than others, seeing folks download the episode warms my heart. We have a great episode lined up with new music from the upcoming Sonus Mortis album, as well as music from Æons Collide, Effigy, Monster Coyote, Neila, PhaZer, Shady Bliss and Seal of Beleth. It’s an episode you won’t want to miss.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or thank them for making their music Creative Commons Licensed. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #142 (MP3)

    Open Metalcast #142 (OGG)

  • [Blog] Left behind

    2016-11-10T17:00:12Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/3zEpo4sA1YM/)

    Feeling a little left behind at the moment. Checking job sites will do that for you.

    Most of the jobs that I'm seeing have moved beyond scripting for the day-to-day work and use it as administrative glue. So Python / Perl are seen as the tools for making sure the backed works, not for doing the actual work. Golang is the new hotness for the back-end processing and heavy-lifting. Which is fine and good, save for I haven't had a whole lot of opportunity to play with AWS on any scale (most of my administrative positions have been with companies that preferred to keep mot of their systems in-house). Add to that my perpetual non-use of Javascript (which has taken over the front-end of the web) and I'm starting to think I made some bad calls in my developer life.

    It feels like anything that isn't on the resume as "professional experience" doesn't count.

    Is there a way to start with AWS that doesn't cost a lot of money and can get me up to speed fast?

    At the coffeeshop that we meet at for Coffee House Coders I remember a conversation where I told another developer what I did (Python and Linux). He commented that was "Old School Development". At the time I was offended, but now I'm thinking he was right.

    I hear ya. Checking job sites can definitely be demoralizing. A lot of development is very faddish and moves from tech stack to tech stack without actually improving the state of the art very much (if at all). It's just a bunch of different details about how to do the same thing you were already doing. I think one factor is that the demand for developers has been ever increasing, which means the industry remains mostly young (that's the only way to fill the demand). Wave after wave of young, inexperienced people making tech choices... I'm not criticizing, just observing.

    Anyway, it sounds like you have some tremendous skills. Demand for Python developers remains strong (although I know a lot depends on geography), and understanding operating systems well enough to administer machines should be knowledge that is transferable. After all, whether containers or virtual machines, it's still the same tech under the hood. Your skills and knowledge are still useful.

    I wish I had some advice on AWS. It's something I keep intending to play with, but I never find time to do. For one thing, I hear bad stories about billing snafus or virtual machines that Amazon keeps alive but are nowhere to be seen in dashboards. Maybe it's better these days, but I prefer to play with solutions where I know that I can't exceed my budget (just in case I screw something up). I do not need crazy surprise bills.

    Charles ☕ Stanhope at 2016-11-10T20:33:43Z

  • Open Metalcast Episode #141: V.O.T.E.

    2016-11-07T22:47:37Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/bgicNffNulM/)

    If you’re even remotely aware of a country called the United States of America you’ll no-doubt know that November 8th is our election day. We’ve had a barrage of campaign calls from celebrities who likely would never call me otherwise (Seriously, lose my phone number). We’ve also had non-stop election coverage in every medium known to man (I think they’re even using the Rosetta stone to craft messages for any voters who might only read hieroglyphs). Whatever your political stripe, denomination, or leaning: please vote if you can.

    Regardless, here’s 49 minutes of the best Creative Commons Licensed Music as a (temporary) respite from the United States of America’s political machinations.

    V.O.T.E.: Very Over This Election.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or vote them for office. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #141 (MP3)

    Open Metalcast #141 (OGG)

  • [Blog] Code Katas

    2016-10-29T17:00:10Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/kcRE62rqbEs/)

    I discovered a site called Code Wars which I'm going to use to help me learn JavaScript and tighten up my programming in general. So I signed up and played around with one of the Katas on the site.

    One of the things I noticed on the site was that you could use Vim or Emacs keys. Cool! So I dutifully started typing into their editor.

    A keypress that is handy and almost automatic to me in Vim is CTRL-W. This keypress allows you to quickly delete the previous word. Unfortunately modern window managers and browsers have usurped that keypress to close out the browser window.

    Yeah, so it closed out my browser. Don't do that.

    (warning: Solution ahead. Stop reading if you want to play with this on your own.)

    The kata that I was working on was to find the two lowest sums of an array (assuming the array has positive integers, etc.). In Python it's a pretty simple matter: sort the array and take the two elements off the front of the newly sorted array. Simple.

    But they added this caveat: Don't change the original array.

    As anyone who has ever done a sort on an array in Python knows, sort is destructive:

    >>> foo = [3,5,2,7,8,0,6,2]
    >>> foo.sort()
    >>> foo
    [0, 2, 2, 3, 5, 6, 7, 8]
    >>>
    

    (But there's something that I missed and learned. Hint: there's a difference between .sort() and sorted())

    It felt like they were expecting me to not sort the array. Hm, that makes things a little more tricky and less Pythonic.

    So I got to thinking, put on my BASIC programming language hat and wrote this masterpiece:

    def sum_two_smallest_numbers(numbers):
        # Take the first number as the lowest number
        lowest = numbers[0]
        # Set the position of the lowest number
        lowest_position = 0
    
        for i in range(0, len(numbers)):
            if numbers[i] < lowest:
                lowest = numbers[i]
                lowest_position = i
    
        second_lowest_position = 0
        # Check for the case where the lowest position is the first number of the
        # array
        if second_lowest_position == lowest_position:
            second_lowest_position = len(numbers) - 1
    
        second_lowest = numbers[second_lowest_position]
    
        for i in range(0, len(numbers)):
            if i != lowest_position and numbers[i] < second_lowest:
                second_lowest = numbers[i]
                second_lowest_position = i
    
        return lowest + second_lowest
    
    
    def main():
        print sum_two_smallest_numbers([5, 8, 12, 18, 22])
    
    if __name__ == "__main__":
        main()
    

    This code has problems: It's not Pythonic (it's essentially BASIC), it doesn't take advantage of any of the routines that Python gives you, it does two passes of the array.

    It's not a great solution, but it works.

    What's the first solution that I see?

    def sum_two_smallest_numbers(numbers):
        sum(sorted(numbers)[:2])
    

    Much more Pythonic, but does the sort affect the original array?

    Turns out there's a difference between .sort() and sorted(). numbers.sort() replaces the original array (which is not what we want), but sorted(numbers) returns the sorted array. Learned something new there.

    But is my solution a better solution? At first glance it isn't (lots more code to do something that a simple one-liner of Python handles with ease). Python's sorted() uses TimSort which is O(n) at best and O(n log n) at the average and worst cases. My code takes two passes at the array which is O(n+n) which reduces down to O(n) (if I'm remembering that right).

    So my code (inelegant as it is) might be a better solution for larger sets of unordered data. Huh.

    What's the lesson here? I'm not entirely sure. Katas are interesting problems and there's a wide variety of solutions on the site for CodeWars. To he honest I thought I had failed when I saw the short, Pythonic solution. But that's the real beauty of learning to code: sometimes the elegant solution isn't the best solution, and sometimes the ham-fisted solution might not be so bad after all.

    But the most important lesson of all is that even programmers who think they know what they're doing need to practice and keep learning.

    Douglas Perkins , bthall , Charles ☕ Stanhope like this.

  • Open Metalcast Special Episode: Club Metal #17

    2016-10-26T12:00:05Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/6wyW0Sh2S-8/)

    All Systems Go. Punch It!

    From the game “Eclipse Phase” (c) Posthuman Studios, LLC. used under the CC-BY-NC-SA license.

    From the game “Eclipse Phase” (c) Posthuman Studios, LLC. used under the CC-BY-NC-SA license.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or reshare this episode with your friends. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast Special Episode: Club Metal #17 (MP3)

    Open Metalcast Special Episode: Club Metal #17 (OGG)

    Douglas Perkins , Charles ☕ Stanhope like this.