The best kittens, technology, and video games blog in the world.

Monday, May 06, 2013

Small Unix utilities written in Ruby - part 3

Naughty cat by kevin dooley from flickr (CC-BY)

Here's the third instalment in my ongoing series (Part 1. Part 2).

All utilities mentioned are available on github.

flickr_find

Find Creative Commons licenced photos on flickr.

Usage example: flickr_find cute kittens.

flickr_get

Download best quality version of a photo from flickr and annotate it with proper file name.

Usage example:

    flickr_get http://www.flickr.com/photos/pagedooley/386303100/

which will be saved as ~/Downloads/naughty_cat_by_kevin_dooley_from_flickr_cc-by.jpg

I've been using flickr_find and flickr_get for years on this blog.

It requires objectiveflickr gem.

osx_suspend

OSX surprisingly lacks an easy way to suspend your current session. This utility does just that.

rand_passwd

Have you ever needed to quickly generate a new password? This utility generates easy to type (lower case letters only) 12 character password, with 56.4 bits of entropy, so you never need to reuse the same password across multiple sites.

webman

The most annoying thing about man pages (and even more about this silly GNU info idea) is that they display in terminal, where they're really painful to search. What man really needs is in-browser display.

Here comen webman. It is fuly intended to be used with alias man=webman in your ~/.bashrc. It finds proper man page, groffs it to HTML, caches that in ~/.man_cache since groff is slow as hell for some reason, and opens your favourite browser.

The code looks fairly overengineered, since the actual script I use also checks EC2 (so I can man page for both OSX and Linux programs with the same command), and this stripped down and somewhat refactored version is still a bit on the complex side.

If it fails to find man page for any reason, it opens relevant Google search instead.

If you need to open it in a terminal simply pass -T flag.

It wasn't tested outside OSX environment yet, so pull requests welcome. Further cleanup pull requests also very much welcome.

4 comments:

Anonymous said...

Hi Tomasz.

Could you be so kind to addrees me to a debugger to be run together with M2TW Kingdoms? I am starting to write some battle script, but I don't know how to test whether those scripts are launched or not. Any suggestion will be much appreciated

MG

taw said...

Anonymous: Wait, what debugger for M2TW Kingdoms?

I don't think I ever did anything for Kingdoms, I vaguely plan to switch Concentrated Vanilla from M2TW engine to Kingdomn engine, but that was never released.

Anonymous said...

Sorry, maybe I didn't explain well what I'm looking for. Stated that I'm not looking for anything related to crack/patch or whatever related to infringements of the rules, I just would like to know if there is a tool or a way to let me see whether a script of mine is fired during the battle. Or, more precisely, whether the game engine labels the units the way I tell it to do. Many commands could be used in battle script only if attached to unit labels and if I fail to give the right label all the rest won't work. So, my basic idea was to give a generic label to each AI unit present on the battlefield (i.e. unit1, unit2 etc), to group them into a battle group and, once grouped, to re-label each of them by doing further tests about their class and category. In this case, knowing the basic formations, I could guess almost for sure where heavy cavalry (if present) will be placed as well as all the other type of units. Enough to write some very basic first moves and then to give back to AI control everything till the end of the battle.
MG

taw said...

Anonymous: I don't know if that's possible, I never modded battle scripts. You should ask on twcenter (and have some patience).