<?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>mikerochford.com &#187; Programming</title>
	<atom:link href="http://mikerochford.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikerochford.com/blog</link>
	<description>Being technical</description>
	<lastBuildDate>Thu, 16 Jun 2011 19:02:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Naigos Plugin: Check for packages to update in Debian/Ubuntu</title>
		<link>http://mikerochford.com/blog/2009/11/05/naigos-plugin-check-for-packages-to-update-in-debianubuntu/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/11/05/naigos-plugin-check-for-packages-to-update-in-debianubuntu/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 04:13:47 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=97</guid>
		<description><![CDATA[Over the years I have manages a lot of systems, mostly debian based. The thing I really hate about having a lot of standalone systems is updating software. I am really bad at keeping track of new updates and I really dont want to have a cron script running to send me a email every [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years I have manages a lot of systems, mostly debian based. The thing I really hate about having a lot of standalone systems is updating software. I am really bad at keeping track of new updates and I really dont want to have a cron script running to send me a email every day. Below is a script I used as a plugin for nagios. </p>
<p>The Script: <a href="http://mikerochford.com/code/perl/check_for_updates.pl">check_for_updates.pl</a></p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=97&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/11/05/naigos-plugin-check-for-packages-to-update-in-debianubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup of your MYSQL server using mysqldump</title>
		<link>http://mikerochford.com/blog/2009/10/22/backup-of-your-mysql-server-using-mysqldump/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/10/22/backup-of-your-mysql-server-using-mysqldump/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 15:25:51 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=85</guid>
		<description><![CDATA[Over the years of being a admin I have seen many ideas on how to backup a mysql database server. Many people are satisfied with with one large dump of all databases into one flat text file. Others think copy the actual db files to other locations are the way to back things up. I [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years of being a admin I have seen many ideas on how to backup a mysql database server. Many people are satisfied with with one large dump of all databases into one flat text file. Others think copy the actual db files to other locations are the way to back things up. I have found dealing with customer and internal databases you need incremental backups. With all that said I developed a perl script that will log in grab all existing database names and do a mysqldump of each database. It will also keep a specified amount of backups and you also can choose to have some logs gzip'ed or left uncompressed. Below is the link to the code. You will have update login credentials and the ip address of the mysql server. </p>
<p>Link: <a href="http://mikerochford.com/code/perl/mysql_backup.pl">mysql_backup.pl</a></p>
<p>Explanation of the script: </p>
<p>The script will login to your mysql server and issue a "show databases;". Once it the database names are retrieved it will run a mysqldump on each database and store the output in the specified directory. The name scheme of the out will be database_name-YYYYMMDD.sql. Doing this it will allow you to sort based on date. Once all mysqldumps have completed it will go through each database directory and audit what should be saved, deleted, gzipped or leave alone. You will be able to chose what the numbers of day you want to retain and the how many days you want to leave as a uncompressed file.</p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=85&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/10/22/backup-of-your-mysql-server-using-mysqldump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to a machine using sockets</title>
		<link>http://mikerochford.com/blog/2009/05/27/connecting-to-a-machine-using-sockets/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/27/connecting-to-a-machine-using-sockets/#comments</comments>
		<pubDate>Wed, 27 May 2009 12:43:37 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=70</guid>
		<description><![CDATA[I work with a api system that connects on a high port. My co-work Matt came up with a great way to set the socket up and verify if the socket isn't stale. This sub-routine is specific to the api but you can use the theory and apply it to pretty much your socket needs. [...]]]></description>
			<content:encoded><![CDATA[<p>I work with a api system that connects on a high port. My co-work <a href="http://www.popmartian.com/tipsntricks/" target="_blank">Matt</a> came up with a great way to set the socket up and verify if the socket isn't stale. This sub-routine is specific to the api but you can use the theory and apply it to pretty much your socket needs.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">sub</span> cp_connect <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1">###############</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1">#</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1"># This function connects to a cp server</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1">#</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1"># Accepts:</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1"># $remote_host The server to connect to</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1"># $remote_port The port to connect to</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1">#</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1"># Returns:</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1"># A critical Path mail server socket connection.</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1">#</span><br />
&nbsp; &nbsp; &nbsp;<span class="co1">###############</span></p>
<p>&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$remote_host</span> = <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a>;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$remote_port</span> = <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a>;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$remote_password</span> = <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a>;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$remote_conneciton_type</span> = <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a>;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$EOL</span> = <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a>;</p>
<p>&nbsp; &nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$remote_conneciton_type</span> =~ <a href="http://perldoc.perl.org/functions/m.html"><span class="kw3">m</span></a>/^rw$/<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$remote_password</span> = <span class="re0">$remote_password</span> .<span class="st0">&quot; write&quot;</span>;<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$socket</span> = IO::<span class="me2">Socket</span>::<span class="me2">INET</span>-&gt;<span class="me1">new</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PeerAddr =&gt; <span class="re0">$remote_host</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PeerPort &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span class="re0">$remote_port</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Proto &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; <span class="st0">&quot;tcp&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; SOCK_STREAM,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Timeout &nbsp; &nbsp; &nbsp; &nbsp; =&gt; <span class="nu0">5</span> <span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; || <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;Couldn't open socket!<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>;</p>
<p>&nbsp; &nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$answer</span> = &lt;<span class="re0">$socket</span>&gt;;<br />
&nbsp; &nbsp; &nbsp;<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="re0">$socket</span> <span class="st0">&quot;LOGIN $remote_password&quot;</span> . <span class="re0">$EOL</span>;<br />
&nbsp; &nbsp; &nbsp;<span class="re0">$answer</span> = &lt;<span class="re0">$socket</span>&gt;;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$answer</span> !~ /^OK/<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;Failed to login to $remote_host : $remote_port : $answer<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/exit.html"><span class="kw3">exit</span></a><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="re0">$socket</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Once you have the understanding of how the sub-routine works. Building a script that interacts with the api is a piece of cake. </p>
<p>Here is an example of how we use the sub-routine in a script. This example will check to see if the socket is defined, if not it will try to connect and define the socket. Once the socket is defined it will issue a command and read the socket. </p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://perldoc.perl.org/functions/defined.html"><span class="kw3">defined</span></a> <span class="re0">$socket</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$socket</span> = cp_connect<span class="br0">&#40;</span><span class="re0">$remote_host</span>, <span class="re0">$remote_port</span>, <span class="re0">$remote_rwpass</span>,<span class="st0">&quot;rw&quot;</span>,<span class="re0">$EOL</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="re0">$socket</span> <span class="st0">&quot;DOMAIN ENUMERATE&quot;</span>. <span class="re0">$EOL</span>;<br />
<span class="kw1">while</span> <span class="br0">&#40;</span><a href="http://perldoc.perl.org/functions/defined.html"><span class="kw3">defined</span></a> <span class="br0">&#40;</span><a href="http://perldoc.perl.org/functions/chomp.html"><span class="kw3">chomp</span></a><span class="br0">&#40;</span><span class="re0">$answer</span> = &lt;<span class="re0">$socket</span>&gt;<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$answer</span> =~ /\*\<a href="http://perldoc.perl.org/functions/s.html"><span class="kw3">s</span></a>+<span class="br0">&#40;</span>.+<span class="br0">&#41;</span>\<a href="http://perldoc.perl.org/functions/s.html"><span class="kw3">s</span></a>/<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$domains</span><span class="br0">&#123;</span>$<span class="nu0">1</span><span class="br0">&#125;</span><span class="br0">&#123;</span><span class="st0">'users'</span><span class="br0">&#125;</span> = <span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">elsif</span><span class="br0">&#40;</span><span class="re0">$answer</span> =~ /^ERROR/<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$error</span> = <span class="re0">$answer</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">last</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">elsif</span><span class="br0">&#40;</span><span class="re0">$answer</span> =~ /OK/<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">last</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=70&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/27/connecting-to-a-machine-using-sockets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sub-routine: gettime();</title>
		<link>http://mikerochford.com/blog/2009/05/27/sub-routine-gettime/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/27/sub-routine-gettime/#comments</comments>
		<pubDate>Wed, 27 May 2009 12:20:01 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=57</guid>
		<description><![CDATA[Over the years working as a systems administrator I have a large sub-routine collection on my belt. One that I use quite frequently is gettime();. This is a simple routine someone in my group wrote to return a nicely formatted timestamp. It is use mostly for logging and such. sub gettime &#40;&#41; &#123; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years working as a systems administrator I have a large sub-routine collection on my belt. One that I use quite frequently is gettime();. This is a simple routine someone in my group wrote to return a nicely formatted timestamp. It is use mostly for logging and such. </p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">sub</span> gettime <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$sec</span>,<span class="re0">$min</span>,<span class="re0">$hour</span>,<span class="re0">$mday</span>,<span class="re0">$mon</span>,<span class="re0">$year</span>,<span class="re0">$wday</span>,<span class="re0">$yday</span>,<span class="re0">$isdst</span><span class="br0">&#41;</span> = <a href="http://perldoc.perl.org/functions/localtime.html"><span class="kw3">localtime</span></a><span class="br0">&#40;</span><a href="http://perldoc.perl.org/functions/time.html"><span class="kw3">time</span></a><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="re0">$year</span> += <span class="nu0">1900</span>;<br />
&nbsp; &nbsp; <span class="re0">$mon</span> += <span class="nu0">1</span>;<br />
&nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$retval</span> = <a href="http://perldoc.perl.org/functions/sprintf.html"><span class="kw3">sprintf</span></a><span class="br0">&#40;</span><span class="st0">&quot;$year<span class="es0">\-</span>%02d<span class="es0">\-</span>%02d %02d:%02d:%02d&quot;</span>,<span class="re0">$mon</span>,<span class="re0">$mday</span>,<span class="re0">$hour</span>,<span class="re0">$min</span>,<span class="re0">$sec</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="re0">$retval</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>
<p>Example: </p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">#!/usr/bin/perl </span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> gettime<span class="br0">&#40;</span><span class="br0">&#41;</span>,<span class="st0">&quot;<span class="es0">\n</span>&quot;</span>;<br />
&nbsp;</div>
<p>returns:</p>
<div class="dean_ch" style="white-space: wrap;">
2009-05-27 07:18:43<br />
&nbsp;</div>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=57&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/27/sub-routine-gettime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hiding your STDIN</title>
		<link>http://mikerochford.com/blog/2009/05/26/hiding-your-stdin/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/26/hiding-your-stdin/#comments</comments>
		<pubDate>Tue, 26 May 2009 20:49:27 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=46</guid>
		<description><![CDATA[Ever write a script that you have to enter a elevated users password? or even your own? Check this out. #!/usr/bin/perl use Term::ReadKey; print &#34;Please enter your username: &#34;; chomp&#40;my $username = &#60;STDIN&#62;&#41;; print &#34;Please enter your password for $username: &#34;; ReadMode&#40;'noecho'&#41;; chomp&#40;my $password = ReadLine&#40;0&#41;&#41;; ReadMode&#40;'normal'&#41;; #for example only. You shouldn't print this... print [...]]]></description>
			<content:encoded><![CDATA[<p>Ever write a script that you have to enter a elevated users password? or even your own? Check this out.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">#!/usr/bin/perl</span><br />
<span class="kw2">use</span> Term::<span class="me2">ReadKey</span>;<br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;Please enter your username: &quot;</span>;<br />
<a href="http://perldoc.perl.org/functions/chomp.html"><span class="kw3">chomp</span></a><span class="br0">&#40;</span><span class="kw1">my</span> <span class="re0">$username</span> = <span class="re4">&lt;STDIN&gt;</span><span class="br0">&#41;</span>; <br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;Please enter your password for $username: &quot;</span>;<br />
ReadMode<span class="br0">&#40;</span><span class="st0">'noecho'</span><span class="br0">&#41;</span>;<br />
<a href="http://perldoc.perl.org/functions/chomp.html"><span class="kw3">chomp</span></a><span class="br0">&#40;</span><span class="kw1">my</span> <span class="re0">$password</span> = ReadLine<span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
ReadMode<span class="br0">&#40;</span><span class="st0">'normal'</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">#for example only. You shouldn't print this...</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;<span class="es0">\n</span>You entered $username for a username and $password for a password!!<span class="es0">\n</span>&quot;</span>;<br />
&nbsp;</div>
<p>Using Term:ReadKey you can disable echo for STDOUT. This way no one will see your password from over your shoulder.</p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=46&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/26/hiding-your-stdin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing gallery2 using the API to return information about a gallery</title>
		<link>http://mikerochford.com/blog/2009/05/26/accessing-gallery2-using-the-api-to-return-information-about-a-gallery/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/26/accessing-gallery2-using-the-api-to-return-information-about-a-gallery/#comments</comments>
		<pubDate>Tue, 26 May 2009 18:18:51 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=34</guid>
		<description><![CDATA[I designed a website for a friend to sell a litter of puppies. He wanted a simple site that had galleries for each dog and one for the litter. I didn't want to maintain the site at all so I used a lot of pre built software. I chose to use Gallery2 to do all [...]]]></description>
			<content:encoded><![CDATA[<p>I designed a website for a friend to sell a litter of puppies. He wanted a simple site that had galleries for each dog and one for the litter. I didn't want to maintain the site at all so I used a lot of pre built software. I chose to use <a href="http://gallery.menalto.com/">Gallery2</a> to do all the picture stuff.  It did everything I wanted (resize,rotate,etc). I didn't like how it looked though. I wanted to just have it do the back end stuff and I wanted to design the layout. To do this all I needed was the urls to access the images. Below is a function I wrote that will output all the information of a picture and its uri.</p>
<p>The script is located <a href="http://mikerochford.com/code/php/gallery2_to_array.php">here</a></p>
<p>which outputs:</p>
<pre>
Array
(
    [0] =&gt; Array
        (
            [title] =&gt; IMG_0028.JPG
            [width] =&gt; 2272
            [height] =&gt; 1704
            [large_picture] =&gt; /p/d/71-1/IMG_0028.JPG
            [thumb_picture] =&gt; /p/d/72-2/IMG_0028.JPG
            [resized_picture] =&gt; Array
                (
                    [0] =&gt; /p/d/73-2/IMG_0028.JPG
                    [1] =&gt; /p/d/74-2/IMG_0028.JPG
                    [2] =&gt; /p/d/75-2/IMG_0028.JPG
                )

        )

    [1] =&gt; Array
        (
            [title] =&gt; IMG_0029.JPG
            [width] =&gt; 2272
            [height] =&gt; 1704
            [large_picture] =&gt; /p/d/77-1/IMG_0029.JPG
            [thumb_picture] =&gt; /p/d/78-2/IMG_0029.JPG
            [resized_picture] =&gt; Array
                (
                    [0] =&gt; /p/d/79-2/IMG_0029.JPG
                    [1] =&gt; /p/d/80-2/IMG_0029.JPG
                    [2] =&gt; /p/d/81-2/IMG_0029.JPG
                )

        )
)
</pre>
<p>You will need to modify the paths in the function to your installation.</p>
<p>A side note... To find gallery ids you will need to to run the following query.</p>
<div class="dean_ch" style="white-space: wrap;">mysql&gt; <span class="kw1">SELECT</span> g2_id,g2_title <span class="kw1">FROM</span> g2_Item <span class="kw1">WHERE</span> g2_canContainChildren=<span class="nu0">1</span>;</div>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=34&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/26/accessing-gallery2-using-the-api-to-return-information-about-a-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto access an array that is in a hash</title>
		<link>http://mikerochford.com/blog/2009/05/26/howto-access-an-array-that-is-in-a-hash/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/26/howto-access-an-array-that-is-in-a-hash/#comments</comments>
		<pubDate>Tue, 26 May 2009 16:38:06 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=29</guid>
		<description><![CDATA[Say you have a hash element that contains an array and you want to loop through the array set. You usually have these types of data sets when you are trying to gather data. example: We will use the following code to build the hash: #!/usr/bin/perl use Data::Dumper; my %data_set; $data_set{'users'} = (); $data_set{'users'}[0] = [...]]]></description>
			<content:encoded><![CDATA[<p>Say you have a hash element that contains an array and you want to loop through the array set. You usually have these types of data sets when you are trying to gather data. </p>
<p>example:<br />
We will use the following code to build the hash:<br />
<code><br />
#!/usr/bin/perl<br />
use Data::Dumper;<br />
my %data_set;<br />
$data_set{'users'} = ();<br />
$data_set{'users'}[0] = "testA";<br />
$data_set{'users'}[1] = "testB";<br />
$data_set{'users'}[2] = "testC";<br />
$data_set{'users'}[3] = "testD";<br />
$data_set{'users'}[4] = "testE";<br />
$data_set{'users'}[5] = "testF";<br />
print Dumper(%data_set);<br />
</code></p>
<p>Output:<br />
<code><br />
$VAR1 = 'users';<br />
$VAR2 = [<br />
          'testA',<br />
          'testB',<br />
          'testC',<br />
          'testD'<br />
        ];<br />
</code></p>
<p>Now that we know the hash element is populated we want to access each array element. This can be done with making some crazy counter in a while loop. Check it out.<br />
<code><br />
foreach my $user (@{$data_set{'users'}}){<br />
    print $user,"\n";<br />
}<br />
</code></p>
<p>Now knowing you can access a array with in a hash using @{<hash_element>}  you can push,pop,splice and shift on the array that is in a hash. </p>
<p>Here is the same script above but using push:<br />
<code><br />
#!/usr/bin/perl<br />
use Data::Dumper;<br />
my %data_set;<br />
$data_set{'users'} = ();<br />
push(@{$data_set{'users'}},"testA");<br />
push(@{$data_set{'users'}},"testB");<br />
push(@{$data_set{'users'}},"testC");<br />
push(@{$data_set{'users'}},"testD");</p>
<p>foreach my $user (@{$data_set{'users'}}){<br />
    print $user,"\n";<br />
}</code></p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=29&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/26/howto-access-an-array-that-is-in-a-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto push a hash onto an array</title>
		<link>http://mikerochford.com/blog/2009/05/26/howto-push-a-hash-onto-an-array/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/26/howto-push-a-hash-onto-an-array/#comments</comments>
		<pubDate>Tue, 26 May 2009 16:19:19 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=26</guid>
		<description><![CDATA[This information was giving to me by my friend Matt use Data::Dumper; my @array; push @array, {'key1' => 'value1', 'key2' => 'value2'}; push @array, {'key1' => 'value1', 'key2' => 'value2'}; push @array, {'key1' => 'value1', 'key2' => 'value2'}; print Dumper(@array); Will give you: $VAR1 = { 'key2' => 'value2', 'key1' => 'value1' }; $VAR2 = [...]]]></description>
			<content:encoded><![CDATA[<p>This information was giving to me by my friend <a href="http://www.popmartian.com/tipsntricks/2008/08/12/perl-howto-push-a-hash-onto-an-array/" target="_blank">Matt</a><br />
use Data::Dumper;<br />
my @array;<br />
push @array, {'key1' => 'value1', 'key2' => 'value2'};<br />
push @array, {'key1' => 'value1', 'key2' => 'value2'};<br />
push @array, {'key1' => 'value1', 'key2' => 'value2'};<br />
print Dumper(@array);</p>
<p>Will give you:</p>
<p>$VAR1 = {<br />
'key2' => 'value2',<br />
'key1' => 'value1'<br />
};<br />
$VAR2 = {<br />
'key2' => 'value2',<br />
'key1' => 'value1'<br />
};<br />
$VAR3 = {<br />
'key2' => 'value2',<br />
'key1' => 'value1'<br />
};</p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=26&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/26/howto-push-a-hash-onto-an-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Finding a hostheader in IIS using Perl and Win32::OLE</title>
		<link>http://mikerochford.com/blog/2009/05/26/finding-a-hostheader-in-iis-using-perl-and-win32ole/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/26/finding-a-hostheader-in-iis-using-perl-and-win32ole/#comments</comments>
		<pubDate>Tue, 26 May 2009 15:58:25 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=22</guid>
		<description><![CDATA[There is no easy way to find a host header in IIS. Unless you think clicking on each site is easy. I have found it difficult to find them in large installations. I wrote a script that will go through each site on the server and look at the host headers and then if found [...]]]></description>
			<content:encoded><![CDATA[<p>There is no easy way to find a host header in IIS. Unless you think clicking on each site is easy. I have found it difficult to find them in large installations. I wrote a script that will go through each site on the server and look at the host headers and then if found it will print the Site comment. You then use the site comment to find the main site in the MMC. </p>
<p><a href="http://mikerochford.com/code/perl/find_hostheader_iis.pl">Here</a> is the script.</p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=22&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/26/finding-a-hostheader-in-iis-using-perl-and-win32ole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing all directory paths in Microsoft IIS/Active Directory using perl and WIN32::OLE</title>
		<link>http://mikerochford.com/blog/2009/05/26/changing-all-directory-paths-in-microsoft-iisactive-directory-using-perl-and-win32ole/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://mikerochford.com/blog/2009/05/26/changing-all-directory-paths-in-microsoft-iisactive-directory-using-perl-and-win32ole/#comments</comments>
		<pubDate>Tue, 26 May 2009 15:13:00 +0000</pubDate>
		<dc:creator>mrochford</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mikerochford.com/blog/?p=14</guid>
		<description><![CDATA[I was put in charge of a filer migration from a old netapp f810 to a new netapp 3040 cluster. One of the systems we have that used the netapp backend was a web cluster running MS Windows 2003. When it was first built it was using a cifs shares by system name (ie: \\f810..tld\customer-home). [...]]]></description>
			<content:encoded><![CDATA[<p>I was put in charge of a filer migration from a old netapp f810 to a new netapp 3040 cluster. One of the systems we have that used the netapp backend was a web cluster running MS Windows 2003. When it was first built it was using a cifs shares by system name (ie: \\f810.<somedomainname>.tld\customer-home). This is great if you never changed filers but a poor idea on our part. In theory you could have just changed the record to point at the new filer, but that was a temporary fix. We wanted to change the path completely to a arbitrary  name like "web".  This will allow us to change it to any back end device no matter what it is. I like to do things programmaticly so below are the two scripts I used to get the job done. You will need to modify these script to fit your needs (ie: Paths).</p>
<p>Bulk IIS path change script: <a href="http://mikerochford.com/code/perl/bulk_IIS_path_change.pl">Link</a></p>
<p>Bulk Active Directory change script: <a href="http://mikerochford.com/code/perl/bulk_AD_path_change.pl">Link</a></p>
<img src="http://mikerochford.com/blog/?ak_action=api_record_view&id=14&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mikerochford.com/blog/2009/05/26/changing-all-directory-paths-in-microsoft-iisactive-directory-using-perl-and-win32ole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

