/dev/audio

I’ve spent the last half hour playing around with /dev/audio, the audio device in Linux. Because Linux is based on Unix, it treats some pretty complex things as normal files. The audio device is an example. You can write to it like any other file, but instead of storing the information on disk, it interprets each byte you send it as an amplitude (from 0x00 to 0xff, I guess).

Fun read, I can’t wait to play with /dev/audio. I wonder what a svg sounds like? Or a text file describing a chess game…

(Source: somethingemporium.com)

Some random *nix apps I’ve run across recently…

It’s been a while since I posted, so I thought I’d throw some useful programs I’ve been using a lot recently out there…

units

Found this one in the famous “500 mile email” story. (Which if you haven’t read, you really should.) This app very simply and shortly converts measurements, quickly and easily. Of course wolframalpha.com is a bit more full featured, but it’s still quite nice.

sort

An oldie but a goodie, this app will sort it’s input alphabetically, or anyway you pass it in quickly and simply. Chain it with cat, (cat file | sort > output), or better yet use it as part of your favorite editor. In vim, block select a region using V, then type :!sort to run sort on your selection. Very handy for organizing rules and whatnot.

pbcopy/pbpaste

These are actually mac specific, but you can find a linux equivalent here. Simply put, they allow you to pipe in or out your system clipboard to standard in standard out. Very very handy.

Bonus: sympy

I’m a big fan of python, especially for science and math work, and this new library might be just the ticket to take me to the next level. Check it out.

Pry, the new Ruby Debugger?

Today’s tip is specifically for ruby programmers, but I would extrapolate it out to every language. The generalized tip is “learn how to use your terminal based debugger.” GDB is your friend. The specialized tip is a new little thing called Pry, for ruby.

Pry is a bit of a conundrum to explain, so my best shot is that it’s a sort of hybrid between a glorified puts statement, and an interactive breakpoint. You require the library, and at the point you want to examine your code you place the line

binding.pry

When you run the code, (either in rails or as a standalone app) when you reach that point, the code will stop, and the pry debugger will start. It has a very streamlined, *nix like interface for cd/ls-ing in and out of objects, scopes, and methods and displaying the current state of all of them. You can also change the values of variables, add code and methods on the fly, but I’m not too familiar with those pieces of functionality yet.

Debugging seems to be a rather glaring weakpoint in the ruby world as far as I can see, and maybe Pry is a creative step in the right direction. Check it out.

Stop writing rambling commit messages.

http://stopwritingramblingcommitmessages.com

Go there. Have you read that? Already back? Good. Now stop doing it. 

The Hacker Mindset

 

1. The world is full of fascinating problems waiting to be solved.
2. No problem should ever have to be solved twice.
3. Boredom and drudgery are evil.
4. Freedom is good.
5. Attitude is no substitute for competence.

This is pretty inspiring. I constantly am saddened by how little I create and add to the world to contrast with how much I consume. I keep having to promise myself that the next time I say “Man, I wish there was [insert solution here]!” to stop, and start making a solution instead of moving on. I at least write the idea down… I have quite a little list of things to make. Time to start solving problems.

[original list source catb.org]

New Favorite Vim Tip

This is blowing my mind: C-x C-l. It autocompletes the whole line.

I got this awesome tip from this excellent list, check it out!

lesser known CLI apps I adore:

  1. Pianobar

    I can’t stress enough how awesome this little program is. It not allows you to play music inside your command line, (tabs or tmux for the win!) but takes out ads, and serves some other nice features, like “Ban this song for a month.” Can’t recommend highly enough. Mac users, you can just type “brew install pianobar”. Other *nixers might need to do some more magic, but it might be in your package manager of choice. Which leads me to my second pick…

  2. Brew

    This one is for the mac users only. If you are a mac user who has used other *nixes, this is apt-get or yum for mac, done right. If you are a long time mac user, this is MacPorts only wonderful to use. Get it now.

  3. Ack

    It really surprises me how few programmers use grep, and how fewer have heard of the awesome ack spin-off/rethinking of the aged linux too. Ack is search for programmers, allowing you to search your source trees with ease and speed. It’s fully configurable, but straight out of the box will ignore .svn and .git files, tmp files, and all the other things that normally get in your way when you are searching. I use it fairly constantly to find // TODO comments that I leave in my code, and to generate a todo list from them. Which gives me a rather good idea to do that automatically when I cd into the folder, using awk. * rubs hands together *

If you have any other smaller applications you use constantly, please feel free to mention them in the comments. Have a good Labor Day!

Why you should learn a little awk…

The latest tool in my *nix arsenal is awk. I’ve never really payed attention to this little tool, but once I discovered how awesome it was, how could I not love a little gizmo that automagically parses input by whitespace and has a simple scripting language you can use on it? I got started learning about it using this fantastic tutorial here. It’s super useful for parsing input on CSV inputs before they hit your scripts… I recently used it generate a IIRF URL rewrite file for an IIS server (I know, I know…) from an excel document supplied by a manager. Do check it out, and if you find any neat uses for it, post responses in the comments.

Wow! The help menu in OSX Lion’s new Terminal application searches man pages. That’s pretty sweet!

Bash Protip: ^corrrect^correct with ^^ notation.

Ever mess up long apt-get command with a tiny typo at the beginning? Solve your keyboard fumbling woes with this simple trick. If you run ^foo^bar it will replace the first instance of foo with bar in your last command, and re run it.