The Wayback Machine - https://web.archive.org/web/20150919102135/http://php.sys-con.com/node/1166979

Click here to close now.





















Welcome!

PHP Authors: Carmen Gonzalez, Hovhannes Avoyan, Lori MacVittie, Trevor Parsons, Andreas Grabner

Related Topics: IoT User Interface, Microsoft Cloud, PHP, Ruby-On-Rails, Perl, Python

IoT User Interface: Blog Feed Post

What Could You Do With Your Code in 20 Lines or Less?

20 Lines or Less #30

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.

Well we made it to 30 editions of the 20LoL.  Soon we’ll break 100 iRule examples that are under 21 lines of code each.  Pretty neat stuff, if you ask me.  This week is the hoolio show, it seems.  The guy is just a monster in the forums, what can I say?  I sure am glad he’s on our side.  I’ve got three examples that I randomly pulled from the forums because I thought they were cool.  Only later did I realize that he had penned them all.  So big thanks yet again to Aaron and all his hard work to better the community.

Pre-loaded searches based on host name

http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=86016&view=topic

This cool little example is a neat spin on a simple HTTP redirect.  The basic idea is to redirect to a given search site and set the search parameter to be the original host name of the request.  So I could request bobschickenshack.com and be redirected to a search for bobschickenshack on the search page of my choosing.  Very cool idea, and darn easy to implement.

 
when HTTP_REQUEST {

# Rewrite the host header to www.yahoo.com and the
# uri to /search?q=$host where $host is the originally requested hostname
HTTP::header replace "www.yahoo.com"
HTTP::uri "/search?q=[HTTP::host]"
}

 

More fun with nested switch

http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=85807&view=topic

I know we’ve covered switch before, but this is yet another good use of it and I really like the idea of selecting snatpools based on which server the request is going to end up going to.  I trimmed this one down a little but only by removing a few of the possible snatpool options, all logic is the same, even though it’s just an excerpt of the overall solution provided.

 

 when LB_SELECTED { 
switch [LB::server addr] {
222.35.42.126 {
switch [IP::client_addr] {
192.168.3.11 { snatpool snat_crt_test2 }
default { snatpool snat_crt_pool }
}
}
221.218.248.155 {
switch [IP::client_addr] {
192.168.3.11 { snatpool snat_uni_test2 }
default { snatpool snat_uni_pool }
}
}
default { snat automap }
}
}

Updating referrers

http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=85807&view=topic

Hoolio does a good job of not only pointing out the inherent problem with trying to replace referrer headers with hostnames from requests, but giving an option that works as desired even if it’s a little bit different direction than the OP was headed.  This is a good example of in-line string replacement with string map, too, which is an often under used command that’s worth a look.

 

 
when HTTP_REQUEST {

log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::host][HTTP::uri]\
with Referer [HTTP::header Referer]"

if {[HTTP::header exists "MyHeader"]} {
log local0. "[IP::client_addr]:[TCP::client_port]: Updating Referer to\
[string map -nocase {http:// https://} [HTTP::header Referer]"
HTTP::header replace Referer "[string map -nocase {http:// https://} [HTTP::header Referer]"
}
}
when HTTP_REQUEST priority 501 {
log local0. "[IP::client_addr]:[TCP::client_port] (501): Current Referer [HTTP::header Referer]"
}
 

There you have it, 3 more iRules to show off just how much you can do in only 20 lines of code. Next time we’ll break past the 100 examples mark. See ya then.

#Colin

Read the original blog entry...

More Stories By Colin Walker

Coming from a *Nix Software Engineering background, Colin is no stranger to long hours of coding, testing and deployment. His personal experiences such as on-stage performance and the like have helped to foster the evangelist in him. These days he splits his time between coding, technical writing and evangalism. He can be found on the road to just about anywhere to preach the good word about ADCs, Application Aware networking, Network Side Scripting and geekery in general to anyone that will listen.

