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

<channel>
	<title>Sigil.us</title>
	<atom:link href="http://www.sigil.us/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sigil.us</link>
	<description>Zachary Schneider&#039;s Blog</description>
	<lastBuildDate>Thu, 28 Jan 2010 17:34:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Shell :: Simple Apache Pig Identification</title>
		<link>http://www.sigil.us/2010/01/shell-simple-apache-pig-identification/</link>
		<comments>http://www.sigil.us/2010/01/shell-simple-apache-pig-identification/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 17:01:46 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=346</guid>
		<description><![CDATA[
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
#!/bin/bash
#apachepig.sh
#simple script for identifying shared hosting pigs on a small server
#only definitive for a forking server, threading would need modification
#should be enhanced for polling, but useful for processes that are hung
#which is what we are looking for right?
&#160;
ARGS=&#40;&#34;$@&#34;&#41;
&#160;
#GLOBALS
WEBROOT=/home
DAEMONNAME=apache2
&#160;
#ARGS
ACTION=${ARGS[0]}
#add single PID functionality later
PID=${ARGS[1]}
&#160;
case $ACTION in
	mem&#41;
		PROCESSES=$&#40;top -b -n1 &#124; grep $DAEMONNAME &#124; sort -r -k 6&#41;
	;;
	cpu&#41;
		PROCESSES=$&#40;top -b [...]]]></description>
			<content:encoded><![CDATA[
<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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#apachepig.sh</span>
<span style="color: #666666; font-style: italic;">#simple script for identifying shared hosting pigs on a small server</span>
<span style="color: #666666; font-style: italic;">#only definitive for a forking server, threading would need modification</span>
<span style="color: #666666; font-style: italic;">#should be enhanced for polling, but useful for processes that are hung</span>
<span style="color: #666666; font-style: italic;">#which is what we are looking for right?</span>
&nbsp;
<span style="color: #007800;">ARGS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;$@&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#GLOBALS</span>
<span style="color: #007800;">WEBROOT</span>=<span style="color: #000000; font-weight: bold;">/</span>home
<span style="color: #007800;">DAEMONNAME</span>=apache2
&nbsp;
<span style="color: #666666; font-style: italic;">#ARGS</span>
<span style="color: #007800;">ACTION</span>=<span style="color: #800000;">${ARGS[0]}</span>
<span style="color: #666666; font-style: italic;">#add single PID functionality later</span>
<span style="color: #007800;">PID</span>=<span style="color: #800000;">${ARGS[1]}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$ACTION</span> <span style="color: #000000; font-weight: bold;">in</span>
	mem<span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">PROCESSES</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>top <span style="color: #660033;">-b</span> <span style="color: #660033;">-n1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$DAEMONNAME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
	cpu<span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">PROCESSES</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>top <span style="color: #660033;">-b</span> <span style="color: #660033;">-n1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$DAEMONNAME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">time</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">PROCESSES</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>top <span style="color: #660033;">-b</span> <span style="color: #660033;">-n1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$DAEMONNAME</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;operation not supported&quot;</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #007800;">IFS</span>=$<span style="color: #ff0000;">'\n'</span>
<span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$PROCESSES</span>; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$x</span>&quot;</span>
	<span style="color: #007800;">PID</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$x</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #007800;">OUTPUT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>lsof <span style="color: #660033;">-w</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$PID</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$WEBROOT</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$OUTPUT</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$OUTPUT</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'NO PIGS'</span>
	<span style="color: #000000; font-weight: bold;">fi</span>	
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; &quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2010/01/shell-simple-apache-pig-identification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell :: simple MySQL DB provisioning</title>
		<link>http://www.sigil.us/2010/01/shell-simple-mysql-db-provisioning/</link>
		<comments>http://www.sigil.us/2010/01/shell-simple-mysql-db-provisioning/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 19:07:46 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=338</guid>
		<description><![CDATA[
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
#!/bin/bash
#provmysqldb.sh
&#160;
ARGS=&#40;&#34;$@&#34;&#41;
&#160;
#GLOBALS
MYSQLHOST=your.server.name
MYSQLPASS=yourpass
&#160;
#ARGS
ACTION=${ARGS[0]}
USER=${ARGS[1]}
#maybe we want to split this out later
DB=${ARGS[1]}
&#160;
if &#91;&#91; $ACTION &#38;&#38; $USER &#38;&#38; $DB &#93;&#93;; then
	case $ACTION in
		create&#41;
			#check to see if db exists
			echo &#34;use ${DB}&#34; &#124; mysql -s -h $MYSQLHOST -u root -p$MYSQLPASS 2&#62; /dev/null
&#160;
			if &#91; $? -ne 0 &#93;; then
				echo -n 'enter password: '
				read PASS
&#160;
				OP=&#34;
				create database ${DB};
				create user '${USER}'@'%' identified by '${PASS}';
				grant all ON [...]]]></description>
			<content:encoded><![CDATA[
<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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#provmysqldb.sh</span>
&nbsp;
<span style="color: #007800;">ARGS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;$@&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#GLOBALS</span>
<span style="color: #007800;">MYSQLHOST</span>=your.server.name
<span style="color: #007800;">MYSQLPASS</span>=yourpass
&nbsp;
<span style="color: #666666; font-style: italic;">#ARGS</span>
<span style="color: #007800;">ACTION</span>=<span style="color: #800000;">${ARGS[0]}</span>
<span style="color: #007800;">USER</span>=<span style="color: #800000;">${ARGS[1]}</span>
<span style="color: #666666; font-style: italic;">#maybe we want to split this out later</span>
<span style="color: #007800;">DB</span>=<span style="color: #800000;">${ARGS[1]}</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$ACTION</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">$USER</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">$DB</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$ACTION</span> <span style="color: #000000; font-weight: bold;">in</span>
		create<span style="color: #7a0874; font-weight: bold;">&#41;</span>
			<span style="color: #666666; font-style: italic;">#check to see if db exists</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;use <span style="color: #007800;">${DB}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mysql <span style="color: #660033;">-s</span> <span style="color: #660033;">-h</span> <span style="color: #007800;">$MYSQLHOST</span> <span style="color: #660033;">-u</span> root -p<span style="color: #007800;">$MYSQLPASS</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'enter password: '</span>
				<span style="color: #c20cb9; font-weight: bold;">read</span> PASS
&nbsp;
				<span style="color: #007800;">OP</span>=<span style="color: #ff0000;">&quot;
				create database <span style="color: #007800;">${DB}</span>;
				create user '<span style="color: #007800;">${USER}</span>'@'%' identified by '<span style="color: #007800;">${PASS}</span>';
				grant all ON <span style="color: #007800;">${DB}</span>.* to '<span style="color: #007800;">${USER}</span>'@'%';
				flush privileges;&quot;</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The database/user: <span style="color: #007800;">${DB}</span> already exists&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
			<span style="color: #000000; font-weight: bold;">;;</span>
		delete<span style="color: #7a0874; font-weight: bold;">&#41;</span>
			<span style="color: #666666; font-style: italic;">#check to see if db exists</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;use <span style="color: #007800;">${DB}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mysql <span style="color: #660033;">-h</span> <span style="color: #007800;">$MYSQLHOST</span> <span style="color: #660033;">-u</span> root -p<span style="color: #007800;">$MYSQLPASS</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
				<span style="color: #007800;">OP</span>=<span style="color: #ff0000;">&quot;
				drop database <span style="color: #007800;">${DB}</span>;
				drop user '<span style="color: #007800;">${USER}</span>'@'%';
				flush privileges;&quot;</span>
			<span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The database/user: <span style="color: #007800;">${DB}</span> doesn't exist&quot;</span>
			<span style="color: #000000; font-weight: bold;">fi</span>
			<span style="color: #000000; font-weight: bold;">;;</span>
		<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Operation not supported'</span>
			<span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$OP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$OP</span> <span style="color: #000000; font-weight: bold;">|</span> mysql <span style="color: #660033;">-h</span> <span style="color: #007800;">$MYSQLHOST</span> <span style="color: #660033;">-u</span> root -p<span style="color: #007800;">$MYSQLPASS</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Operation Succeeded!'</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Operation Failed!'</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'USAGE: provmysqldb.sh &lt;action:create|delete&gt; &lt;dbname&gt;'</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2010/01/shell-simple-mysql-db-provisioning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Love the Cloud :: More new companies</title>
		<link>http://www.sigil.us/2010/01/love-the-cloud-more-new-companies/</link>
		<comments>http://www.sigil.us/2010/01/love-the-cloud-more-new-companies/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 21:38:25 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=326</guid>
		<description><![CDATA[Linode
A Xen VPS hosting company.
According to these benchmarks they have the best Xen VPS performance so far.
Heroku
A ruby app hosting company with a slick API and a fully managed stack. I love their web design too!
]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.linode.com" target="_blank">Linode<br />
</a><span style="font-weight: normal;">A Xen VPS hosting company.<br />
According to <a href="http://journal.uggedal.com/vps-performance-comparison" target="_blank">these</a> benchmarks they have the best Xen VPS performance so far.</span></strong></p>
<p><strong><a href="http://heroku.com/" target="_blank">Heroku<br />
</a><span style="font-weight: normal;">A ruby app hosting company with a slick API and a fully managed stack. I love their web design too!</span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2010/01/love-the-cloud-more-new-companies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IPS/pkg :: A business friendly software distribution and packaging system</title>
		<link>http://www.sigil.us/2010/01/ipspkg-a-business-friendly-software-distribution-and-packaging-system/</link>
		<comments>http://www.sigil.us/2010/01/ipspkg-a-business-friendly-software-distribution-and-packaging-system/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 23:06:49 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=320</guid>
		<description><![CDATA[I just noticed this change to pkg in OpenSolaris. These functionality additions allow for the conditional display and acceptance of software licenses on package install for the IPS system.
Why is this significant? Because it opens up the package system for commercial software distributors. If you couple this with the IPS repository functionality and require keys [...]]]></description>
			<content:encoded><![CDATA[<p>I just noticed this <a title="pkg license functionality" href="http://blogs.sun.com/srw/entry/new_pkg_5_license_functionality" target="_blank">change</a> to pkg in OpenSolaris. These functionality additions allow for the conditional display and acceptance of software licenses on package install for the IPS system.</p>
<p>Why is this significant? Because it opens up the package system for commercial software distributors. If you couple this with the IPS repository functionality and require keys for the repo you have subscription updates, and license management covered!</p>
<p>Your software purchase and install path looks like:</p>
<p>Go to web site -&gt; do they support opensolaris -&gt; yes -&gt; buy -&gt; add repo -&gt; pkg install software</p>
<p>Update your software from now until forever:</p>
<p>pkg install software or</p>
<p>pkg image-update</p>
<p>I really don&#8217;t like having to run custom installers from vendors that run scripts that do all kinds of stuff to the system and also install package sets. If the software packaging system is opened up to vendors we can manage our open source and commercial applications from one place.</p>
<p>I would also like to see open source projects build their own package repositories for all the major distributions. This would allow us to stay current with some software packages who&#8217;s development out paces the release cycles of the enterprise distros (RHEL, Ubuntu LTS).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2010/01/ipspkg-a-business-friendly-software-distribution-and-packaging-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storage Management :: Global File Systems and ZFS</title>
		<link>http://www.sigil.us/2010/01/storage-management-global-file-systems-and-zfs/</link>
		<comments>http://www.sigil.us/2010/01/storage-management-global-file-systems-and-zfs/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 02:06:20 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[ZFS]]></category>
		<category><![CDATA[GFS2]]></category>
		<category><![CDATA[Lustre]]></category>
		<category><![CDATA[Redhat]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=295</guid>
		<description><![CDATA[One enterprise architecture feature that every admin dreams of is simple storage management. Having one storage network and a global filesystem that all nodes can access, and being able to easily have space &#8220;appear&#8221; on the file system by adding LUNs to the global file system is a huge time saver.
Redhat Linux
GFS(2)
Redhat has done well [...]]]></description>
			<content:encoded><![CDATA[<p>One enterprise architecture feature that every admin dreams of is simple storage management. Having one storage network and a global filesystem that all nodes can access, and being able to easily have space &#8220;appear&#8221; on the file system by adding LUNs to the global file system is a huge time saver.</p>
<h3>Redhat Linux</h3>
<p><strong>GFS(2)</strong><br />
Redhat has done well with GFS(2) from a systems management perspective (I have read that it doesn&#8217;t scale as well as lustre). The cluster file system technology is pretty simple comparatively speaking even though there are several layers involved. You don&#8217;t need metadata controllers or independent systems acting as lock managers. You do need to either have fencing hardware, or a manual fencing process in place to account for failed nodes.</p>
<p>Adding storage involves using LVM to add the LUN to the volume, expand the volume, then using gfs2_grow to expand the filesystem.</p>
<p>At its simplest a configuration could look like the following:</p>
<p><img class="alignnone size-full wp-image-297" title="fig-gfs-with-san" src="http://www.sigil.us/wp-content/uploads/2010/01/fig-gfs-with-san.png" alt="" width="335" height="236" /></p>
<h3>Sun Solaris/OpenSolaris</h3>
<p><strong>SAM-QFS</strong><br />
Sun has had SAM-QFS for quite some time. It is more complex than GFS(2). To be fair it also has more features. It requires dedicated metadata controllers. This solution doesn&#8217;t interest me much due to the fact that I use Solaris/OpenSolaris for ZFS to simplify storage management.</p>
<p>Adding storage to the shared QFS file system appears to involve a similar process to GFS(2).</p>
<p>At its simplest a configuration could look like the following:</p>
<p><img class="alignnone size-full wp-image-306" title="clientdiagramjpeg-1" src="http://www.sigil.us/wp-content/uploads/2010/01/clientdiagramjpeg-11.jpeg" alt="" width="518" height="524" /></p>
<h3>Lustre, BTRFS/CRFS, ZFS and the Future</h3>
<p><strong>Lustre</strong><br />
Lustre seems to be more complex than both GFS(2) and SAM-QFS. It also seems to be more scalable. It requires 2 types of controllers: MDS (metadata) and OSS (storage). So from a management perspective it requires quite a bit more overhead.</p>
<p>It looks like ZFS will be added as a backend storage format in the future versions 2.x+ this might simplify LUN management a little for the solution.</p>
<p><strong>BTRFS/CRFS</strong><br />
BTRFS is a Linux ZFS workalike. It is still in development but the final version is shaping up to have ZFS feature parity (minus easy device/raid management, zvols, and other sweet things like zfs send recv). What interests me however is CRFS.</p>
<p>CRFS also in development, appears to be a global network filesystem that basically exports BTRFS file systems.</p>
<p><strong>ZFS</strong><br />
What I would like to see is ZFS to become cluster aware. Being able to use OpenSolaris as a storage host and export either a zfs or a zpool to nodes, and perhaps run a lockmanager process similar to GFS(2) would be pretty slick.</p>
<h3>For now with ZFS</h3>
<p>Creating ZFS file systems on disk boxes connected to a SAN fabric really isn&#8217;t that difficult. It is however a bit time consuming, and you really should configure LUN masking for each LUN and node. Other wise you run the risk of accidentally corrupting data by using the same LUN at the same time on different nodes.</p>
<p>Exporting zvols with Comstar/iSCSI also doesn&#8217;t seem like the best idea, because again you should configure target portal groups and host access, and I don&#8217;t think that running ZFS on top of a ZFS based virtual block device (zvol) would be great for performance. Jeff Bonwick had stated something about improving the zvol performance (block pass through?) in his last ZFS talk. I am not sure wether it has been done yet or not. There also are no best practice notes about ZFS on iSCSI zvols.</p>
<p>I would think using UFS on a zvol would be better performance wise, but the whole purpose of the exercise for me is to provide snapshot functionality to the host consuming the filesystem, and filesystem delegation to the zones on the host.</p>
<p>I would really like to be able to use zvols as opposed to SAN fabric LUNs because then the zones could use snapshots, I could mirror the zvols from a Comstar storage host to a remote system for disaster recovery, and only have to deal with one zpool.</p>
<p>So how about it? Is anyone else using Comstar, ZFS, and OpenSolaris in the fashion I have described What is your strategy for consolidating storage management with OpenSolaris?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2010/01/storage-management-global-file-systems-and-zfs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bash :: Extension change  script</title>
		<link>http://www.sigil.us/2010/01/extension-change-bash-script/</link>
		<comments>http://www.sigil.us/2010/01/extension-change-bash-script/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 19:40:26 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=288</guid>
		<description><![CDATA[A simple script to recursively change filename extensions (case insensitive)

#!/bin/bash
#chext.sh
&#160;
ARGS=&#40;&#34;$@&#34;&#41;
&#160;
if &#91;&#91; -d ${ARGS[0]} &#38;&#38; ${ARGS[1]} &#38;&#38; ${ARGS[2]} &#93;&#93;; then
        for x in $&#40;find ${ARGS[0]} -name &#34;*.${ARGS[1]}&#34;&#41;; do
                y=$&#40;echo $x &#124; sed &#34;s/\.${ARGS[1]}\$/\.${ARGS[2]}/i&#34;&#41;
  [...]]]></description>
			<content:encoded><![CDATA[<p>A simple script to recursively change filename extensions (case insensitive)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#chext.sh</span>
&nbsp;
<span style="color: #007800;">ARGS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;$@&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #800000;">${ARGS[0]}</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #800000;">${ARGS[1]}</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #800000;">${ARGS[2]}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #800000;">${ARGS[0]}</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.<span style="color: #007800;">${ARGS[1]}</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #007800;">y</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$x</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">&quot;s/\.<span style="color: #007800;">${ARGS[1]}</span><span style="color: #000099; font-weight: bold;">\$</span>/\.<span style="color: #007800;">${ARGS[2]}</span>/i&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$x</span> <span style="color: #007800;">$y</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$x</span> -&amp;gt; <span style="color: #007800;">$y</span>&quot;</span>
        <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'USAGE: chext.sh'</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2010/01/extension-change-bash-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Grails :: Broken Mail Template Rendering</title>
		<link>http://www.sigil.us/2009/12/grails-broken-mail-template-rendering/</link>
		<comments>http://www.sigil.us/2009/12/grails-broken-mail-template-rendering/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 21:54:08 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Templates]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=273</guid>
		<description><![CDATA[Ugg. So one thing all web applications HAVE to do is send mail. In order to keep your code tidy you should be using templates to handle your mail formatting. In PHP + Zend Framework I have accomplished this cleanly via the following:

1
2
3
4
5
6
7
8
9
10
11
12
$view = new Zend_View&#40;&#41;;
$view-&#62;addScriptPath&#40;BASE_PATH.'/tpl'&#41;;
$view-&#62;somevar = $somevar;
$html = $view-&#62;render&#40;'someTemplate.phtml'&#41;;
&#160;
$mail = new Zend_Mail&#40;&#41;;
$mail-&#62;setBodyHtml&#40;$html&#41;;
$mail-&#62;setFrom&#40;$config-&#62;site-&#62;serviceAddress, $config-&#62;site-&#62;appName&#41;;
$mail-&#62;addTo&#40;$email&#41;;
&#160;
$mail-&#62;setSubject&#40;$config-&#62;site-&#62;appName.' - [...]]]></description>
			<content:encoded><![CDATA[<p>Ugg. So one thing all web applications HAVE to do is send mail. In order to keep your code tidy you should be using templates to handle your mail formatting. In PHP + Zend Framework I have accomplished this cleanly via the following:</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: #000088;">$view</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_View<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addScriptPath</span><span style="color: #009900;">&#40;</span>BASE_PATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/tpl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">somevar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$somevar</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'someTemplate.phtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBodyHtml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">serviceAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appName</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' - Message Subject'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Zend_View handles the output buffering and rendering of the template. I have never really had a problem with it.</p>
<p>In Grails this is supposed to work:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">sendMail <span style="color: #66cc66;">&#123;</span>
	to user.<span style="color: #006600;">email</span>
        from <span style="color: #ff0000;">'email@emails.com'</span>
        subject <span style="color: #ff0000;">'Subject'</span>
        body <span style="color: #66cc66;">&#40;</span>view:<span style="color: #ff0000;">'/mail/myTemplate'</span>, model<span style="color: #66cc66;">&#91;</span>user:user<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>sendMail is a mail service plugin that accepts a closure as an argument, it also has a shortcut to the gsp template engine to render the template. Seems more simplistic, however there is a lot of code under the hood driving it. It seems that the output buffering within the Grails framework is very tied to the servlet response.</p>
<p>Anyway within a Grails Service (haven&#8217;t tried it within a controller yet) it munges the output buffer. Probably due to the output buffer juggling that is going on within various layers of the response and template rendering wrappers. The result is a failed remoting call.</p>
<p>The fix (figured this out after profiling and digging around the web) is to wrap sendMail in a thread:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> t <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Thread</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	sendMail <span style="color: #66cc66;">&#123;</span>
		to user.<span style="color: #006600;">email</span>
                from <span style="color: #ff0000;">'email@emails.com'</span>
                subject <span style="color: #ff0000;">'Subject'</span>
                body <span style="color: #66cc66;">&#40;</span>view:<span style="color: #ff0000;">'/mail/myTemplate'</span>, model<span style="color: #66cc66;">&#91;</span>user:user<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
t.<span style="color: #993399;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>This leads me to believe that somewhere within GrailsPageResponseWrapper the original output buffer is being overwritten or lost which is killing the response writer. Spawning a new thread for the operation preserves the original output buffer.</p>
<p>I am surprised that no one else is using this functionality outside of their controllers, and only 2 people have encountered the issue. I don&#8217;t know enough about the grails stack to debug it fully myself yet.</p>
<p>Here is a link to the bug report:<br />
<a href="http://jira.codehaus.org/browse/GRAILSPLUGINS-1548">http://jira.codehaus.org/browse/GRAILSPLUGINS-1548</a></p>
<p>Please fix? <img src='http://www.sigil.us/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2009/12/grails-broken-mail-template-rendering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell Web Server :: Netcat is neat</title>
		<link>http://www.sigil.us/2009/12/shell-web-server-netcat-is-neat/</link>
		<comments>http://www.sigil.us/2009/12/shell-web-server-netcat-is-neat/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 20:03:20 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=268</guid>
		<description><![CDATA[A very basic bash web server. Netcat is pretty epic. Referenced Paul Buchheit

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
#!/bin/bash
&#160;
HOMEDIR=./
RESP=/tmp/webresp
&#91; -p $RESP &#93; &#124;&#124; mkfifo $RESP
&#160;
while true ; do
&#40; cat $RESP &#41; &#124; nc -l 8000 &#124; &#40;
REQ=`while read L &#38;&#38; &#91; &#34; &#34; &#34;&#60;&#34; &#34;$L&#34; &#93; ; do echo &#34;$L&#34; ; done`
URL=`echo $REQ &#124; head -1 &#124; awk -F&#34; &#34; '{print [...]]]></description>
			<content:encoded><![CDATA[<p>A very basic bash web server. Netcat is pretty epic. Referenced <a href="http://paulbuchheit.blogspot.com/2007/04/webserver-in-bash.html">Paul Buchheit</a></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
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">HOMEDIR</span>=.<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #007800;">RESP</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>webresp
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$RESP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">mkfifo</span> <span style="color: #007800;">$RESP</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span> ; <span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$RESP</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> nc <span style="color: #660033;">-l</span> <span style="color: #000000;">8000</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
<span style="color: #007800;">REQ</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> L <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #ff0000;">&quot;&lt;&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$L</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$L</span>&quot;</span> ; <span style="color: #000000; font-weight: bold;">done</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">URL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$REQ</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span><span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #780078;">`date '+%Y-%m-%d %H:%M:%S'`</span>] <span style="color: #007800;">$REQ</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-1</span>
&nbsp;
<span style="color: #007800;">index</span>=<span style="color: #ff0000;">'index.html'</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$URL</span>&quot;</span> == <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>	
	<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">file</span></span>=index.html
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">file</span></span>=<span style="color: #007800;">$URL</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$HOMEDIR</span><span style="color: #007800;">$file</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">CODE</span>=<span style="color: #000000;">400</span>
	<span style="color: #007800;">CONTENT</span>=<span style="color: #ff0000;">'Not Found'</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">CODE</span>=<span style="color: #000000;">200</span>
	<span style="color: #007800;">CONTENT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$HOMEDIR</span><span style="color: #007800;">$file</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #007800;">$RESP</span> <span style="color: #cc0000; font-style: italic;">&lt;&lt;EOF
HTTP/1.1 $CODE OK
Cache-Control: private
Content-Type: text/plain
Server: bash/3.2.48
Connection: Close
Content-Length: ${#CONTENT}
&nbsp;
$CONTENT
EOF</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2009/12/shell-web-server-netcat-is-neat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RedHat EL5 :: Surprisingly Better</title>
		<link>http://www.sigil.us/2009/12/redhat-el5-surprisingly-better/</link>
		<comments>http://www.sigil.us/2009/12/redhat-el5-surprisingly-better/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 04:06:54 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=265</guid>
		<description><![CDATA[So I have been putting RHEL5.4 through its paces in preparation for the RHCE exam. It has come a long way since version 4. Yum is actually pretty ok. The distro itself is snappy even on garbage hardware. All in all though not as bad as I remember RHEL being.
Things that still bother me vs [...]]]></description>
			<content:encoded><![CDATA[<p>So I have been putting RHEL5.4 through its paces in preparation for the RHCE exam. It has come a long way since version 4. Yum is actually pretty ok. The distro itself is snappy even on garbage hardware. All in all though not as bad as I remember RHEL being.</p>
<p>Things that still bother me vs Ubuntu LTS:</p>
<ul>
<li>Comparatively small distro package set.</li>
<li>File system layout in respect to etc and var: stuff is all over the place. Seriously each configurable software package having its own directory in etc and var sub directories (log etc) is nice. It is uniform and easy to guess where things might be.</li>
<li>$300/yr</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2009/12/redhat-el5-surprisingly-better/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elementary Algorithms :: Array Difference</title>
		<link>http://www.sigil.us/2009/11/elementary-algorithms-array-difference/</link>
		<comments>http://www.sigil.us/2009/11/elementary-algorithms-array-difference/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 15:59:18 +0000</pubDate>
		<dc:creator>Zachary Schneider</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sigil.us/?p=223</guid>
		<description><![CDATA[UPDATED
In an interview I was posed a problem: given 2 arrays a and b write a program that will print the elements of a that are not in b.
The easiest (incorrect solution) in PHP:

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/php
&#60;?
$a = array&#40;1, 2, 3, 4, 9, 20, 30, 82, 57&#41;;
$b = array&#40;1, 2, 3, 82, 57, 100, 32&#41;;
&#160;
$c = array&#40;&#41;;
foreach&#40;$a as [...]]]></description>
			<content:encoded><![CDATA[<p><b>UPDATED</b></p>
<p>In an interview I was posed a problem: given 2 arrays <strong>a</strong> and <strong>b</strong> write a program that will print the elements of a that are not in b.</p>
<p>The easiest (incorrect solution) in PHP:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">57</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$aval</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: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aval</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aval</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now as I had stated in the interview this is <b>NOT</b> the best way to accomplish this. Of course that would all depend on how in_array is implemented in PHP. If in_array is simply a short cut to a true false foreach loop then we have a problem.  If <b>n</b> and <b>m</b> represent the number of elements of <b>a</b> and <b>b</b> respectively iterations = n * m. Or O(mn). Not efficient. Since this is PHP I am guessing this is the case (a simple sequential search).</p>
<p>So what is a better solution (best?) to allow for better performance as <b>n</b> and <b>m</b> increase? This is the best I could come up with after a quick look at a couple of algorithms.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">57</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//binary search function</span>
<span style="color: #000000; font-weight: bold;">function</span> binSearch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ar</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$l</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$l</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$mid</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$l</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ar</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mid</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ar</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$mid</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&lt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$l</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mid</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mid</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//sort the first array used in the bin search</span>
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$m</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$m</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</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: #339933;">!</span>binSearch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #339933;">,</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</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: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Removing the negation operator prior to the function call will change the program to array intersection vs array diff. The math for this binary search solution is O(m log<subscript>2</subscript> n). </p>
<p><b>So consider the following:</b><br />
m = 8<br />
n = 8</p>
<p><b>Solution 1:</b><br />
(mn) = 64</p>
<p><b>Solution 2:</b><br />
16*log2(8) = 48</p>
<p>Basically due to the first array being sorted and chunking we are able to do fewer comparisons instead of a comparison for each element. As the size of the chunk decreases the worst case is that the value doesn&#8217;t exist.</p>
<p>It also occurs to me that you will want to count each array and sort the shortest and use that as the first argument and the longer array[val] as the second to further reduce the number of iterations. Of course the order of the arguments matters for this problem (in <b>a</b> not in <b>b</b>). I suppose you could flip flop logic/operator in/on the binary search call/function though to account for that as well. </p>
<p>Anyway this is basic CS, everyone probably knows this but I couldn&#8217;t come up with it off the top of my head, and the problem was driving me nuts cycling in the back of my mind so I had to write it out.</p>
<p><b>UPDATE</b><br />
I still kept thinking about this so here is another based on array merge and comparing next array elements. Since this is a diff and not an intersection we need to merge the first array twice. Any value that shows up twice in the merged array is in <b>a</b> and not in <b>b</b>.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">57</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<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: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #000088;">$i</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$i</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The math ends up being something like ~O(m + m + n).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sigil.us/2009/11/elementary-algorithms-array-difference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
