Most Read This Week
From the Blogosphere
What Could You Do with Your Code in 20 Lines or Less?
20 Lines or Less #27
By: Colin Walker
Aug. 6, 2009 07:30 PM
What could you do with your code in 20 Lines or Less? That's the question I ask (almost) every week for the devcentral community, and every week I go looking to find cool new examples that show just how flexible and powerful iRules can be without getting in over your head.
Here are a few more cool iRules from the forums. This week I’ve included one of the simplest, shortest iRules to ever make the 20LoL. It just struck me as something quite useful that I’m willing to bet several people will look at and say “oh, that’s handy” despite the fact that it’s not complex or long.
Keep the code coming.
Multiple Matches with Switch
Joe answered a plea for help from the forums that showed how to modify an existing iRule that mad use of switch dropping through to multiple match cases. This is a great way to streamline your rule and I wanted to post this here as it’s a good example of what it looks like.
Mod_Rewrite to iRules conversion
Hoolio strikes again with this awesome conversion of some mode rewrite rules into an iRule format. This is extremely handy for centralizing and streamlining these types of rewrites. He makes it look so easy, doesn’t he?
Insert Pool Info
In likely the shortest, simplest iRule to date in the 20 Lines or Less, hoolio shows how to insert information about the chosen pool into a header on a server response. This one struck me as useful enough to post. I usually go for things that are a little more flashy but there’s something to be said for simplicity if it gets the job done.
The things that you can do in less than 21 lines of iRules code continue to amaze and interest me, so I’ll be back next week with three more examples of just how much you can accomplish in those scant few lines of code.
Subscribe to the World's Most Powerful Newsletters
Today's Top Reads