Colin currently helps manage and maintain DevCentral (http://devcentral.f5.com). He is also a contributor in many ways, from Articles to Videos to numerous forum posts, to iRules coding and whatever else he can get his hands on that might benefit the community and allow it to continue to grow.

@ThingsExpo Stories
SYS-CON Events announced today that Machkey International Company will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Machkey provides advanced connectivity solutions for just about everyone. Businesses or individuals, Machkey is dedicated to provide high-quality and cost-effective products to meet all your needs.
As more intelligent IoT applications shift into gear, they’re merging into the ever-increasing traffic flow of the Internet. It won’t be long before we experience bottlenecks, as IoT traffic peaks during rush hours. Organizations that are unprepared will find themselves by the side of the road unable to cross back into the fast lane. As billions of new devices begin to communicate and exchange data – will your infrastructure be scalable enough to handle this new interconnected world?
The Internet of Things has the potential to disrupt all industries, not just consumer, as businesses leverage the new insights and capabilities enabled by new devices / things, automation, integration and analytics, etc., to transform how they do business. One industry ripe for disruption is higher education. Colleges and universities are being challenged with serving more students and at the same time ensuring successful student outcomes. In his session at @ThingsExpo, Chris Witeck, Principal Technology Strategist at Citrix, will take a closer look at the potential of IoT in providing the ...
Contrary to mainstream media attention, the multiple possibilities of how consumer IoT will transform our everyday lives aren’t the only angle of this headline-gaining trend. There’s a huge opportunity for “industrial IoT” and “Smart Cities” to impact the world in the same capacity – especially during critical situations. For example, a community water dam that needs to release water can leverage embedded critical communications logic to alert the appropriate individuals, on the right device, as soon as they are needed to take action.
WebRTC is about the data channel as much as about video and audio conferencing. However, basically all commercial WebRTC applications have been built with a focus on audio and video. The handling of “data” has been limited to text chat and file download – all other data sharing seems to end with screensharing. What is holding back a more intensive use of peer-to-peer data? In her session at @ThingsExpo, Dr Silvia Pfeiffer, WebRTC Applications Team Lead at National ICT Australia, will look at different existing uses of peer-to-peer data sharing and how it can become useful in a live session to...
Using code to define your infrastructure is a trend that is quickly becoming common practice and a critical part of any successful deployment In his session at 17th Cloud Expo, Christopher Gallo, Developer Advocate at SoftLayer, an IBM Company, will discuss what it means to be powered by SoftLayer, and some really awesome tools to help you make your deployments agile.
SYS-CON Events has announced today that Roger Strukhoff has been named conference chair of Cloud Expo and @ThingsExpo 2015 Silicon Valley. The 17th Cloud Expo and 4th @ThingsExpo will take place on November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. "The Internet of Things brings trillions of dollars of opportunity to developers and enterprise IT, no matter how you measure it," stated Roger Strukhoff. "More importantly, it leverages the power of devices and the Internet to enable us all to improve the state of the world and lives of people."
Cloud Expo is the single show where delegates and technology vendors can meet to experience and discuss the entire world of the cloud.At 16th Cloud Expo in New York City, Sandy Carter keynoted on women in tech and why women need to take risks and embrace failure to give them the courage to crash through the glass ceiling. She now shares some of her own thoughts and experiences from Cloud Expo.
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
iRise has launched iRise 10.5, which broadens the ability to integrate iRise’s advanced product definition capabilities into the rest of the application development lifecycle, allowing artifacts to be visible and consumable in tools used later in the software development process. iRise takes you from sketch to realistic prototype-for desktop, mobile or wearable apps-in minutes. The 10.5 release brings more features to the cloud version, and expands integrations with leading ALM tools. (Photo: Business Wire) The Agile and DevOps movements have made strides in streamlining the process of...
Cloudian, Inc., has released Cloudian HyperStore ‘forever live’ FL3000 series arrays and HyperStore 5.2 software. The new appliances, which can start small and scale up to 3.8 petabytes of storage in a single data center rack, offer businesses the ability to scale with the demands of the business, from terabytes to hundreds of petabytes.
While many app developers are comfortable building apps for the smartphone, there is a whole new world out there. In his session at @ThingsExpo, Narayan Sainaney, Co-founder and CTO of Mojio, will discuss how the business case for connected car apps is growing and, with open platform companies having already done the heavy lifting, there really is no barrier to entry.
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
SYS-CON Events announced today that Luxoft Holding, Inc., a leading provider of software development services and innovative IT solutions, has been named “Bronze Sponsor” of SYS-CON's @ThingsExpo, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Luxoft’s software development services consist of core and mission-critical custom software development and support, product engineering and testing, and technology consulting.
Akana has announced the availability of the new Akana Healthcare Solution. The API-driven solution helps healthcare organizations accelerate their transition to being secure, digitally interoperable businesses. It leverages the Health Level Seven International Fast Healthcare Interoperability Resources (HL7 FHIR) standard to enable broader business use of medical data. Akana developed the Healthcare Solution in response to healthcare businesses that want to increase electronic, multi-device access to health records while reducing operating costs and complying with government regulations.
The Internet of Things is in the early stages of mainstream deployment but it promises to unlock value and rapidly transform how organizations manage, operationalize, and monetize their assets. IoT is a complex structure of hardware, sensors, applications, analytics and devices that need to be able to communicate geographically and across all functions. Once the data is collected from numerous endpoints, the challenge then becomes converting it into actionable insight.
With the Apple Watch making its way onto wrists all over the world, it’s only a matter of time before it becomes a staple in the workplace. In fact, Forrester reported that 68 percent of technology and business decision-makers characterize wearables as a top priority for 2015. Recognizing their business value early on, FinancialForce.com was the first to bring ERP to wearables, helping streamline communication across front and back office functions. In his session at @ThingsExpo, Kevin Roberts, GM of Platform at FinancialForce.com, will discuss the value of business applications on wearable ...
The 3rd International WebRTC Summit, to be held Nov. 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA, announces that its Call for Papers is now open. Topics include all aspects of improving IT delivery by eliminating waste through automated business models leveraging cloud technologies. WebRTC Summit is co-located with 15th International Cloud Expo, 6th International Big Data Expo, 3rd International DevOps Summit and 2nd Internet of @ThingsExpo. WebRTC (Web-based Real-Time Communication) is an open source project supported by Google, Mozilla and Opera that aims to enable bro...
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
SYS-CON Events announced today that Pythian, a global IT services company specializing in helping companies leverage disruptive technologies to optimize revenue-generating systems, has been named “Bronze Sponsor” of SYS-CON's 17th Cloud Expo, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Founded in 1997, Pythian is a global IT services company that helps companies compete by adopting disruptive technologies such as cloud, Big Data, advanced analytics, and DevOps to advance innovation and increase agility. Specializing in designing, imple...