Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.
Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

2017/01/20

Ding! Ding! The Process is Dead!

Starts with a thing I saw on David Walsh's Blog:
I've been working with beefy virtual machines, docker containers, and build processes lately. Believe it or not, working on projects aimed at making Mozilla developers more productive can mean executing code that can take anywhere from a minute to an hour, which in itself can hit how productive I can be. For the longer tasks, I often get away from my desk, make a cup of coffee, and check in to see how the rest of the Walsh clan is doing.

When I walk away, however, it would be nice to know when the task is done, so I can jet back to my desk and get back to work. My awesome Mozilla colleague Byron "glob" Jones recently showed me his script for task completion notification and I forced him to put it up on GitHub so you all can get it too; it's called ding!
OK, that sounds cool. So I go to Github and I see one line that gives me pause.

Requires ding.mp3 and error.mp3 in same directory as script. OSX only.

I can handle the image thing, but I don't own or run an OSX computer. (I have one somewhere, but it's ancient and has no functioning battery. I don't use it.)

"So," I think, "how could I do this on my Linux box? What's the shortest path toward functionality on this concept?"

Well, recently, I have been playing with Text-to-Speech. Actually, I have been a long-time user of TTS, using festival then espeak to tell me the current time and temperature on the hour and half-hour. I switched to Amazon's Polly in December, deciding that the service sounded much better than the on-my-computer choices. (Hear for yourself.) So, I knew how to handle the audio aspects.

The other part required me to get much more familiar with Perl's system function than I had been previously.


