<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>JustynShull.com</title>
	
	<link>http://justynshull.com</link>
	<description>I Am Justyn</description>
	<lastBuildDate>Thu, 11 Aug 2011 03:51:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Justynshull" /><feedburner:info uri="justynshull" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Automated off-site Linux Backups using Duply and Duplicity</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/0pEdSC-MZYk/</link>
		<comments>http://justynshull.com/2011/08/automated-off-site-linux-backups-using-duply-and-duplicity/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 04:55:17 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[duply]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=154</guid>
		<description><![CDATA[Off-site backups are important, and even though I know this, I rarely implement them in my own servers. Lately, I&#8217;ve been setting up rsnapshot to do hourly and daily backups locally(to the same server), and I only do manual backups to remote servers occasionally. I decided to install duply on all of my servers/virtual machines(that [...]]]></description>
			<content:encoded><![CDATA[<p>Off-site backups are important, and even though I know this, I rarely implement them in my own servers.   Lately, I&#8217;ve been setting up rsnapshot to do hourly and daily backups locally(to the same server), and I only do manual backups to remote servers occasionally.   I decided to install duply on all of my servers/virtual machines(that I care about) and have them back up to a single backup server.    This backup server will also do daily encrypted backups to Amazon S3, effectively giving me 3 redundant layers of backups.  </p>
<p>If you haven&#8217;t heard of <a href="http://duplicity.nongnu.org/">Duplicity</a> or <a href="http://duply.net/">Duply</a> before, Duply is basically a wrapper for Duplicity which makes it easier to manage.   Duplicity itself is similar to rsnapshot except, it uses tar to efficiently store differences between backups (instead of hardlinks).   Here&#8217;s the description from the <a href="http://duplicity.nongnu.org/duplicity.1.html">man page</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Duplicity incrementally backs up files and directory by 
encrypting tar-format volumes with GnuPG and uploading 
them to a remote <span style="color: #7a0874; font-weight: bold;">&#40;</span>or <span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">file</span> server. Currently <span style="color: #7a0874; font-weight: bold;">local</span>, 
<span style="color: #c20cb9; font-weight: bold;">ftp</span>, ssh<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">scp</span>, rsync, WebDAV, WebDAVs, HSi and Amazon S3 backends 
are available. Because duplicity uses librsync, the incremental 
archives are space efficient and only record the parts of files 
that have changed since the <span style="color: #c20cb9; font-weight: bold;">last</span> backup. Currently duplicity 
supports deleted files, full Unix permissions, directories, 
symbolic links, fifos, etc., but not hard links.</pre></div></div>

<p>I wrote this mainly as a reference for myself when I need to set duply up on another server, but it might be useful for others as well.  </p>
<p><strong>CentOS 5 / 6 Instructions</strong></p>
<p><strong>Install the <a href="http://fedoraproject.org/wiki/EPEL" title="EPEL Repository" target="_blank">EPEL</a> repo:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#Cent 6:</span>
rpm <span style="color: #660033;">-Uvh</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedoraproject.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>epel-release-<span style="color: #000000;">6</span>-<span style="color: #000000;">5</span>.noarch.rpm
<span style="color: #666666; font-style: italic;">#Cent 5:</span>
rpm <span style="color: #660033;">-Uvh</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedoraproject.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>epel-release-<span style="color: #000000;">5</span>-<span style="color: #000000;">4</span>.noarch.rpm</pre></div></div>

<p><strong>Install duplicity:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #660033;">--enablerepo</span>=epel <span style="color: #c20cb9; font-weight: bold;">install</span> duplicity</pre></div></div>

<p><strong>Install duply:</strong><br />
Get the URL for the latest version here: <a href="http://duply.net/?title=Duply-downloads">http://duply.net/?title=Duply-downloads</a><br />
download it to your server, extract it, and copy duply to /usr/local/bin/duply then chmod +x /usr/local/bin/duply</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dev.justynshull.com<span style="color: #000000; font-weight: bold;">/</span>duply_1.5.5.1.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf duply_1.5.5.1.tgz
<span style="color: #c20cb9; font-weight: bold;">cp</span> duply_1.5.5.1<span style="color: #000000; font-weight: bold;">/</span>duply <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>duply
<span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>duply</pre></div></div>

<p><em>Note:  Bug <a href="https://bugzilla.redhat.com/show_bug.cgi?id=675234" title="675234" target="_blank">675234</a> is a request to have duply put into the Fedora repo, but there is also a .spec and source rpm if you wish to build an rpm yourself. </em> </p>
<p><strong>Setup a basic Duply profile</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>duply <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">700</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>duply
duply testvm1 create</pre></div></div>

<p><em>Note: If you don&#8217;t create /etc/duply, then it will use $HOME/.duply by default.</em>  </p>
<p>Take a look at the options in /etc/duply/testvm1/conf and configure it to your liking.  There are many different TARGET formats you can use, including ssh, rsync over ssh, ftp, and even amazon&#8217;s S3.   You can view them all here: <a href="http://duplicity.nongnu.org/duplicity.1.html#sect7">URL Formats</a><br />
This is what mine usually look like(without encryption) using rsync over ssh:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># egrep -v '^#|^$' /etc/duply/testvm1/conf</span>
<span style="color: #007800;">GPG_KEY</span>=<span style="color: #ff0000;">'disabled'</span>
<span style="color: #007800;">TARGET</span>=<span style="color: #ff0000;">'rsync://backups.justynshull.com//home/testvm1/backups'</span>
<span style="color: #007800;">TARGET_USER</span>=<span style="color: #ff0000;">'testvm1'</span>
<span style="color: #007800;">SOURCE</span>=<span style="color: #ff0000;">'/'</span>
<span style="color: #007800;">MAX_AGE</span>=3M
<span style="color: #007800;">MAX_FULL_BACKUPS</span>=<span style="color: #000000;">3</span>
<span style="color: #007800;">MAX_FULLBKP_AGE</span>=30D
<span style="color: #007800;">VOLSIZE</span>=<span style="color: #000000;">3500</span>
<span style="color: #007800;">DUPL_PARAMS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUPL_PARAMS</span> --full-if-older-than <span style="color: #007800;">$MAX_FULLBKP_AGE</span> &quot;</span>
<span style="color: #007800;">DUPL_PARAMS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUPL_PARAMS</span> --volsize <span style="color: #007800;">$VOLSIZE</span> &quot;</span>
<span style="color: #007800;">DUPL_PARAMS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DUPL_PARAMS</span> --include=/etc <span style="color: #000099; font-weight: bold;">\
</span>        --include=/home <span style="color: #000099; font-weight: bold;">\
</span>        --include=/root <span style="color: #000099; font-weight: bold;">\
</span>        --include=/var/www <span style="color: #000099; font-weight: bold;">\
</span>        --include=/var/lib/mysql <span style="color: #000099; font-weight: bold;">\
</span>        --include=/var/log <span style="color: #000099; font-weight: bold;">\
</span>        --exclude=/** &quot;</span></pre></div></div>

<p>I prefer to use multiple &#8211;include= options rather than fill /etc/duply/testvm1/exclude with every directory I *don&#8217;t* want backed up.   Either way will work though.   Also, if you&#8217;re going to use rsync or ssh/sftp, I&#8217;d recommend setting up the backup server so that you can log in with ssh keys and generate a separate key for each server you&#8217;re backing up from.   You&#8217;ll also have to have ssh&#8217;d into the backup server as that user at least once to avoid errors about the target host key. </p>
<p><strong>Encryption</strong><br />
Duply/Duplicity supports using GPG to encrypt volumes before uploading them to the remote server, and the easiest way to enable encryption is by putting this in your conf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#comment out #GPG_KEY from earlier</span>
<span style="color: #666666; font-style: italic;">#GPG_KEY='disabled'</span>
<span style="color: #007800;">GPG_PW</span>=<span style="color: #ff0000;">'secret_password'</span></pre></div></div>

<p>This will encrypt the volumes using the passphrase you put in GPG_PW, but you can refer to the documentation for how to set it up to use actual gpg keys. </p>
<p><strong>Including MySQL Backups</strong><br />
If you&#8217;re running mysql on the server, you should consider adding something similar to this to /etc/testvm1/<strong>pre</strong>, which gets run automatically by duply, to dump all databases before backing up the server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-pv</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>db_backups
<span style="color: #000000; font-weight: bold;">for</span> db <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'show databases'</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'information_schema'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">do</span>
        mysqldump <span style="color: #660033;">-uroot</span> <span style="color: #007800;">$db</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>db_backups<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$db</span>.sql;
        <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>;
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p><strong>Run your first backup:<br />
</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 backup</pre></div></div>

<p><strong>Automate it</strong><br />
If all goes well(no errors), then you should be okay to set up a cronjob to run duply backup.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># crontab -l</span>
<span style="color: #000000;">30</span>      <span style="color: #000000;">3</span>       <span style="color: #000000; font-weight: bold;">*</span>       <span style="color: #000000; font-weight: bold;">*</span>       <span style="color: #000000; font-weight: bold;">*</span>       <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>duply testvm1 backup
<span style="color: #000000;">30</span>      <span style="color: #000000;">5</span>       <span style="color: #000000; font-weight: bold;">*</span>       <span style="color: #000000; font-weight: bold;">*</span>       sun       <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>duply testvm1 backup_verify_purge <span style="color: #660033;">--force</span></pre></div></div>

<p><strong>Purge Old Backups</strong><br />
If you use the above crontab, the 2nd line will run once a week, purging old backups from the remote server.   If you&#8217;re worried about keeping too many backups, you might want to increase how often this runs and also decrease the options in the duply profile configuration.</p>
<p><strong>Verify Backups</strong><br />
Duply makes it easy to see what you&#8217;re currently backing up.<br />
To see a list of backups stored on the remote server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 status</pre></div></div>

<p>To see a list of files that have changed since the last backup:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 verify</pre></div></div>

<p>List all files in a backup yesterday(leave out to show latest):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 list 1D</pre></div></div>

<p><strong>Restore Backups</strong><br />
It&#8217;s just as easy to restore complete or partial backups.<br />
Restore the entire latest backup to /tmp/restore:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 restore <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>restore</pre></div></div>

<p>Restore backup from 7 days ago to /tmp/restore:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 restore <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>restore 1W</pre></div></div>

<p>Restore single file or directory to /tmp/restore:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 fetch home<span style="color: #000000; font-weight: bold;">/</span>justyns <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>restore
<span style="color: #666666; font-style: italic;">#When using 'fetch', make sure you leave off the leading slash.</span></pre></div></div>

<p>Restore a file from a month ago:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">duply testvm1 fetch home<span style="color: #000000; font-weight: bold;">/</span>justyns<span style="color: #000000; font-weight: bold;">/</span>plans_for_world_dom.txt <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>justyns<span style="color: #000000; font-weight: bold;">/</span>plans_for_world_dom.txt 1M</pre></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=0pEdSC-MZYk:kG1TRChZ7jc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=0pEdSC-MZYk:kG1TRChZ7jc:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=0pEdSC-MZYk:kG1TRChZ7jc:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=0pEdSC-MZYk:kG1TRChZ7jc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=0pEdSC-MZYk:kG1TRChZ7jc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=0pEdSC-MZYk:kG1TRChZ7jc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=0pEdSC-MZYk:kG1TRChZ7jc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=0pEdSC-MZYk:kG1TRChZ7jc:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/0pEdSC-MZYk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2011/08/automated-off-site-linux-backups-using-duply-and-duplicity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://justynshull.com/2011/08/automated-off-site-linux-backups-using-duply-and-duplicity/</feedburner:origLink></item>
		<item>
		<title>Xen file-based vs LVM-based disk images (benchmarks)</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/wXQP6QgP5Hg/</link>
		<comments>http://justynshull.com/2011/05/xen-file-based-vs-lvm-based-disk-images-benchmarks/#comments</comments>
		<pubDate>Sun, 08 May 2011 05:06:23 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=133</guid>
		<description><![CDATA[I&#8217;ve been messing around a lot with Xen lately and have seen several different articles and forum posts debating the advantages over using file-based disk images, like /mnt/xen/VM01-disk.img, versus giving the VM direct access to a LVM partition. So, I ran a few simple tests on my own to determine what would be best for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been messing around a lot with Xen lately and have seen several different articles and forum posts debating the advantages over using file-based disk images, like /mnt/xen/VM01-disk.img, versus giving the VM direct access to a LVM partition.   So, I ran a few simple tests on my own to determine what would be best for my machine.  </p>
<p>Dom-0 is using four 1.5tb 7200rpm seagate drives in a software Raid-10, /dev/md2.  Both Dom0 and DomU have 1gb of ram and are using ext3.   Xen is using mainly default settings with the default scheduler.  </p>
<p><strong>From DomU with the DomU image being file-based on ext3 Dom-0 fs<br />
DomU has 1gb ram</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>DomU<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=tmpfile.bin bs=1024k count=10k</span>
<span style="color: #000000;">10240</span>+<span style="color: #000000;">0</span> records <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #000000;">10240</span>+<span style="color: #000000;">0</span> records out
<span style="color: #000000;">10737418240</span> bytes <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span> GB<span style="color: #7a0874; font-weight: bold;">&#41;</span> copied, <span style="color: #000000;">192.556</span> seconds, <span style="color: #000000;">55.8</span> MB<span style="color: #000000; font-weight: bold;">/</span>s</pre></div></div>

<p><strong>From Dom0 on the same filesystem where above DomU&#8217;s image is stored.<br />
Dom0 has 1gb ram</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>Dom0<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=tmpfile.bin bs=1024k count=10k</span>
<span style="color: #000000;">10240</span>+<span style="color: #000000;">0</span> records <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #000000;">10240</span>+<span style="color: #000000;">0</span> records out
<span style="color: #000000;">10737418240</span> bytes <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span> GB<span style="color: #7a0874; font-weight: bold;">&#41;</span> copied, <span style="color: #000000;">72.0743</span> seconds, <span style="color: #000000;">149</span> MB<span style="color: #000000; font-weight: bold;">/</span>s</pre></div></div>

<p>I was really surprised to see there was this much of a difference between Dom0 and DomU disk access.    Several tests were run, and the results didn&#8217;t vary much at all.  </p>
<p>I also ran a bonnie++ benchmark on both Dom0 and DomU.<br />
Dom0:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> Version  <span style="color: #000000;">1.96</span>       <span style="color: #660033;">------Sequential</span> Output------ <span style="color: #660033;">--Sequential</span> Input- <span style="color: #660033;">--Random-</span>
Concurrency   <span style="color: #000000;">1</span>     <span style="color: #660033;">-Per</span> Chr- <span style="color: #660033;">--Block--</span> <span style="color: #660033;">-Rewrite-</span> <span style="color: #660033;">-Per</span> Chr- <span style="color: #660033;">--Block--</span> <span style="color: #660033;">--Seeks--</span>
Machine        Size K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP
razer.justynshul 2G   <span style="color: #000000;">419</span>  <span style="color: #000000;">98</span> <span style="color: #000000;">144092</span>  <span style="color: #000000;">21</span> <span style="color: #000000;">68102</span>   <span style="color: #000000;">2</span>   <span style="color: #000000;">882</span>  <span style="color: #000000;">97</span> <span style="color: #000000;">183977</span>   <span style="color: #000000;">2</span> <span style="color: #000000;">699.3</span>   <span style="color: #000000;">0</span>
Latency             60846us    1136ms     381ms   53632us   98757us     371ms
Version  <span style="color: #000000;">1.96</span>       <span style="color: #660033;">------Sequential</span> Create------ <span style="color: #660033;">--------Random</span> Create--------
razer.justynshull.c <span style="color: #660033;">-Create--</span> <span style="color: #660033;">--Read---</span> <span style="color: #660033;">-Delete--</span> <span style="color: #660033;">-Create--</span> <span style="color: #660033;">--Read---</span> <span style="color: #660033;">-Delete--</span>
              files  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP
                 <span style="color: #000000;">16</span> +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
Latency                87us     447us     486us     694us      34us      41us
<span style="color: #000000;">1.96</span>,<span style="color: #000000;">1.96</span>,razer.justynshull.com,<span style="color: #000000;">1</span>,<span style="color: #000000;">1304536826</span>,2G,,<span style="color: #000000;">419</span>,<span style="color: #000000;">98</span>,<span style="color: #000000;">144092</span>,<span style="color: #000000;">21</span>,<span style="color: #000000;">68102</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">882</span>,<span style="color: #000000;">97</span>,<span style="color: #000000;">183977</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">699.3</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">16</span>,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,60846us,1136ms,381ms,53632us,98757us,371ms,87us,447us,486us,694us,34us,41us</pre></div></div>

<p>DomU:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Version  <span style="color: #000000;">1.96</span>       <span style="color: #660033;">------Sequential</span> Output------ <span style="color: #660033;">--Sequential</span> Input- <span style="color: #660033;">--Random-</span>
Concurrency   <span style="color: #000000;">1</span>     <span style="color: #660033;">-Per</span> Chr- <span style="color: #660033;">--Block--</span> <span style="color: #660033;">-Rewrite-</span> <span style="color: #660033;">-Per</span> Chr- <span style="color: #660033;">--Block--</span> <span style="color: #660033;">--Seeks--</span>
Machine        Size K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP
razer2.justynshu 2G   <span style="color: #000000;">446</span>  <span style="color: #000000;">99</span> <span style="color: #000000;">94601</span>  <span style="color: #000000;">12</span> <span style="color: #000000;">62259</span>   <span style="color: #000000;">1</span>  <span style="color: #000000;">1006</span>  <span style="color: #000000;">99</span> <span style="color: #000000;">130897</span>   <span style="color: #000000;">1</span> <span style="color: #000000;">182.1</span>   <span style="color: #000000;">0</span>
Latency             64057us    1771ms    2969ms   19222us    1887ms     348ms
Version  <span style="color: #000000;">1.96</span>       <span style="color: #660033;">------Sequential</span> Create------ <span style="color: #660033;">--------Random</span> Create--------
razer2.justynshull. <span style="color: #660033;">-Create--</span> <span style="color: #660033;">--Read---</span> <span style="color: #660033;">-Delete--</span> <span style="color: #660033;">-Create--</span> <span style="color: #660033;">--Read---</span> <span style="color: #660033;">-Delete--</span>
              files  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP
                 <span style="color: #000000;">16</span> +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
Latency             44083us     395us     410us      59us      10us      66us
<span style="color: #000000;">1.96</span>,<span style="color: #000000;">1.96</span>,razer2.justynshull.com,<span style="color: #000000;">1</span>,<span style="color: #000000;">1304538856</span>,2G,,<span style="color: #000000;">446</span>,<span style="color: #000000;">99</span>,<span style="color: #000000;">94601</span>,<span style="color: #000000;">12</span>,<span style="color: #000000;">62259</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">1006</span>,<span style="color: #000000;">99</span>,<span style="color: #000000;">130897</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">182.1</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">16</span>,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,64057us,1771ms,2969ms,19222us,1887ms,348ms,44083us,395us,410us,59us,10us,66us</pre></div></div>

<h3>Round 2 &#8211; LVM-based disk on DomU</h3>
<p>Here are the results of the same tests, except this time DomU is using LVM as the root disk instead of a file-based image.   It is still on the same exact hardware and drives/raid set-up.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>DomU<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=tmpfile.bin bs=1024k count=10k</span>
<span style="color: #000000;">10240</span>+<span style="color: #000000;">0</span> records <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #000000;">10240</span>+<span style="color: #000000;">0</span> records out
<span style="color: #000000;">10737418240</span> bytes <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span> GB<span style="color: #7a0874; font-weight: bold;">&#41;</span> copied, <span style="color: #000000;">123.34</span> seconds, <span style="color: #000000;">87.1</span> MB<span style="color: #000000; font-weight: bold;">/</span>s</pre></div></div>

<p>Bonnie++ test:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Version  <span style="color: #000000;">1.96</span>       <span style="color: #660033;">------Sequential</span> Output------ <span style="color: #660033;">--Sequential</span> Input- <span style="color: #660033;">--Random-</span>
Concurrency   <span style="color: #000000;">1</span>     <span style="color: #660033;">-Per</span> Chr- <span style="color: #660033;">--Block--</span> <span style="color: #660033;">-Rewrite-</span> <span style="color: #660033;">-Per</span> Chr- <span style="color: #660033;">--Block--</span> <span style="color: #660033;">--Seeks--</span>
Machine        Size K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP K<span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP
CentOS           2G   <span style="color: #000000;">444</span>  <span style="color: #000000;">99</span> <span style="color: #000000;">78784</span>   <span style="color: #000000;">6</span> <span style="color: #000000;">48588</span>   <span style="color: #000000;">1</span>   <span style="color: #000000;">957</span>  <span style="color: #000000;">97</span> <span style="color: #000000;">190338</span>   <span style="color: #000000;">1</span> <span style="color: #000000;">612.1</span>   <span style="color: #000000;">0</span>
Latency             18285us     433ms     306ms   33926us   48079us     456ms
Version  <span style="color: #000000;">1.96</span>       <span style="color: #660033;">------Sequential</span> Create------ <span style="color: #660033;">--------Random</span> Create--------
CentOS              <span style="color: #660033;">-Create--</span> <span style="color: #660033;">--Read---</span> <span style="color: #660033;">-Delete--</span> <span style="color: #660033;">-Create--</span> <span style="color: #660033;">--Read---</span> <span style="color: #660033;">-Delete--</span>
              files  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP  <span style="color: #000000; font-weight: bold;">/</span>sec <span style="color: #000000; font-weight: bold;">%</span>CP
                 <span style="color: #000000;">16</span> +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
Latency              6908us     386us     402us     433us      23us      33us
<span style="color: #000000;">1.96</span>,<span style="color: #000000;">1.96</span>,CentOS,<span style="color: #000000;">1</span>,<span style="color: #000000;">1304828315</span>,2G,,<span style="color: #000000;">444</span>,<span style="color: #000000;">99</span>,<span style="color: #000000;">78784</span>,<span style="color: #000000;">6</span>,<span style="color: #000000;">48588</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">957</span>,<span style="color: #000000;">97</span>,<span style="color: #000000;">190338</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">612.1</span>,<span style="color: #000000;">0</span>,<span style="color: #000000;">16</span>,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,18285us,433ms,306ms,33926us,48079us,456ms,6908us,386us,402us,433us,23us,33us</pre></div></div>

<p>I should re-run the bonnie tests with a large test size since these may be inaccurate with only 2g.  Going purely off of the dd results, using LVM is the way to go.<br />
The Sequential Output from bonnie++ is higher for the DomU using a file-based disk image, but that doesn&#8217;t match up to any of the dd tests on the same DomU.  When I have time, I&#8217;ll re-run the bonnie tests with larger file sizes to see if the results stay the same or not.  </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=wXQP6QgP5Hg:ruEM7EwNPOU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=wXQP6QgP5Hg:ruEM7EwNPOU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=wXQP6QgP5Hg:ruEM7EwNPOU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=wXQP6QgP5Hg:ruEM7EwNPOU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=wXQP6QgP5Hg:ruEM7EwNPOU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=wXQP6QgP5Hg:ruEM7EwNPOU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=wXQP6QgP5Hg:ruEM7EwNPOU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=wXQP6QgP5Hg:ruEM7EwNPOU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/wXQP6QgP5Hg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2011/05/xen-file-based-vs-lvm-based-disk-images-benchmarks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://justynshull.com/2011/05/xen-file-based-vs-lvm-based-disk-images-benchmarks/</feedburner:origLink></item>
		<item>
		<title>Create Your Own URL Shortener</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/ZwUtD0WH1Bg/</link>
		<comments>http://justynshull.com/2011/02/create-your-own-url-shortener/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 23:38:21 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shorturl]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=96</guid>
		<description><![CDATA[I don&#8217;t really pay attention to twitter that often,but I did notice more and more people are starting to use personalized url shorteners. There&#8217;s a lot of free services out there you can use, but if you have somewhere you can host a simple php script, why not make your own? I ended up buying [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t really pay attention to twitter that often,but I did notice more and more people are starting to use personalized url shorteners.   There&#8217;s a lot of free services out there you can use, but if you have somewhere you can host a simple php script, why not make your own?</p>
<p>I ended up buying <a href="http://iamj.us/tyn">iamj.us/tyn</a>, and that&#8217;s what I&#8217;m going to set this up on.   If I wanted to make things shorter, I could take off the /tyn  but then I dont think it&#8217;d make as much sense.   <a href="http://iamj.us/tyn11l">http://iamj.us/tyn11l</a> redirects back to this page, for example. If you need help picking out a short domain name, try out <a href="http://domai.nr">domai.nr</a>. </p>
<p>To create my own shortener, I decided just to use php&#8217;s <a href="http://php.net/manual/en/function.base-convert.php">base_convert</a> function which will convert to and from bases 2-36.    For a personal url shortener, you shouldn&#8217;t need more than base 36.   I did end up having to write a base 62 converter class for <a href="http://sh0tz.com">sh0tz</a> so that I can keep urls short, but that&#8217;s another post another time.  </p>
<p><strong>Create the Database</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">create</span> <span style="color: #990099; font-weight: bold;">database</span> iamjurl<span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">grant</span> <span style="color: #990099; font-weight: bold;">all</span> <span style="color: #990099; font-weight: bold;">privileges</span> <span style="color: #990099; font-weight: bold;">on</span> iamjurl.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">to</span> <span style="color: #008000;">'dbuser'</span>@<span style="color: #008000;">'localhost'</span> identified by <span style="color: #008000;">'password'</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> flush <span style="color: #990099; font-weight: bold;">privileges</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`urls`</span> <span style="color: #FF00FF;">&#40;</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #008000;">`id`</span> <span style="color: #999900; font-weight: bold;">int</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #008000;">`url`</span> <span style="color: #999900; font-weight: bold;">varchar</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">1024</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`id`</span><span style="color: #FF00FF;">&#41;</span>
    <span style="color: #CC0099;">-&gt;</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">ENGINE</span><span style="color: #CC0099;">=</span>MyISAM <span style="color: #990099; font-weight: bold;">DEFAULT</span> <span style="color: #FF9900; font-weight: bold;">CHARSET</span><span style="color: #CC0099;">=</span>utf8<span style="color: #000033;">;</span></pre></div></div>

<p>Super simple.  One column for the url id, and one column for the url.   You could add more fields for tracking views and that sort of thing if you wanted.  </p>
<p><strong>Write the PHP Guts</strong><br />
First, we need the ability to insert a new url into the database and echo out the short url.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new'</span><span style="color: #009900;">&#93;</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;">//Somebody called /url.php?new to create a new short url</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</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;">//If url= isnt set to anything, then we don't really care since theres no link to add</span>
                <span style="color: #000088;">$dbcon</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error connecting to db: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'INSERT INTO urls (url) VALUES (&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;);'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid query: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//the new url's added to the database, now we get the auto_increment id and base_convert it to base36</span>
                <span style="color: #000088;">$shorturl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">base_convert</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">36</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//and echo it out to the browser</span>
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$baseurl}</span><span style="color: #006699; font-weight: bold;">{$shorturl}</span> <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That should be fairly self-explanatory with the comments in there.    So now you can go to <strong>http://iamj.us/url.php?new&#038;url=http://google.com</strong> and it will add a new row to the urls table with <em>http://google.com</em> in it.   It&#8217;ll also echo <strong>https://iamj.us/tyn1o</strong> or something similar to the screen.  Whatever the baseurl is plus the base36 id of that row.  </p>
<p>Now, if we actually want to be able to go to that link using a short url?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'go'</span><span style="color: #009900;">&#93;</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;">//somebody got redirected either with .htaccess or went directly to url.php?go=</span>
        <span style="color: #000088;">$dbcon</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error connecting to db: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//take go= and convert it back to base10 to match the mysql row id</span>
        <span style="color: #000088;">$shortid</span> <span style="color: #339933;">=</span> <span style="color: #990000;">base_convert</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'go'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">36</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'SELECT url FROM urls WHERE id=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$shortid</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;;'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid query: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//While testing this, it's easier to echo $query out and make sure you're getting the right url</span>
        <span style="color: #666666; font-style: italic;">//returned from mysql</span>
        <span style="color: #666666; font-style: italic;">//      echo $query;</span>
        <span style="color: #666666; font-style: italic;">//      echo mysql_result($result,0);</span>
        <span style="color: #666666; font-style: italic;">//if we're not testing, then just redirect the user to the url we received from mysql</span>
        <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Again, this should be self-explanatory.   Go to <strong>/url.php?go=o </strong> and it converts the letter o to base10 which turns into 24, and then redirects the browser to the url stored in mysql with the id of 24.   If you wanted to track views or other statistics, this would be the spot to do so(before redirecting.)</p>
<p>We don&#8217;t actually want to use /url.php?go=.   We want to use(in my case) /tynXXXX.    We do this with a simple mod_rewrite rule.    This is what my .htaccess looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-d
<span style="color: #00007f;">RewriteRule</span> ^(tyn)(.*)$ /url.php?go=$2 [NC,L]</pre></div></div>

<p>The RewriteRule line would need changed if you&#8217;re not going to use a prefix to the shorturl(/xxx instead of /tynXXX).    ^(.*) should be sufficient, and change $2 to $1.   </p>
<p><strong>Security</strong><br />
As it is right now, there&#8217;s not much security to this script.   You can rename url.php to something like ASDF089234fasdf.php if you want to use security through obscurity.  With an .htaccess, noone will know the actual filename of this script, and if you use the bookmarklet below you won&#8217;t have to remember it either.<br />
If you plan on letting other people use it, adding checks for duplicate urls and reusing the same id would be a good idea.   I&#8217;m already using <a href="http://us.php.net/manual/en/function.mysql-real-escape-string.php">mysql_real_escape_string</a> but it wouldn&#8217;t hurt to sanitize the input even further.  </p>
<p>Each time a row gets added, the id is only incremented by 1.  Meaning it&#8217;d be easy for someone to get one url and then start going forward or backward down your list of urls just by subtracting/adding 1(in base36) to the url.   To prevent this, try multiplying $shorturl by 303 or some other large odd number.   Run <a href="http://iamj.us/basetest.php">this code</a> to see what I mean:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
* basetest.php - Outputs a table showing how multiplying a number before base_converting it helps with obscurity.
* Author: Justyn Shull &lt;justyn@justynshull.com&gt;
*/</span>
<span style="color: #000088;">$magicnum</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">303</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Normal&lt;/td&gt;&lt;td&gt;x303&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$i</span>&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;td&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">base_convert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">36</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;td&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">base_convert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">*</span><span style="color: #000088;">$magicnum</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">36</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/td&gt;&lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/table&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>See how the &#8216;normal&#8217; column is easy to decipher, but the &#8216;x303&#8242; column is a little more random?</p>
<p><strong>Bonus!</strong><br />
Adding an actual gui to this script would make things awesome, right?  Because you don&#8217;t want to urlencode URLs on your own and type in a long url everytime you want to make a short url.   I&#8217;d recommend displaying an input box if url isn&#8217;t set and having the form method set to get.   </p>
<p>Or you can do what I did, and just create a simple <a href="javascript:void(location.href='http://iamj.us/url.php?new&#038;url='+escape(location.href))">bookmarklet</a> like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">href</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'http://iamj.us/url.php?new&amp;url='</span><span style="color: #339933;">+</span>escape<span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Result</strong><br />
Go to <a href="http://iamj.us/url.php">http://iamj.us/url.php</a> to see what my end result looks like for now.   It&#8217;s essentially the same code in this post plus a few extras.   </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=ZwUtD0WH1Bg:z7r8x4BzBMU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=ZwUtD0WH1Bg:z7r8x4BzBMU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=ZwUtD0WH1Bg:z7r8x4BzBMU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=ZwUtD0WH1Bg:z7r8x4BzBMU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=ZwUtD0WH1Bg:z7r8x4BzBMU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=ZwUtD0WH1Bg:z7r8x4BzBMU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=ZwUtD0WH1Bg:z7r8x4BzBMU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=ZwUtD0WH1Bg:z7r8x4BzBMU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/ZwUtD0WH1Bg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2011/02/create-your-own-url-shortener/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://justynshull.com/2011/02/create-your-own-url-shortener/</feedburner:origLink></item>
		<item>
		<title>Installing and Updating WordPress via SVN</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/V5daCuY-OZo/</link>
		<comments>http://justynshull.com/2010/09/installing-and-updating-wordpress-via-svn/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 05:03:09 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=86</guid>
		<description><![CDATA[I have quite a few WordPress installations that I semi-manage on my server, and just recently realized how time consuming it is everytime a new version comes out.   WordPress does let you update it to the newest version directly from the admin interface which is definitely nice, but if you have several installations of [...]]]></description>
			<content:encoded><![CDATA[<p>I have quite a few <a href="http://wordpress.org/">WordPress</a> installations that I semi-manage on my server, and just recently realized how time consuming it is everytime a new version comes out.   WordPress does let you update it to the newest version directly from the admin interface which is definitely nice, but if you have several installations of WordPress you aren&#8217;t going to want to log in to every single one of them and click that update button.</p>
<p>One solution, and the one I decided on for now, is to use <a href="http://subversion.apache.org/">Subversion</a>.   Ever since 1.5, WordPress has been using subversion for its version control so of course they allow public read-only access to the subversion repository.   Whether you are already familiar with subversion or not, it is relatively easy to install WordPress using svn and then keep it up to date as well.</p>
<p>Here&#8217;s an example on my server:<br />
<code><br />
$cd /var/www/vhosts/testdomain.com/httpdocs/<br />
$svn co http://core.svn.wordpress.org/tags/3.0 .<br />
.....svn will download the 3.0 branch of wordpress to the current directory ...<br />
</code><br />
Be sure to include the period at the end of that svn checkout command so that it downloads wordpress to the directory you&#8217;re in.   Otherwise it will create a new directory named 3.0.   Once Subversion finishes checking out the branch, and assuming your permissions are all good then you can just go to http://testdomain.com/ and run the WordPress install script to put in your database info and whatnot.    You could also modify <strong>wp-config.php</strong> manually if you&#8217;re into that.</p>
<p>And to upgrade wordpress?    Easy!   You just need to switch the branch subversion has checked out currently.<br />
<code><br />
$cd /var/www/vhosts/testdomain.com/httpdocs/<br />
$svn sw http://core.svn.wordpress.org/tags/3.0.1/ .<br />
</code><br />
It will update all the files that need to be updated.   Depending on the release, you&#8217;ll probably need to go to <strong>http://&lt;wordpress install&gt;/wp-admin/upgrade.php</strong> once the files are updated.</p>
<p>Now with this, you could create a bash script to loop through all of your wordpress installation directories and run the svn switch command to update to the latest stable wordpress branch.    You can find a list of the current available branches here: <a href="http://core.svn.wordpress.org/tags/">http://core.svn.wordpress.org/tags</a>/</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=V5daCuY-OZo:QReURSuBsJc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=V5daCuY-OZo:QReURSuBsJc:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=V5daCuY-OZo:QReURSuBsJc:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=V5daCuY-OZo:QReURSuBsJc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=V5daCuY-OZo:QReURSuBsJc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=V5daCuY-OZo:QReURSuBsJc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=V5daCuY-OZo:QReURSuBsJc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=V5daCuY-OZo:QReURSuBsJc:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/V5daCuY-OZo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2010/09/installing-and-updating-wordpress-via-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://justynshull.com/2010/09/installing-and-updating-wordpress-via-svn/</feedburner:origLink></item>
		<item>
		<title>cdn test</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/cKEPPIibjvU/</link>
		<comments>http://justynshull.com/2010/09/cdn-test/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 02:28:50 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=81</guid>
		<description><![CDATA[Just testing the CDN to see if this image gets uploaded automatically like it should.]]></description>
			<content:encoded><![CDATA[<p><a href="http://justynshull.com/wp-content/uploads/2010/09/bra-virus-meme1.gif"><img class="alignnone size-medium wp-image-82" title="bra-virus-meme1" src="http://justynshull.com/wp-content/uploads/2010/09/bra-virus-meme1-230x300.gif" alt="" width="230" height="300" /></a></p>
<p>Just testing the CDN to see if this image gets uploaded automatically like it should.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=cKEPPIibjvU:jXO560jYX_0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=cKEPPIibjvU:jXO560jYX_0:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=cKEPPIibjvU:jXO560jYX_0:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=cKEPPIibjvU:jXO560jYX_0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=cKEPPIibjvU:jXO560jYX_0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=cKEPPIibjvU:jXO560jYX_0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=cKEPPIibjvU:jXO560jYX_0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=cKEPPIibjvU:jXO560jYX_0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/cKEPPIibjvU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2010/09/cdn-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://justynshull.com/2010/09/cdn-test/</feedburner:origLink></item>
		<item>
		<title>du2.php</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/DixtPv80Bvg/</link>
		<comments>http://justynshull.com/2010/08/du2-php/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 05:01:07 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=72</guid>
		<description><![CDATA[This is based off of du.php, and is basically the same thing except it lets you click on folders to navigate through the directory structure and see how much space each directory is taking up. It uses php&#8217;s shell_exec function to call the du utility on the directories it&#8217;s in. So if your host doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>This is based off of <a href="http://justynshull.com/2010/08/du-php-php-disk-usage-script/">du.php</a>, and is basically the same thing except it lets you click on folders to navigate through the directory structure and see how much space each directory is taking up.    </p>
<p>It uses php&#8217;s shell_exec function to call the du utility on the directories it&#8217;s in.   So if your host doesn&#8217;t allow you to use shell_exec, this isn&#8217;t going to work for you.    If they do allow shell_exec, but do not allow ssh access then this is perfect.   </p>
<p>You can view it <a href="https://justynshull.com/showscript.php?file=du2.php">here</a> as well.</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
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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Disk Usage Report&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">///////////////////////////////////////////////////////////</span>
<span style="color: #666666; font-style: italic;">//Disk Usage script v2                       ///</span>
<span style="color: #666666; font-style: italic;">//du2.php                          ///</span>
<span style="color: #666666; font-style: italic;">/////////////                         ///</span>
<span style="color: #666666; font-style: italic;">//Author:  Justyn Shull                    ///</span>
<span style="color: #666666; font-style: italic;">//E-mail:  justyn@justynshull.com           ///</span>
<span style="color: #666666; font-style: italic;">/////////////                      ///</span>
<span style="color: #666666; font-style: italic;">//based off my old du.php script:         ///</span>
<span style="color: #666666; font-style: italic;">//This lists the directories in $dir with the   ///</span>
<span style="color: #666666; font-style: italic;">//space they take up.  Not sorted, but allows  ///</span>
<span style="color: #666666; font-style: italic;">//you to click on a directory to navigate     ///</span>
<span style="color: #666666; font-style: italic;">////////////////////////////////////////////////</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/////TODO: Fix it so you don't end up with the full path you've taken</span>
<span style="color: #666666; font-style: italic;">//        eg:   du2.php?dir=../mail/../html/</span>
&nbsp;
<span style="color: #000088;">$time1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">True</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">chdir</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">chdir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$homedir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pwd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Home: <span style="color: #006699; font-weight: bold;">$homedir</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;dir&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #666666; font-style: italic;">//$dir = getenv('DOCUMENT_ROOT').&quot;/..&quot;; // *should* be the users's home</span>
    <span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span>
    <span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;dir&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">chdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pwd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$homeindir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pwd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$homedir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//if ($homeindir === false) die (&quot;Invalid dir&quot;);  //hopefully this will keep us from leaving $home</span>
&nbsp;
<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ls -la'</span><span style="color: #339933;">,</span><span style="color: #000088;">$dirs</span><span style="color: #339933;">,</span><span style="color: #000088;">$rc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rc</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error listing files&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$numdir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirs</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$numdir</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirs</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$lsdirs</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strrchr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirs</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</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>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$numdir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lsdirs</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print usage now</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$numdir</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</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;">$x</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: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a href=du2.php?dir=<span style="color: #006699; font-weight: bold;">$dir</span>/<span style="color: #006699; font-weight: bold;">$lsdirs</span>[<span style="color: #006699; font-weight: bold;">$x</span>]&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>/icons/folder.gif<span style="color: #000099; font-weight: bold;">\&quot;</span> border=0&gt;&lt;/a&gt;    ..&lt;br /&gt;&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: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$du</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;du -hs &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lsdirs</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$du</span><span style="color: #339933;">,</span><span style="color: #000088;">$rc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rc</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error on &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;: &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">escapeshellarg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lsdirs</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;a href=du2.php?dir=<span style="color: #006699; font-weight: bold;">$dir</span>/<span style="color: #006699; font-weight: bold;">$lsdirs</span>[<span style="color: #006699; font-weight: bold;">$x</span>]&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>/icons/folder.gif<span style="color: #000099; font-weight: bold;">\&quot;</span> border=0&gt;&lt;/a&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$du</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;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$time2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">True</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$dutime</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$time2</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$time1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;Page generated in &lt;b&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$dutime</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/b&gt; seconds&lt;/p&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;/BODY&gt;&lt;/HTML&gt;</pre></td></tr></table></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=DixtPv80Bvg:okAHnNJP4jM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=DixtPv80Bvg:okAHnNJP4jM:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=DixtPv80Bvg:okAHnNJP4jM:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=DixtPv80Bvg:okAHnNJP4jM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=DixtPv80Bvg:okAHnNJP4jM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=DixtPv80Bvg:okAHnNJP4jM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=DixtPv80Bvg:okAHnNJP4jM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=DixtPv80Bvg:okAHnNJP4jM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/DixtPv80Bvg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2010/08/du2-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://justynshull.com/2010/08/du2-php/</feedburner:origLink></item>
		<item>
		<title>Cosmos pictures</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/oe3_b5mpKbc/</link>
		<comments>http://justynshull.com/2010/08/cosmos-pictures/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 10:05:58 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Rigs]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[pictures]]></category>

		<guid isPermaLink="false">http://justynshull.com/?p=38</guid>
		<description><![CDATA[Pictures of my first watercooled setup.   Cable management is almost non-existent and the tubing is way too long.    I&#8217;ll post pictures of my new setup soon.]]></description>
			<content:encoded><![CDATA[<p>Pictures of my first watercooled setup.   Cable management is almost non-existent and the tubing is way too long.    I&#8217;ll post pictures of my new setup soon.</p>

<div class="ngg-galleryoverview" id="ngg-gallery-1-38">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://justynshull.com/2010/08/cosmos-pictures/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-11" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0861.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0861" alt="100_0861" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0861.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-12" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0862.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0862" alt="100_0862" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0862.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-13" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0863.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0863" alt="100_0863" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0863.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-14" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0864.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0864" alt="100_0864" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0864.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-15" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0865.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0865" alt="100_0865" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0865.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-16" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0866.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0866" alt="100_0866" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0866.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-17" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0867.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0867" alt="100_0867" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0867.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-18" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0868.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0868" alt="100_0868" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0868.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-19" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0869.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0869" alt="100_0869" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0869.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-20" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://justynshull.com/wp-content/gallery/cosmos/100_0870.JPG" title=" " class="shutterset_set_1" >
								<img title="100_0870" alt="100_0870" src="http://justynshull.com/wp-content/gallery/cosmos/thumbs/thumbs_100_0870.JPG" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>


<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=oe3_b5mpKbc:zGyRu_7liIg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=oe3_b5mpKbc:zGyRu_7liIg:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=oe3_b5mpKbc:zGyRu_7liIg:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=oe3_b5mpKbc:zGyRu_7liIg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=oe3_b5mpKbc:zGyRu_7liIg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=oe3_b5mpKbc:zGyRu_7liIg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=oe3_b5mpKbc:zGyRu_7liIg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=oe3_b5mpKbc:zGyRu_7liIg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/oe3_b5mpKbc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2010/08/cosmos-pictures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://justynshull.com/2010/08/cosmos-pictures/</feedburner:origLink></item>
		<item>
		<title>du.php – PHP Disk Usage script</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/_8YphY3aLj8/</link>
		<comments>http://justynshull.com/2010/08/du-php-php-disk-usage-script/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 09:37:13 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">https://justynshull.com/?p=25</guid>
		<description><![CDATA[I&#8217;m starting to copy my scripts from https://justynshull.com/oldsite/phpscripts.html but figured I&#8217;d start with this one so I can get the syntax hilighting/formatting down with wordpress. 1 2 3 4 5 6 7 8 9 10 11 12 &#60;?php // $a = shell_exec('df -h'); //echo getenv('DOCUMENT_ROOT'); chdir&#40;getenv&#40;'DOCUMENT_ROOT'&#41;&#41;; chdir&#40;'..'&#41;; echo shell_exec&#40;'pwd'&#41;; $a = shell_exec&#40;'du -hx *'&#41;; //$a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m starting to copy my scripts from <a href="https://justynshull.com/oldsite/phpscripts.html">https://justynshull.com/oldsite/phpscripts.html</a> but figured I&#8217;d start with this one so I can get the syntax hilighting/formatting down with wordpress.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">&lt;?php</span>
 <span style="color: #666666; font-style: italic;">// $a = shell_exec('df -h');</span>
<span style="color: #666666; font-style: italic;">//echo getenv('DOCUMENT_ROOT');</span>
<span style="color: #990000;">chdir</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">chdir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pwd'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'du -hx *'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//$a = shell_exec('ls -l');</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;h2&gt;Disk space&lt;/h2&gt;&lt; pre&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt; /pre&gt;'</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=_8YphY3aLj8:HLb9MvMJcC0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=_8YphY3aLj8:HLb9MvMJcC0:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=_8YphY3aLj8:HLb9MvMJcC0:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=_8YphY3aLj8:HLb9MvMJcC0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=_8YphY3aLj8:HLb9MvMJcC0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=_8YphY3aLj8:HLb9MvMJcC0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=_8YphY3aLj8:HLb9MvMJcC0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=_8YphY3aLj8:HLb9MvMJcC0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/_8YphY3aLj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2010/08/du-php-php-disk-usage-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://justynshull.com/2010/08/du-php-php-disk-usage-script/</feedburner:origLink></item>
		<item>
		<title>Switch to VPS and wordpress</title>
		<link>http://feedproxy.google.com/~r/Justynshull/~3/UBrM4uNr37s/</link>
		<comments>http://justynshull.com/2010/08/switch-to-vps-and-wordpress/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 09:21:04 +0000</pubDate>
		<dc:creator>Justyn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://justynshull.com/?p=18</guid>
		<description><![CDATA[I decided to switch my website from basic html/php to WordPress, and at the same time moved it over to my VPS.   It was being hosted on dreamhost before. I still need to install/configure subversion, and move some of my old stuff over to wordpress.   There isn&#8217;t much to move, so it won&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to switch my website from basic html/php to WordPress, and at the same time moved it over to my VPS.   It was being hosted on dreamhost before.</p>
<p>I still need to install/configure subversion, and move some of my old stuff over to wordpress.   There isn&#8217;t much to move, so it won&#8217;t be hard.    The old version of the site can be found here:</p>
<p><a href="http://justynshull.com/oldsite/">http://justynshull.com/oldsite/</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Justynshull?a=UBrM4uNr37s:B5TGJ5QlvpE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=UBrM4uNr37s:B5TGJ5QlvpE:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=UBrM4uNr37s:B5TGJ5QlvpE:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=UBrM4uNr37s:B5TGJ5QlvpE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=UBrM4uNr37s:B5TGJ5QlvpE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=UBrM4uNr37s:B5TGJ5QlvpE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Justynshull?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Justynshull?a=UBrM4uNr37s:B5TGJ5QlvpE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Justynshull?i=UBrM4uNr37s:B5TGJ5QlvpE:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Justynshull/~4/UBrM4uNr37s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://justynshull.com/2010/08/switch-to-vps-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://justynshull.com/2010/08/switch-to-vps-and-wordpress/</feedburner:origLink></item>
	</channel>
</rss>

