Skip to content

Instantly share code, notes, and snippets.

View mtheoryx's full-sized avatar
🐳
Making happy little clouds

David Poindexter mtheoryx

🐳
Making happy little clouds
View GitHub Profile
@mtheoryx
mtheoryx / gist:3131260
Created July 17, 2012 18:53
Search within an array of hashes by value
# Say you have an array of hashes. They keys can be strings or symbols,
# Ruby doesn't care much in this instance.
# And say you want to do a search based on the value of one of those hash keys.
# First, let's make a new array of hashes.
haystack = Array.new
haystack << {:title => "Privacy Status", :id => "sakai.privacy"}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v02="http://go.iu.edu/v02">
<soapenv:Header/>
<soapenv:Body>
<v02:Encode>
<!--Optional:-->
<v02:passCode>?</v02:passCode>
<!--Optional:-->
<v02:longURL>?</v02:longURL>
</v02:Encode>
</soapenv:Body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
@mtheoryx
mtheoryx / gist:3138139
Created July 18, 2012 19:08
Ruby short circuit "or"
# First, let's explain some "normal" conditional OR behavior.
# I'm going to use some IRB output here because IRB always prints
# an evaluation value to the screen; this will help.
# Just setting up some variables to play with
# The comment that starts with "#=>" is the result
# of the operation, and IRB prints this out for us
# automatically
1.9.3p194 :001 > a = 1
#=> 1
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<EncodeResponse xmlns="http://go.iu.edu/v02/">
<EncodeResult/>
</EncodeResponse>
</soap:Body>
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<EncodeResponse xmlns="http://go.iu.edu/">
<EncodeResult>http://go.iu.edu/5sA</EncodeResult>
</EncodeResponse>
</soap:Body>
</soap:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v02="http://go.iu.edu/v02">
<soapenv:Header/>
<soapenv:Body>
<v02:Encode>
<!--Optional:-->
<v02:passCode>?</v02:passCode>
<!--Optional:-->
<v02:longURL>?</v02:longURL>
</v02:Encode>
</soapenv:Body>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Invalid Passcode - Please try again.
at GoIUWebServiceV02.Encode(String passCode, String longURL)</faultstring>
<faultactor>GoIU</faultactor>
<detail/>
</soap:Fault>
</soap:Body>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<EncodeResponse xmlns="http://go.iu.edu/v02">
<EncodeResult/>
</EncodeResponse>
</soap:Body>
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Invalid Passcode - Please try again.
at GoIUWebServiceV02.Encode(String passCode, String longURL)</faultstring>
<faultactor>GoIU</faultactor>
<detail/>
</soap:Fault>
</soap:Body>