I'm not yet 100% happy with this code, but I'm reasonably okay with it so far. Certainly the concept has been proven. (I use the audio files from globau's ding.) With enough interest, I will switch it from being a GitHub gist to being a repo.

2012/01/06

My Song of Love for Unix


My first computer was a DOS-running TRS-80 in the 1980s. In 1988, when I was heading off to college, my parents got me a Tandy PC with an 8088 processor and a green monochrome monitor that took a composite video cable. I still have it but I don't use it. The only modification I did on it was to add a modem (2400 baud, I think, but maybe 1200 baud) and I mostly used it to connect to BBSes and mostly to the campus' big machine, MUSIC (Multi-User System for Interactive Computing). I know I touched some GNU tools for DOS at the time, and I heard about UNIX systems and felt an awe about them that I don't think it's possible to express these days, when you can download Linux for free and all of Apple's computers run BSD, but I never got close to a real UNIX system back then.

In fact, the first I really touched a Unix system was when I went to school again, to get my Computer Science degree. I learned C as a subset of C++ on SunOS systems, and I have to say that I was somewhat underwhelmed with Unix. X looked positively crufty compared to Windows 95, much less MacOS, even in 1996. What I didn't get, what it took me a while to get, is that the windows don't really matter. Once you get into the Unix mindset, CDE is KDE is Gnome is Windows is MacOS. The way windowing doesn't matter, and what does matter is the command line.

And why is that? Windows has CMD and now Powershell, and Macs could be coerced to give you a prompt even back then, even if few people used them. What makes Unix systems different? In a word, pipes.

Pipes?

So, you have an MP3 of a song, somewhere in your music collection. For example, "Never Ending Love" by Delaney and Bonnie. You don't know where it is and you want to copy it to your phone. So, first you have to go through your music collection.

find Music/.

That gives you a big list of all your music. tl;dr

find Music/. | grep -i delaney

OK, so, that gives you the whole album, plus "Delaney's Dream" by Seth Austin, too.

find Music/. | grep -i delaney | grep -i "never ending"

And, if your music collection is mine, that cuts it down to two. And a great many other problems can be broken down in similar ways.

It gets deeper, but in essence, the command line, the basic way you connect with a machine, is a programming language in and of itself. You write small things that filter the information, learn the flags to control the output of the tools, and only display it when it is down to what you need to see. To the extent it is possible to script a windowing system, it is a cast-iron PITA. When you want to script things in the command line, it is baked in at a fundamental level.

So, if someone suggests you learn Unix, yeah, it's great to run Ubuntu and get the Unity shell (the current term for window manager, I guess), but you'll either be using things that are ported to all the platforms (Chrome, Firefox, Komodo Edit, in my case), things that are equivalent to things on other platforms (Nautilus vs Windows Explorer, for example) or things that are hoped to be equivalent to things on other platforms but just aren't (GIMP vs Photoshop). This makes Mac vs PC vs Linux largely a matter of taste, but the command line, or shell, is the thing that makes Unix different, that makes it powerful, which makes it powerful and user-friendly to those who it excepts as users.

Yes, I have just largely restated Neal Stephenson's "In the Beginning was the Command Line". I still enjoyed the trip, and hope you did too.

2009/11/19

Windows Essentials?

OK, I munged it up. I couldn't create new accounts or add new MSI packages to the netbook. It had to go. It had to go. The problem I had was that my install media was on CDROM, but the netbook, being a netbook, has no optical drive from which to read a CDROM. But college campuses collect computer geeks and computer gear, so a quick Hey Rube got me a loaner USB optical drive. (What's crazy is that this drive is almost exactly the size of the netbook. I'll put up a picture tomorrow.)

So, I have the initial install. That was fast enough. There's the drivers to make the thing usable. I shoved a chunk of 'em onto my thumb drive, but I am sure I missed more than a few, including the work printer. After that, go to windowsupdate and get the thing up to the newest. And honestly, I'm still downloading and installing Service Pack 3 here. But that's just minimal function. We're not talking apps yet.

First place I went to was Ninite. There's an awful lot installers you can get at once. I picked up a bunch of browsers — I rock Firefox because Delicious has my bookmarks, but I have Chrome and Safari running, too — plus Hulu and VLC, Microsoft Security Essentials for virus protection and such, .Net and Dropbox and CCleaner and Notepad++ and PuTTY. Not a bad bunch of stuff, but not complete.

Dave Winer calls Dropbox the coolest software of the decade. I'm not quite there yet, but I'm close. It is pretty neat.

I live in a very networked world, and I have 15GB of SSD total on this thing, so I'd rather run Google Apps for what few Office Suite things I need and keep the space. I mean, if I'm somewhere not home and not work, it's very unlikely that I need an office suite. So, I went to get the Google Pack.

All things told, I probably shouldn't have put on Google Earth. Probably too big with little enough use. We'll see.

There's also a whole bunch of tweaks for XP that only come from the source. Power Toys. I first went for TweakUI, but the ClearType Tweaker and Alt-Tab replacement, are really near-essential add-ons. And Virtual Desktop Manager is SO nice.

But that doesn't get into the core issues. I have IE6. It is inexcuable to not have IE8. I need PowerShell. It isn't a Gnome terminal with a bash shell, but it's better than Command Prompt.

He's a few required SourceForge bits. Synergy allows you to share one keyboard and mouse across many computers, which is great when I'm at work. I can type on a netbook keyboard but I probably couldn't work on one, program on one. And there's XMing, an X server for Windows, which connects to the crucial PuTTY and allows you to have your big heavy windowing applications run on the big server and show up on the netbook as just the pictures.

One thing I'm pondering but not decided on is Growl for Windows. It's like my beloved notify-osd with a networking protocol bolted onto it, it seems.

Which leads me to these few questions: I need a Perl, but do I need Strawberry or Activestate? And is Notebook++ good enough for my programming on Windows needs, or should I get Komodo Edit? I've gone Komodo for 80% of my coding work.

And the big one. What did I forget? What Windows program have I omitted that's essential and just plain cool?

2009/10/19

Modern One-Liner Perl

I have never been much of a fan of Perl one-liners. Take every slur about Perl that exists in the popular imagination, and that's the reality for one-liners.

perl -e 'print 51 * 51 , "\n"'
But now, by going -E instead of -e, you bring in Perl 5.10. This means you get say, which is by far my fave Perl 5.10 addition.

perl -E 'say 51 * 51'
I'm already starting to do one-liners more, now that I have say. Using realias is also helpful with this.

Credit where due.