<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Patrick Talmadge &#187; Computers</title>
	<atom:link href="http://www.patricktalmadge.com/category/computers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.patricktalmadge.com</link>
	<description>My Thoughts and Ramblings</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:59:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Regex Flickr Parser</title>
		<link>http://www.patricktalmadge.com/2011/12/20/regex-flickr-parser/</link>
		<comments>http://www.patricktalmadge.com/2011/12/20/regex-flickr-parser/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 23:26:45 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Flickr Embed]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1507</guid>
		<description><![CDATA[<p>Today&#8217;s Regex is used to parse a string for Flickr links and extract the Photo_ID. Once we have the Photo_ID we&#8217;re able to create a standard embed code from nearly any Flickr URL.</p> Supported Links: <p>The following Regex supports these Flickr links and embed code snippets.</p> Normal URL : http://www.flickr.com/photos/gambort/6501997531/ Short URL : http://flic.kr/p/aUyrkH Embed [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s Regex is used to parse a string for Flickr links and extract the Photo_ID. Once we have the Photo_ID we&#8217;re able to create a standard embed code from nearly any Flickr URL.</p>
<h4>Supported Links:</h4>
<p>The following Regex supports these Flickr links and embed code snippets.</p>
<pre>
Normal URL : http://www.flickr.com/photos/gambort/6501997531/
Short URL :  http://flic.kr/p/aUyrkH
Embed :      &gt;a href="http://www.flickr.com/photos/gambort/6501997531/"
             title="Skyrim black dragon by gambort, on Flickr"&gt;&lt;img
	     src="http://farm8.staticflickr.com/7004/6501997531_80aa9da91a.jpg"
             width="500" height="334" alt="Skyrim black dragon"&gt;&lt;/a&gt;

****Short Code id needs to be decoded and replaced with the full photo ID****
</pre>
<p><br/></p>
<p>Again, I&#8217;ve broken it up the Regex and commented each line.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$regexstr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'~
# Match Flickr link and embed code
(?:&lt;a [^&gt;]*href=&quot;)?		# If a tag match up to first quote of src
(?:				# Group Flickr url
	https?:\/\/		# Either http or https
	(?:[\w]+\.)*		# Optional subdomains
	(?:               		# Group host alternatives.
		flic\.kr     	# Either flic.kr
	        	| flickr\.com	# or flickr.com 
	)			# End Host Group
	(?:\/photos)?		# Optional video sub directory
	\/[^\/]+\/		# Slash and stuff before Id
	([0-9a-zA-Z]+)	# $1: PHOTO_ID is numeric
	[^\s]*			# Not a space
)				# End group
&quot;?				# Match end quote if part of src
(?:.*&gt;&lt;/a&gt;)?			# Match the end of the a tag
~ix'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>Usage Example:</h4>
<p>This example is more involved than the previous posts because we need to make an API call to get the image URL after we get the Flickr Photo_ID. I&#8217;ve also included a Base58 decode function incase the url is the short flic.kr style link. </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParseForFlickr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$regexstr</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&lt;&lt;</span>REGEX FROM ABOVE<span style="color: #339933;">&gt;&gt;;</span>
&nbsp;
	<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'phpFlickr.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$f</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpFlickr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;&lt;Flickr API Key&gt;&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$regexstr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Loop results		</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
		<span style="color: #666666; font-style: italic;">//If short code decode it     </span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;flic.kr&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flickrDecode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> 
&nbsp;
		<span style="color: #666666; font-style: italic;">//make flickr api call with photo id</span>
		<span style="color: #000088;">$pinfo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$f</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">photos_getSizes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//Array 3 is the medium 500 size</span>
		<span style="color: #000088;">$imgstr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' &lt;p&gt;&lt;img class=&quot;upostimg&quot; src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$pinfo</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'source'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;&lt;/p&gt; '</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$imgstr</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> flickrDecode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$alphabet</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$decoded</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$multi</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$digit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$decoded</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$multi</span> <span style="color: #339933;">*</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$alphabet</span><span style="color: #339933;">,</span> <span style="color: #000088;">$digit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$multi</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$multi</span> <span style="color: #339933;">*</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$alphabet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$decoded</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>For more Regex see <a href="http://www.patricktalmadge.com/2011/12/14/regex-youtube-parser/">Regex YouTube Parser</a> or <a href="http://www.patricktalmadge.com/2011/12/17/regex-vimeo-parser/">Regex Vimeo Parser</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/12/20/regex-flickr-parser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regex Vimeo Parser</title>
		<link>http://www.patricktalmadge.com/2011/12/17/regex-vimeo-parser/</link>
		<comments>http://www.patricktalmadge.com/2011/12/17/regex-vimeo-parser/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 05:28:12 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Vimeo Embed]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1499</guid>
		<description><![CDATA[<p>Today&#8217;s Regex is used to parse a string for Vimeo links and extract the Video_ID. Once we have the Video_ID we&#8217;re able to create a standard embed code from Vimeo links.</p> Supported Links: <p>The following Regex supports these Vimeo links and embed code snippets.</p> Normal URL: http://vimeo.com/9669721 Group URL: http://vimeo.com/groups/tvc/videos/32626014 New Embed: &#60;iframe src="http://player.vimeo.com/video/9669721?title=0 &#38;byline=0&#38;portrait=0&#38;color=ffffff" [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s Regex is used to parse a string for Vimeo links and extract the Video_ID. Once we have the Video_ID we&#8217;re able to create a standard embed code from Vimeo links.</p>
<h4>Supported Links:</h4>
<p>The following Regex supports these Vimeo links and embed code snippets.</p>
<pre>
Normal URL: http://vimeo.com/9669721
Group URL:   http://vimeo.com/groups/tvc/videos/32626014
New Embed:   &lt;iframe src="http://player.vimeo.com/video/9669721?title=0
             &amp;byline=0&amp;portrait=0&amp;color=ffffff" width="400"
             height="225" frameborder="0" webkitAllowFullScreen
             mozallowfullscreen allowFullScreen &gt; &lt;/iframe &gt;

**** Doesn't handle Vimeo's old embed code ****
</pre>
<p><br/></p>
<p>Again, I&#8217;ve broken it up the Regex and commented each line.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$regexstr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'~
 # Match Vimeo link and embed code
(?:&lt;iframe [^&gt;]*src=&quot;)? 	# If iframe match up to first quote of src
(?:				# Group vimeo url
	https?:\/\/		# Either http or https
	(?:[\w]+\.)*		# Optional subdomains
	vimeo\.com		# Match vimeo.com
	(?:[\/\w]*\/videos?)?	# Optional video sub directory this handles groups links also
	\/			# Slash before Id
	([0-9]+)		# $1: VIDEO_ID is numeric
	[^\s]*			# Not a space
)				# End group
&quot;?				# Match end quote if part of src
(?:[^&gt;]*&gt;&lt;/iframe&gt;)?		# Match the end of the iframe
(?:&lt;p&gt;.*&lt;/p&gt;)?		        # Match any title information stuff
~ix'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>Usage Example:</h4>
<p>This example function takes an input string and uses the above Regex to parse off the Vimeo Video_ID ($1) and add it to $iframestr to create a standard embed code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParsePostVimeo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$regexstr</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&lt;&lt;</span>REGEX FROM ABOVE<span style="color: #339933;">&gt;&gt;;</span>
	<span style="color: #000088;">$iframestr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' &lt;p&gt;&lt;iframe src=&quot;http://player.vimeo.com/video/$1?title=0&amp;amp;byline=0&amp;amp;portrait=0&quot; width=&quot;500&quot; height=&quot;284&quot; frameborder=&quot;0&quot; webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;/iframe&gt;&lt;/p&gt; '</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$regexstr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$iframestr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>For more Regex see <a href="http://www.patricktalmadge.com/2011/12/14/regex-youtube-parser/">Regex YouTube Parser</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/12/17/regex-vimeo-parser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Regex YouTube Parser</title>
		<link>http://www.patricktalmadge.com/2011/12/14/regex-youtube-parser/</link>
		<comments>http://www.patricktalmadge.com/2011/12/14/regex-youtube-parser/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 05:02:14 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[YouTube Embed]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1481</guid>
		<description><![CDATA[<p>Over the next several days I&#8217;m going to post a series of Regex strings. These Regex strings can be used to parse input for different links. I&#8217;m using PHP in my examples (you may need to tweak the Regex to work in another language).</p> <p>Today&#8217;s Regex is used to parse a string for YouTube links [...]]]></description>
			<content:encoded><![CDATA[<p>Over the next several days I&#8217;m going to post a series of Regex strings. These Regex strings can be used to parse input for different links. I&#8217;m using PHP in my examples (you may need to tweak the Regex to work in another language).</p>
<p>Today&#8217;s Regex is used to parse a string for YouTube links and extract the Video_ID. Once I have the Video_ID I&#8217;m able to create a standard embed code from nearly any YouTube URL.</p>
<h4>Supported Links:</h4>
<p>The following Regex supports these YouTube links and embed code snippets.</p>
<pre>
Short URL : http://youtu.be/OxWMsxa5uVk
Normal URL: http://www.youtube.com/watch?v=OxWMsxa5uVk&#038;t=28s
HTTPS URL : https://www.youtube.com/watch?v=OxWMsxa5uVk&#038;feature=g-logo
New Embed : &lt;iframe width="560" height="315" src="http://www.youtube.com/
            embed/OxWMsxa5uVk" frameborder="0"
            allowfullscreen&gt;&lt;/iframe&gt;
Old Embed : &lt;object width="1280" height="720"&gt;&lt;param name="movie"
            value="http://www.youtube.com/v/OxWMsxa5uVk?
            version=3&amp;hl=en_US&amp;rel=0"&gt;&lt;/param&gt;
            &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;
            &lt;param name="allowscriptaccess"
            value="always"&gt;&lt;/param&gt;&lt;embed
            src="http://www.youtube.com/v/OxWMsxa5uVk?version=3&amp;
            hl=en_US&amp;rel=0" type="application/x-shockwave-flash"
            width="1280" height="720" allowscriptaccess="always"
            allowfullscreen="true"&gt; &lt;/embed>&lt;/object&gt;
</pre>
<p><br/></p>
<p>I won&#8217;t spend a lot of time explaining the Regex because I&#8217;ve broken it up Regex and commented each line.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$regexstr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'~
# Match Youtube link and embed code
(?:				 # Group to match embed codes
   (?:&lt;iframe [^&gt;]*src=&quot;)?	 # If iframe match up to first quote of src
   |(?:				 # Group to match if older embed
      (?:&lt;object .*&gt;)?		 # Match opening Object tag
      (?:&lt;param .*&lt;/param&gt;)*     # Match all param tags
      (?:&lt;embed [^&gt;]*src=&quot;)?     # Match embed tag to the first quote of src
   )?				 # End older embed code group
)?				 # End embed code groups
(?:				 # Group youtube url
   https?:\/\/		         # Either http or https
   (?:[\w]+\.)*		         # Optional subdomains
   (?:               	         # Group host alternatives.
       youtu\.be/      	         # Either youtu.be,
       | youtube\.com		 # or youtube.com 
       | youtube-nocookie\.com	 # or youtube-nocookie.com
   )				 # End Host Group
   (?:\S*[^\w\-\s])?       	 # Extra stuff up to VIDEO_ID
   ([\w\-]{11})		         # $1: VIDEO_ID is numeric
   [^\s]*			 # Not a space
)				 # End group
&quot;?				 # Match end quote if part of src
(?:[^&gt;]*&gt;)?			 # Match any extra stuff up to close brace
(?:				 # Group to match last embed code
   &lt;/iframe&gt;		         # Match the end of the iframe	
   |&lt;/embed&gt;&lt;/object&gt;	         # or Match the end of the older embed
)?				 # End Group of last bit of embed code
~ix'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>Usage Example:</h4>
<p>This example function takes an input string and uses the above Regex to parse off the Video_ID ($1) and add it to $iframestr to create a standard embed code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ParsePostYouTube<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$regexstr</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&lt;&lt;</span>REGEX FROM ABOVE<span style="color: #339933;">&gt;&gt;;</span>
  <span style="color: #000088;">$iframestr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' &lt;p&gt;&lt;iframe width=&quot;500&quot; height=&quot;284&quot; src=&quot;http://www.youtube.com/embed/$1?wmode=transparent&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/p&gt; '</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$regexstr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$iframestr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/12/14/regex-youtube-parser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Date in Human Readable Format</title>
		<link>http://www.patricktalmadge.com/2011/06/30/php-date-in-human-readable-format/</link>
		<comments>http://www.patricktalmadge.com/2011/06/30/php-date-in-human-readable-format/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 05:22:21 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Date Format]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1437</guid>
		<description><![CDATA[<p>I&#8217;m working on a PHP project that requires human readable, relative date formatting. Below is the PHP function I&#8217;m using. The function handles past and future dates.</p> <p>Sample Future Output : </p> 30 seconds to go 1 minute to go 5 hours to go Tomorrow at 2:25pm June 30, 2022 5:34pm <p>Sample Past Output : [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a PHP project that requires human readable, relative date formatting. Below is the PHP function I&#8217;m using. The function handles past and future dates.</p>
<p>Sample Future Output : </p>
<ul>
<li>30 seconds to go</li>
<li>1 minute to go</li>
<li>5 hours to go</li>
<li>Tomorrow at 2:25pm</li>
<li>June 30, 2022 5:34pm</li>
</ul>
<p>Sample Past Output : </p>
<ul>
<li>0 seconds ago</li>
<li>32 minutes ago</li>
<li>20 hours ago</li>
<li>Yesterday at  5:26pm</li>
<li>Monday at 10:28am</li>
<li>June 25 at 5:23am</li>
<li>March 30, 2010 at 5:34pm</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> FormatTime<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Get time difference and setup arrays</span>
	<span style="color: #000088;">$difference</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$timestamp</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$periods</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;second&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;minute&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hour&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;day&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;week&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;month&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;years&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$lengths</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;60&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;60&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;24&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;7&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;4.35&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Past or present</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ending</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ago&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$difference</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #000088;">$difference</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$ending</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;to go&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Figure out difference by looping while less than array length</span>
	<span style="color: #666666; font-style: italic;">// and difference is larger than lengths.</span>
	<span style="color: #000088;">$arr_len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lengths</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$arr_len</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$difference</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$lengths</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$difference</span> <span style="color: #339933;">/=</span> <span style="color: #000088;">$lengths</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Round up		</span>
	<span style="color: #000088;">$difference</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Make plural if needed</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$difference</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$periods</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Default format</span>
	<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$difference</span> <span style="color: #006699; font-weight: bold;">$periods</span>[<span style="color: #006699; font-weight: bold;">$j</span>] <span style="color: #006699; font-weight: bold;">$ending</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// over 24 hours</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// future date over a day formate with year</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ending</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;to go&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$difference</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Tomorrow at &quot;</span><span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;g:i a&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j, Y \a<span style="color: #000099; font-weight: bold;">\\</span>t g:i a&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$difference</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Yesterday</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Yesterday at &quot;</span><span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;g:i a&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Less than a week display -- Monday at 5:28pm</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l \a<span style="color: #000099; font-weight: bold;">\\</span>t g:i a&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$difference</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Less than a year display -- June 25 at 5:23am</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j \a<span style="color: #000099; font-weight: bold;">\\</span>t g:i a&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #666666; font-style: italic;">// if over a year or the same month one year ago -- June 30, 2010 at 5:34pm</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j, Y \a<span style="color: #000099; font-weight: bold;">\\</span>t g:i a&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/06/30/php-date-in-human-readable-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Super Simple WCF Caching</title>
		<link>http://www.patricktalmadge.com/2011/06/15/super-simple-wcf-caching/</link>
		<comments>http://www.patricktalmadge.com/2011/06/15/super-simple-wcf-caching/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 03:36:34 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1418</guid>
		<description><![CDATA[<p>The other day I had an interesting problem at work. My new project had a web service call that was pulling metadata off an MS SQL cube. When I started to the the project the call had 6 nested loops that it processing twice. A poster child for inefficiency. Unfortunately looping seems the be the [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I had an interesting problem at work. My new project had a web service call that was pulling metadata off an MS SQL cube. When I started to the the project the call had 6 nested loops that it processing twice. A poster child for inefficiency. Unfortunately looping seems the be the only way to pull metadata from a cube. </p>
<p>By limiting the loops to only the required dimensions and processing everything only once, I was able to get the execution time from 2.5 minutes down to 6 seconds. 6 seconds is still far to long for an on demand call. Luckily the cube metadata doesn&#8217;t change frequently. Allowing me to cache the data. Taking the call from 6 seconds down to 200 milliseconds, on all subsequent calls. This is the caching I implemented for the metadata.</p>
<p>Created global private static instance of the HttpRuntime Cache. Allowing anyone calling the service to get the same data from the cache.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Caching</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cache</span> _cache <span style="color: #008000;">=</span> HttpRuntime<span style="color: #008000;">.</span><span style="color: #0000FF;">Cache</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Next, create a key to use for your cached object. Depending on the data your caching this may need to be more unique than below. Get the object from your global cache using the key. If a non-null comes out of the cache return your cached object.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">string</span> key <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">object</span> to cache<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
&nbsp;
var list <span style="color: #008000;">=</span> _cache<span style="color: #008000;">.</span><span style="color: #0000FF;">Get</span><span style="color: #008000;">&#40;</span>key<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> <span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">object</span> to cache<span style="color: #008000;">&gt;;</span>
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>list <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
      <span style="color: #0600FF; font-weight: bold;">return</span> list<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>If no object comes out of the cache do your normal data processing. Just before you return your data add it to the cache. Here I&#8217;m caching for one day at normal priority.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">  _cache<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>key,<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">object</span> to cache<span style="color: #008000;">&gt;</span>, <span style="color: #0600FF; font-weight: bold;">null</span>, DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddDays</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>, <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Caching</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Cache</span><span style="color: #008000;">.</span><span style="color: #0000FF;">NoSlidingExpiration</span>, <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Caching</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">CacheItemPriority</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Normal</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>That&#8217;s it! The first call will populate the cache and all other calls will pull from the cache. Super simple and an excellent way to improve your service call performance.</p>
<h5>Good Luck!</h5>
]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/06/15/super-simple-wcf-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide Multiple Upload link in SharePoint 2010</title>
		<link>http://www.patricktalmadge.com/2011/04/09/hide-multiple-upload-link-in-sharepoint-2010/</link>
		<comments>http://www.patricktalmadge.com/2011/04/09/hide-multiple-upload-link-in-sharepoint-2010/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 02:20:11 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1351</guid>
		<description><![CDATA[<p>I had a request to hide the multiple file upload links in SharePoint 2010. After an hour or two of searching for a configuration setting, I got tired and did a simple CSS hack. Granted this doesn&#8217;t disable the functionality it only hides links. So users could still work around this if they know the [...]]]></description>
			<content:encoded><![CDATA[<p>I had a request to hide the multiple file upload links in SharePoint 2010. After an hour or two of searching for a configuration setting, I got tired and did a simple CSS hack. Granted this doesn&#8217;t disable the functionality it only hides links. So users could still work around this if they know the path. </p>
<p>Because SharePoint ignores common web standards and uses Ids with periods I had to escape the Id. CSS will treat the periods as a class declaration if they are not escaped.</p>
<p>To use this simply add the code snippet to your main CSS file or your master page in SharePoint. If this code snippet doesn&#8217;t work for you verify that the Id&#8217;s are the same in your SharePoint installation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#ctl00_PlaceHolderMain_UploadDocumentSection_ctl03_UploadMultipleLink</span><span style="color: #00AA00;">,</span> 
<span style="color: #cc00cc;">#Ribbon</span>\.Documents\.New\.AddDocument\.Menu\.Upload\<span style="color: #6666ff;">.UploadMultiple-Menu32</span>
<span style="color: #00AA00;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/04/09/hide-multiple-upload-link-in-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dealing with Silverlight InitParms</title>
		<link>http://www.patricktalmadge.com/2011/03/15/dealing-with-silverlight-initparms/</link>
		<comments>http://www.patricktalmadge.com/2011/03/15/dealing-with-silverlight-initparms/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 05:00:51 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1325</guid>
		<description><![CDATA[<p>I&#8217;ve found the best way access initParams throughout your Silverlight Application is to put them in a global static dictionary. This is how I setup my initParms dictionary.</p> <p>First we need to set an initParams in our ASPX Page:</p> 1 2 3 4 5 6 7 8 9 10 11 12 13 &#60;div id=&#34;silverlightControlHost&#34;&#62; &#60;object [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found the best way access initParams throughout your Silverlight Application is to put them in a global static dictionary. This is how I setup my initParms dictionary.</p>
<p>First we need to set an initParams in our ASPX Page:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;silverlightControlHost&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>object width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;100%&quot;</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;100%&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;application/x-silverlight-2&quot;</span> data<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;data:application/x-silverlight-2,&quot;</span><span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>param name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;source&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ClientBin/initParamsDemo.xap&quot;</span> <span style="color: #339933;">/&gt;</span> 
		<span style="color: #339933;">&lt;</span>param name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;onError&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;onSilverlightError&quot;</span> <span style="color: #339933;">/&gt;</span> 
		<span style="color: #339933;">&lt;</span>param name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;background&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;white&quot;</span> <span style="color: #339933;">/&gt;</span> 
		<span style="color: #339933;">&lt;</span>param name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;minRuntimeVersion&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;3.0.40818.0&quot;</span> <span style="color: #339933;">/&gt;</span> 
		<span style="color: #339933;">&lt;</span>param name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;autoUpgrade&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> <span style="color: #339933;">/&gt;</span>
		<span style="color: #339933;">&lt;</span>param name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;initParams&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ServiceURL=http://localhost:8000/service1.svc&quot;</span> <span style="color: #339933;">/&gt;</span>
		<span style="color: #339933;">&lt;</span> a style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text-decoration: none;&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40818.0&quot;</span><span style="color: #339933;">&gt;</span> 
			<span style="color: #339933;">&lt;</span>img style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;border-style: none;&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://go.microsoft.com/fwlink/?LinkId=108181&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Get Microsoft Silverlight&quot;</span> <span style="color: #339933;">/&gt;</span> 
		<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;/</span>object<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Next we need to create our static dictionary in App.xaml.cs and assign the dictionary in the startup event.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> static IDictionary<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">,</span> string<span style="color: #339933;">&gt;</span> AppParams<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> void Application_Startup<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> StartupEventArgs e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	this<span style="color: #339933;">.</span>RootVisual <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MainPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	AppParams <span style="color: #339933;">=</span> e<span style="color: #339933;">.</span>InitParams<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>When you want to access your param you simply use grab if from the dictionary using the key.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"> App<span style="color: #339933;">.</span>AppParams<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ServiceURL&quot;</span><span style="color: #009900;">&#93;</span></pre></td></tr></table></div>

<p>We can&#8217;t always trust that the initParam is set you should check to make sure it&#8217;s in the dictionary before using it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>App<span style="color: #339933;">.</span>AppParams<span style="color: #339933;">.</span>ContainsKey<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ServiceURL&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Do Something with: App.AppParams[&quot;ServiceURL&quot;]</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Handle error&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2011/03/15/dealing-with-silverlight-initparms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ch Ch Changes</title>
		<link>http://www.patricktalmadge.com/2010/08/24/ch-ch-changes/</link>
		<comments>http://www.patricktalmadge.com/2010/08/24/ch-ch-changes/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 04:00:46 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Career]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[New]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=1238</guid>
		<description><![CDATA[<p>After more than 3 years on the same team I&#8217;ve accepted a Senior Developer job offer from <a href="http://www.extendedresults.com/">Extended Results</a>. I will be starting my new job September 7th. <a href="http://www.extendedresults.com/">Extended Results</a> was founded in 2006 and specializes in business intelligence software solutions, a huge market in this economy. I think I&#8217;ll be able to [...]]]></description>
			<content:encoded><![CDATA[<p>After more than 3 years on the same team I&#8217;ve accepted a Senior Developer job offer from <a href="http://www.extendedresults.com/">Extended Results</a>. I will be starting my new job September 7th. <a href="http://www.extendedresults.com/">Extended Results</a> was founded in 2006 and specializes in business intelligence software solutions, a huge market in this economy. I think I&#8217;ll be able to make a huge difference in the company as well as take my career to the next level.</p>
<p>Most of <a href="http://www.extendedresults.com/">Extended Results&#8217; </a> software is developed in Silverlight, which gives me a chance to hone my Silverlight skill set. I eagerly await this new chapter in my career.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2010/08/24/ch-ch-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expand URL</title>
		<link>http://www.patricktalmadge.com/2009/11/12/expand-url/</link>
		<comments>http://www.patricktalmadge.com/2009/11/12/expand-url/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 22:14:08 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=930</guid>
		<description><![CDATA[<p>The popularity of short URL services, like tinyurl.com and bit.ly, has grown due to the character limits of Twitter. These services pose a security risk because they could be used to conceal the addresses malicious sites. Users are being taught to trust all URLs and just blindly click. Sites like Twitter should offer users the [...]]]></description>
			<content:encoded><![CDATA[<p>The popularity of short URL services, like tinyurl.com and bit.ly, has grown due to the character limits of Twitter. These services pose a security risk because they could be used to conceal the addresses malicious sites. Users are being taught to trust all URLs and just blindly click. Sites like Twitter should offer users the ability to expand these short URLs so the user can quickly verify the trust worthiness.</p>
<p>Below is a sample php function that expands URLs. As you can see the function is extremely simple and only takes two lines of code (the rest of the code is a use example). I hope large sites will adopt similar functionality before novice users become accustomed to blindly clicking obfuscated links.</p>
<blockquote><p>&lt;?php<br />
                  $url = <span style="color: #ff0000;">&#8220;http://bit.ly/4t9IYV&#8221;</span>;<br />
                  $fullURL = expandURL($url);<br />
                   <span style="color: #0000ff;">echo</span> <span style="color: #ff0000;">&#8220;Short URL: $url&#8221;</span>;<br />
                   <span style="color: #0000ff;">echo</span> <span style="color: #ff0000;">&#8220;Original URL:&#8221;</span>.$fullURL;</p>
<p>                   <span style="color: #0000ff;">function</span> expandURL( $url )<br />
                   {<br />
                                    $fullURL = get_headers($url,1);<br />
                                    <span style="color: #0000ff;">return</span> $fullURL['Location'];<br />
                   }<br />
?&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2009/11/12/expand-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problem Step Recorder in Windows 7</title>
		<link>http://www.patricktalmadge.com/2009/09/30/problem-step-recorder-in-windows-7/</link>
		<comments>http://www.patricktalmadge.com/2009/09/30/problem-step-recorder-in-windows-7/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 21:31:55 +0000</pubDate>
		<dc:creator>Patrick Talmadge</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Problem Step Recorder]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.patricktalmadge.com/?p=832</guid>
		<description><![CDATA[<p>Problem Step Recorder is a neat new tool built into Windows 7. On a Windows 7 machine type PSR in the search box and Problem Step Recorder will open. </p> <p style="text-align: center;"></p> <p>Click &#8220;Start Record&#8221; and reproduce the problem/error/step. Once PSR is running you can add comments by clicking &#8220;Add Comments&#8221; . When the issue has been reproduced click &#8220;Stop [...]]]></description>
			<content:encoded><![CDATA[<p>Problem Step Recorder is a neat new tool built into Windows 7. On a Windows 7 machine type PSR in the search box and Problem Step Recorder will open. </p>
<p style="text-align: center;"><img class="size-full wp-image-873 aligncenter" title="psr_open" src="http://www.patricktalmadge.com/wp-content/uploads/2009/08/psr_open.png" alt="psr_open" width="442" height="69" /></p>
<p>Click &#8220;Start Record&#8221; and reproduce the problem/error/step. Once PSR is running you can add comments by clicking &#8220;Add Comments&#8221; . When the issue has been reproduced click &#8220;Stop Record&#8221; and save the mht file.</p>
<p>This is a great little tool that will help software testers explain how to reproduce bugs. PSR could even help the IT people figure out user problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.patricktalmadge.com/2009/09/30/problem-step-recorder-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<div style="display:none;">
<a href="http://www.filmistek.com" title="film izle" >film izle</a>
<a href="http://www.filmizlek.net" title="film izle" >film izle</a> 
<a href="http://www.nettefilm.net" title="film izle" >film izle</a>
<a href="http://www.nettefilmizle.net" title="film izle" >film izle</a>
<a href="http://www.sinemasohbet.com" title="film izle" >film izle</a>
<a href="http://www.sinemafilmizleme.com" title="film izle" >film izle</a>
<a href="http://www.laledevridizisi.net" title="film izle" >film izle</a>
<a href="http://www.guncelvideolar.net" title="film izle" >film izle</a> 


<a href="http://xdiziizle.blogspot.com" title="dizi izle" >dizi izle</a>
<a href="http://tr-square.blogspot.com" title="dizi izle" >dizi izle</a>
<a href="http://brnckvvtmllttrhaberimatbaa.blogspot.com" title="film izle" >film izle</a>
<a href="http://zirzir.blogspot.com" title="film izle" >film izle</a>
<a href="http://filmizle-flimizle.blogspot.com" title="film izle" >film izle</a>
</div>
