<?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>markomedia</title> <atom:link href="http://www.markomedia.com.au/feed/" rel="self" type="application/rss+xml" /><link>http://www.markomedia.com.au</link> <description>Web Development</description> <lastBuildDate>Tue, 24 Apr 2012 03:00:11 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Compile PHP pcntl module on OS X Lion</title><link>http://www.markomedia.com.au/php/compile-php-pcntl-module-on-os-x-lion/</link> <comments>http://www.markomedia.com.au/php/compile-php-pcntl-module-on-os-x-lion/#comments</comments> <pubDate>Tue, 24 Apr 2012 03:00:11 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Lion]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1921</guid> <description><![CDATA[I had some trouble compiling pcntl PHP module on OS X Lion so I thought I&#8217;d share this solution. In fact, you can use these steps to compile any other PHP module. First download the latest php source from PHP.NET cd into your php src directory, then: cd ext/pcntl phpize ./configure --enable-pcntl When I ran...]]></description> <content:encoded><![CDATA[<p>I had some trouble compiling pcntl PHP module on OS X Lion so I thought I&#8217;d share this solution. In fact, you can use these steps to compile any other PHP module.</p><p>First download the latest php source from <a
href="http://www.php.net/downloads.php">PHP.NET</a><br
/> cd into your php src directory, then:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw3">cd</span> ext<span class="sy0">/</span>pcntl</pre></div></div></div></div></div></div></div><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">phpize</pre></div></div></div></div></div></div></div><pre lang"bash">./configure --enable-pcntl</pre><p>When I ran the last step (configure), I got the following error:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">‘PHP_FE_END’ undeclared here <span class="br0">&#40;</span>not <span class="kw1">in</span> a <span class="kw1">function</span><span class="br0">&#41;</span></pre></div></div></div></div></div></div></div><p>To get around the problem, you need to specify your system architecture before configuring your extension:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="re2">CFLAGS</span>=<span class="st_h">'-arch x86_64'</span> <span class="re2">CXXFLAGS</span>=<span class="st_h">'-arch x86_64'</span> <span class="re2">LDFLAGS</span>=<span class="st_h">'-arch x86_64'</span> .<span class="sy0">/</span>configure <span class="re5">--enable-pcntl</span></pre></div></div></div></div></div></div></div><p>Copy compiled modules into PHP extensions:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">cp</span> modules<span class="sy0">/</span>pcntl.so <span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>php<span class="sy0">/</span>extensions<span class="sy0">/</span></pre></div></div></div></div></div></div></div><p>Enable the extension:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw3">echo</span> <span class="st0">&quot;extension=pcntl.so&quot;</span> <span class="sy0">&gt;&gt;</span> <span class="sy0">/</span>etc<span class="sy0">/</span>php.ini</pre></div></div></div></div></div></div></div><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/php/compile-php-pcntl-module-on-os-x-lion/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>MySQL cursors in stored procedures</title><link>http://www.markomedia.com.au/mysql/mysql-cursors-in-stored-procedures/</link> <comments>http://www.markomedia.com.au/mysql/mysql-cursors-in-stored-procedures/#comments</comments> <pubDate>Wed, 14 Mar 2012 10:05:04 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[cursors]]></category> <category><![CDATA[StoredProcedures]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1909</guid> <description><![CDATA[I&#8217;ve wanted to write a few stored procedures in MySQL for a while now, but I found it very fiddly and was unable to come up with one very quickly. Tonight I was determined to read up on MySQL documentation and get one going. For my reference only, this stored procedure will loop through a...]]></description> <content:encoded><![CDATA[<p>I&#8217;ve wanted to write a few stored procedures in MySQL for a while now, but I found it very fiddly and was unable to come up with one very quickly. Tonight I was determined to read up on <a
title="MySQL Documentation" href="http://dev.mysql.com/doc/">MySQL documentation</a> and get one going.</p><p>For my reference only, this stored procedure will loop through a recordset and update a single row in a table upon a single row lookup in another table.</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="mysql"><pre class="de1">DELIMITER <span class="sy1">//</span> 
&nbsp;
<span class="kw1">DROP</span> <span class="kw1">PROCEDURE</span> <span class="kw12">IF</span> <span class="kw1">EXISTS</span> sp_test <span class="sy1">//</span>
&nbsp;
<span class="kw1">CREATE</span> <span class="kw1">PROCEDURE</span> sp_test <span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="kw1">BEGIN</span>
	<span class="kw1">DECLARE</span> done <span class="kw4">INT</span> <span class="kw2">DEFAULT</span> <span class="kw3">FALSE</span><span class="sy2">;</span>
	<span class="kw1">DECLARE</span> myid <span class="kw4">INT</span><span class="sy2">;</span>
	<span class="kw1">DECLARE</span> cur1 CURSOR FOR <span class="kw1">SELECT</span> id <span class="kw1">from</span> table1 <span class="kw1">WHERE</span> firstname <span class="kw10">IS</span> <span class="kw3">NULL</span><span class="sy2">;</span>
	<span class="kw1">DECLARE</span> CONTINUE <span class="kw1">HANDLER</span> FOR <span class="kw10">NOT</span> FOUND <span class="kw1">SET</span> done <span class="sy1">=</span> <span class="kw3">TRUE</span><span class="sy2">;</span>
&nbsp;
	OPEN cur1<span class="sy2">;</span>
&nbsp;
	read_loop: LOOP
		<span class="kw12">IF</span> done <span class="kw12">THEN</span>
			LEAVE read_loop<span class="sy2">;</span>
		<span class="kw12">END</span> <span class="kw12">IF</span><span class="sy2">;</span>
&nbsp;
		FETCH cur1 <span class="kw1">INTO</span> myid<span class="sy2">;</span>
		<span class="kw1">UPDATE</span> table1 <span class="kw1">SET</span> firstname <span class="sy1">=</span> <span class="br0">&#40;</span><span class="kw1">SELECT</span> firstname <span class="kw1">from</span> table2 <span class="kw1">WHERE</span> id <span class="sy1">=</span> myid<span class="br0">&#41;</span>
		<span class="kw1">WHERE</span> id <span class="sy1">=</span> myid<span class="sy2">;</span>
	<span class="kw12">END</span> LOOP<span class="sy2">;</span>
&nbsp;
	close cur1<span class="sy2">;</span>
<span class="kw12">END</span><span class="sy2">;</span>
<span class="sy1">//</span></pre></div></div></div></div></div></div></div><p>Once I got the procedure to compile, executing it was as simple as:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="mysql"><pre class="de1"><span class="kw1">call</span> sp_test</pre></div></div></div></div></div></div></div><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/mysql/mysql-cursors-in-stored-procedures/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>IE6, IE7, IE8, &amp; IE9 on OS X in Virtual Machine</title><link>http://www.markomedia.com.au/osx/ie6-ie7-ie8-ie9/</link> <comments>http://www.markomedia.com.au/osx/ie6-ie7-ie8-ie9/#comments</comments> <pubDate>Fri, 10 Feb 2012 00:45:05 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[OS X]]></category> <category><![CDATA[IE6]]></category> <category><![CDATA[IE7]]></category> <category><![CDATA[IE8]]></category> <category><![CDATA[IE9]]></category> <category><![CDATA[virtualbox]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1903</guid> <description><![CDATA[Today I discovered a nice tool on Github which installs free Windows virtual machines using VirtualBox on OS X. The only reason I&#8217;d use these virtual machines is to have different versions of Internet Explorer browsers running side by side for testing purposes. So here&#8217;s what you need to do: 1. Download VirtualBox if you...]]></description> <content:encoded><![CDATA[<p>Today I discovered a <a
title="https://github.com/xdissent/ievms" href="https://github.com/xdissent/ievms">nice tool on Github</a> which installs free Windows virtual machines using VirtualBox on OS X. The only reason I&#8217;d use these virtual machines is to have different versions of Internet Explorer browsers running side by side for testing purposes.</p><p>So here&#8217;s what you need to do:<br
/> 1. <a
title="Virtual Box" href="http://www.virtualbox.org/wiki/Downloads">Download VirtualBox</a> if you don&#8217;t have it already.<br
/> 2. Choose what version of Internet Explorer to install. Then type the following commands in your terminal window:<br
/> <strong>Install ALL versions of Internet Explorer: IE6, IE7, IE 8, and IE 9</strong></p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">curl <span class="re5">-s</span> https:<span class="sy0">//</span>raw.github.com<span class="sy0">/</span>xdissent<span class="sy0">/</span>ievms<span class="sy0">/</span>master<span class="sy0">/</span>ievms.sh <span class="sy0">|</span> <span class="kw2">bash</span></pre></div></div></div></div></div></div></div><p><strong>Install Internet Explorer 7 Only</strong></p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">curl <span class="re5">-s</span> https:<span class="sy0">//</span>raw.github.com<span class="sy0">/</span>xdissent<span class="sy0">/</span>ievms<span class="sy0">/</span>master<span class="sy0">/</span>ievms.sh <span class="sy0">|</span> <span class="re2">IEVMS_VERSIONS</span>=<span class="st0">&quot;7&quot;</span> <span class="kw2">bash</span></pre></div></div></div></div></div></div></div><p><strong>Install Internet Explorer 8 Only</strong></p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">curl <span class="re5">-s</span> https:<span class="sy0">//</span>raw.github.com<span class="sy0">/</span>xdissent<span class="sy0">/</span>ievms<span class="sy0">/</span>master<span class="sy0">/</span>ievms.sh <span class="sy0">|</span> <span class="re2">IEVMS_VERSIONS</span>=<span class="st0">&quot;8&quot;</span> <span class="kw2">bash</span></pre></div></div></div></div></div></div></div><p><strong>Install Internet Explorer 9 Only</strong></p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">curl <span class="re5">-s</span> https:<span class="sy0">//</span>raw.github.com<span class="sy0">/</span>xdissent<span class="sy0">/</span>ievms<span class="sy0">/</span>master<span class="sy0">/</span>ievms.sh <span class="sy0">|</span> <span class="re2">IEVMS_VERSIONS</span>=<span class="st0">&quot;9&quot;</span> <span class="kw2">bash</span></pre></div></div></div></div></div></div></div><p>3. Open VirtualBox and launch your virtual machine. You will be prompted to type in account password, which is &#8220;Password1&#8243;. The password is also in the &#8220;Passowd hint&#8221; field if you forget it.</p><p>Cheers<br
/> Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/osx/ie6-ie7-ie8-ie9/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>opendiff and FileMerge on OS X</title><link>http://www.markomedia.com.au/osx/opendiff-and-filemerge-on-os-x/</link> <comments>http://www.markomedia.com.au/osx/opendiff-and-filemerge-on-os-x/#comments</comments> <pubDate>Sun, 15 Jan 2012 01:01:24 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[OS X]]></category> <category><![CDATA[difftool]]></category> <category><![CDATA[filemerge]]></category> <category><![CDATA[opendiff]]></category> <category><![CDATA[utilities]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1779</guid> <description><![CDATA[Today I discovered opendiff tool that&#8217;s native to OS X &#8211; provided you have installed the Xcode on your system. It allows you to compare 2 directories and perform actions such as merge-left, merge-right etc&#8230; Opendiff simply launches FileMerge OS X utility, which is another one I didn&#8217;t know about, and displays differences between 2...]]></description> <content:encoded><![CDATA[<p>Today I discovered <strong>opendiff</strong> tool that&#8217;s native to OS X &#8211; provided you have installed the Xcode on your system. It allows you to compare 2 directories and perform actions such as merge-left, merge-right etc&#8230;</p><p>Opendiff simply launches FileMerge OS X utility, which is another one I didn&#8217;t know about, and displays differences between 2 selected directories.</p><p>The very simple command to compare 2 directories is:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">opendiff dir1 dir2</pre></div></div></div></div></div></div></div><p>This will then launch FileMerge utility and give you a nice visual representation of differences in your folders:<br
/> <a
class="frame-holder aligncenter" href="http://www.markomedia.com.au/wp-content/uploads/2012/01/Screen-Shot-2012-01-15-at-12.00.54-PM.png" rel="shadowbox"><img
title="FileMerge" src="http://www.markomedia.com.au/wp-content/uploads/2012/01/Screen-Shot-2012-01-15-at-12.00.54-PM-300x161.png" alt="FileMerge" width="300" height="161" /></a><br
/> <a
class="frame-holder aligncenter" href="http://www.markomedia.com.au/wp-content/uploads/2012/01/Screen-Shot-2012-01-15-at-11.51.42-AM.png" rel="shadowbox"><img
title="FileMerge" src="http://www.markomedia.com.au/wp-content/uploads/2012/01/Screen-Shot-2012-01-15-at-11.51.42-AM-300x86.png" alt="FileMerge" width="300" height="86" /></a></p><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/osx/opendiff-and-filemerge-on-os-x/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bandwidth throttling on OS X</title><link>http://www.markomedia.com.au/networking/bandwidth-throttling-on-os-x/</link> <comments>http://www.markomedia.com.au/networking/bandwidth-throttling-on-os-x/#comments</comments> <pubDate>Mon, 19 Dec 2011 12:46:24 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[Networking]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[networking]]></category> <category><![CDATA[OS X]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1775</guid> <description><![CDATA[I&#8217;ve been using Charles HTTTP Proxy for bandwidth throttling and network monitoring in general. It&#8217;s a great little tool, but when it comes to bandwidth throttling, it will only throttle HTTP and HTTPS traffic on ports 80 and 443 respectively. I thought there had to be a way to throttle bandwidth on any port using...]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been using <a
title="Charles HTTP Proxy" href="http://www.charlesproxy.com/">Charles HTTTP Proxy</a> for bandwidth throttling and network monitoring in general. It&#8217;s a great little tool, but when it comes to bandwidth throttling, it will only throttle HTTP and HTTPS traffic on ports 80 and 443 respectively.</p><p>I thought there had to be a way to throttle bandwidth on any port using the native <a
title="IP firewall and traffic shaper program" href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/ipfw.8.html">IP firewall and traffic shaper program</a>. After reading up the documentation for ipfw, I figured out a way to throttle speed on any outgoing port.</p><p>For example, the following example will create a pipe that will allow 25Kb/s to go through port 1935.</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">sudo</span> ipfw pipe <span class="nu0">1</span> config bw 25KByte<span class="sy0">/</span>s
<span class="kw2">sudo</span> ipfw add <span class="nu0">1</span> pipe <span class="nu0">1</span> src-port <span class="nu0">1935</span></pre></div></div></div></div></div></div></div><p>To disable throttling, simply delete the throttling rule:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">sudo</span> ipfw delete <span class="nu0">1</span></pre></div></div></div></div></div></div></div><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/networking/bandwidth-throttling-on-os-x/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>bash script useful tips</title><link>http://www.markomedia.com.au/linux/bash-script-useful-tips/</link> <comments>http://www.markomedia.com.au/linux/bash-script-useful-tips/#comments</comments> <pubDate>Wed, 30 Nov 2011 00:08:15 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Shell]]></category> <category><![CDATA[bash]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1767</guid> <description><![CDATA[At Learnosity I&#8217;ve spent last 2 days scripting virtual server deployment on Amazon cloud. For my reference, these are some useful commands I had to use to get the job done. 1. Hash &#8220;Hello World&#8221; string using SHA256 algorithm echo -n &#34;Hello World&#34; &#124; shasum -a 256 You can also hash a file shasum -a...]]></description> <content:encoded><![CDATA[<p>At <a
href="http://www.learnosity.com" title="Learnosity">Learnosity</a> I&#8217;ve spent last 2 days scripting virtual server deployment on Amazon cloud. For my reference, these are some useful commands I had to use to get the job done.<br
/> 1. Hash &#8220;Hello World&#8221; string using SHA256 algorithm</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw3">echo</span> <span class="re5">-n</span> <span class="st0">&quot;Hello World&quot;</span> <span class="sy0">|</span> shasum <span class="re5">-a</span> <span class="nu0">256</span></pre></div></div></div></div></div></div></div><p>You can also hash a file</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">shasum <span class="re5">-a</span> <span class="nu0">256</span> myfile.ext</pre></div></div></div></div></div></div></div><p>2. Display server IP address by stripping out all other network information, including the local 127.0.0.1 IP</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">ifconfig</span>  <span class="sy0">|</span> <span class="kw2">grep</span> <span class="st_h">'inet addr:'</span><span class="sy0">|</span> <span class="kw2">grep</span> <span class="re5">-v</span> <span class="st_h">'127.0.0.1'</span> <span class="sy0">|</span> <span class="kw2">cut</span> -d: <span class="re5">-f2</span> <span class="sy0">|</span> <span class="kw2">awk</span> <span class="st_h">'{ print $1}'</span></pre></div></div></div></div></div></div></div><p>3. Read out first 64 characters from a long string</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="co1">${mystring:0:64}</span></pre></div></div></div></div></div></div></div><p>4. While loop with 10 iterations</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="re2">i</span>=<span class="nu0">0</span>;
<span class="kw1">while</span> <span class="br0">&#91;</span> <span class="re1">$i</span> <span class="re5">-lt</span> <span class="nu0">10</span> <span class="br0">&#93;</span>
<span class="kw1">do</span>
    <span class="kw3">echo</span> <span class="re1">$i</span>
    <span class="re2">i</span>=$<span class="br0">&#91;</span><span class="re1">$i</span>+<span class="nu0">1</span><span class="br0">&#93;</span>
<span class="kw1">done</span></pre></div></div></div></div></div></div></div><p>5. Replace contents of a file. For example search for string1, replace with string2 in myfile.txt</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">sed</span> <span class="re5">-e</span> <span class="st0">&quot;s/string1/string2/g&quot;</span> myfile.txt <span class="sy0">&gt;</span> myfile.txt_temp
<span class="kw2">mv</span> myfile.txt_temp myfile.txt</pre></div></div></div></div></div></div></div><p>6. Display number of CPU processors on Linux<br
/> The command simply pulls out all instances of the word &#8216;processor&#8217; from /proc/cpuinfo and returns the word count of it.</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">cat</span> <span class="sy0">/</span>proc<span class="sy0">/</span>cpuinfo <span class="sy0">|</span> <span class="kw2">grep</span> processor <span class="sy0">|</span> <span class="kw2">wc</span> <span class="re5">-l</span></pre></div></div></div></div></div></div></div><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/linux/bash-script-useful-tips/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>apr_sockaddr_info_get() failed for mydomain.com</title><link>http://www.markomedia.com.au/apache/apr_sockaddr_info_get-failed-for-mydomain-com/</link> <comments>http://www.markomedia.com.au/apache/apr_sockaddr_info_get-failed-for-mydomain-com/#comments</comments> <pubDate>Thu, 24 Nov 2011 09:46:19 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[Apache]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1762</guid> <description><![CDATA[I recently changed my ISP from Optus to TPG and when I tried to start my local apache instance and I got this error httpd: apr_sockaddr_info_get&#40;&#41; failed for 192-168-1-107.tpgi.com.au httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName That gave me a hint that my local hostname had changed....]]></description> <content:encoded><![CDATA[<p>I recently changed my ISP from Optus to TPG and when I tried to start my local apache instance and I got this error</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">httpd: apr_sockaddr_info_get<span class="br0">&#40;</span><span class="br0">&#41;</span> failed <span class="kw1">for</span> <span class="nu0">192</span>-<span class="nu0">168</span>-<span class="nu0">1</span>-<span class="nu0">107</span>.tpgi.com.au
httpd: Could not reliably determine the server<span class="st_h">'s fully qualified domain name, using 127.0.0.1 for ServerName</span></pre></div></div></div></div></div></div></div><p>That gave me a hint that my local hostname had changed.  I reset it back to what it was originally like this:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1"><span class="kw2">sudo</span> <span class="kw2">hostname</span> myoldhostname.local</pre></div></div></div></div></div></div></div><p>Restarted apache and it was smooth sailing again.</p><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/apache/apr_sockaddr_info_get-failed-for-mydomain-com/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>AES-128 padded encryption/decryption with Railo, Java and AS3</title><link>http://www.markomedia.com.au/java/aes-128-padded-encryptiondecryption-with-railo-java-and-as3/</link> <comments>http://www.markomedia.com.au/java/aes-128-padded-encryptiondecryption-with-railo-java-and-as3/#comments</comments> <pubDate>Fri, 14 Oct 2011 14:05:43 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[AS3]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[Railo]]></category> <category><![CDATA[java]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1752</guid> <description><![CDATA[I&#8217;ve recently been working on text file decryption using Railo server. My files were encrypted in ActionScript 3 with the powerful AES-128 algorithm. For more info on AS3 encryption see Hurlant Crypto demo. My challenge was to decypt this heavily encrypted content on a different platform, i.e. Railo with underlying Java Cipher capabilities. The 6...]]></description> <content:encoded><![CDATA[<p>I&#8217;ve recently been working on text file decryption using Railo server. My files were encrypted in ActionScript 3 with the powerful AES-128 algorithm. For more info on AS3 encryption see <a
title="Hurlant Crypto demo" href="http://crypto.hurlant.com/demo/">Hurlant Crypto demo</a>.</p><p>My challenge was to decypt this heavily encrypted content on a different platform, i.e. Railo with underlying Java Cipher capabilities.</p><p>The 6 things I knew about the encrypted content were:<br
/> 1. Encryption Method &#8211; AES<br
/> 2. Mode &#8211; CBC (Cipher-block chaining)<br
/> 3. Padding &#8211; PKCS5<br
/> 4. Initialisation Vector (IV) &#8211; given hex string<br
/> 5. Passphrase &#8211; given hex string<br
/> 6. Encrypted text file saved in base64 encoded string.</p><p>For my records, this is how I went about decrypting on Railo:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="cfm"><pre class="de1"><span class="sc5"><span class="sy0">&lt;</span><span class="kw1">cfscript</span><span class="sy0">&gt;</span></span>
// Create some java objects
IvParameterSpec = createObject(&quot;java&quot;, &quot;javax.crypto.spec.IvParameterSpec&quot;);
Cipher = createObject(&quot;java&quot;, &quot;javax.crypto.Cipher&quot;);
SecretKeySpec = createObject(&quot;java&quot;, &quot;javax.crypto.spec.SecretKeySpec&quot;);
BASE64Decoder = createObject(&quot;java&quot;, &quot;sun.misc.BASE64Decoder&quot;);
Str = createObject(&quot;java&quot;, &quot;java.lang.String&quot;);
MessageDigest = createObject(&quot;java&quot;, &quot;java.security.MessageDigest&quot;);
&nbsp;
encryptedFileContent = &quot;base64encodedcontent&quot;;
password = binarydecode(&quot;somehexpassphrase&quot;, &quot;hex&quot;);
iv = binarydecode(&quot;somehexivstring&quot;, &quot;hex&quot;);
&nbsp;
skeySpec = SecretKeySpec.init(password, &quot;AES&quot;);
ivSpec = IvParameterSpec.init(iv);
cipher = Cipher.getInstance(&quot;AES/CBC/PKCS5Padding&quot;);
&nbsp;
encryptedContent = BASE64Decoder.decodeBuffer(encryptedFileContent);
cipher.init(Cipher.DECRYPT_MODE,skeySpec,ivSpec);
decryptedBytes = cipher.doFinal(encryptedContent);
decryptedString = Str.init(decryptedBytes);
<span class="sc5"><span class="sy0">&lt;/</span><span class="kw1">cfscript</span><span class="sy0">&gt;</span></span></pre></div></div></div></div></div></div></div><p>Now that we know how the decryption works, encrypting data on Railo should be a piece of cake. For example:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="cfm"><pre class="de1"><span class="sc5"><span class="sy0">&lt;</span><span class="kw1">cfscript</span><span class="sy0">&gt;</span></span>
password = &quot;somepassphrase&quot;;
stringToEncrypt = &quot;stringToEncrypt&quot;;
md = MessageDigest.getInstance(&quot;MD5&quot;);
md.update(password.getBytes(&quot;UTF-8&quot;), 0, password.length());
rawKey = md.digest();
&nbsp;
skeySpec = SecretKeySpec.init(rawKey, &quot;AES&quot;);
ivSpec = IvParameterSpec.init(rawKey);
cipher = Cipher.getInstance(&quot;AES/CBC/PKCS5Padding&quot;);
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivSpec);
&nbsp;
encryptedbytes = cipher.doFinal(stringToEncrypt.getBytes());
<span class="sc5"><span class="sy0">&lt;/</span><span class="kw1">cfscript</span><span class="sy0">&gt;</span></span></pre></div></div></div></div></div></div></div><p>The only thing you need to be aware of is the format of parameters passed into encryption/decryption logic, and convert them appropriately. These parameters can be either plain, base64 or hex strings.</p><p>Who would&#8217;ve thought that reverse engineering could be som much fun <img
src='http://www.markomedia.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Cheers<br
/> Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/java/aes-128-padded-encryptiondecryption-with-railo-java-and-as3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Compile Apache2 from source on OS X</title><link>http://www.markomedia.com.au/apache/compile-apache2-from-source-on-os-x/</link> <comments>http://www.markomedia.com.au/apache/compile-apache2-from-source-on-os-x/#comments</comments> <pubDate>Sat, 08 Oct 2011 04:43:21 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[Apache]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1744</guid> <description><![CDATA[I&#8217;ve had to reinstall apache server on my Mac and the only way to do it cleanly was to nuke my existing apache installation and compile a fresh one from source. That&#8217;s all cool, but I could never remember what modules I needed and how to enable them.  If you don&#8217;t load any modules at...]]></description> <content:encoded><![CDATA[<p>I&#8217;ve had to reinstall apache server on my Mac and the only way to do it cleanly was to nuke my existing apache installation and compile a fresh one from source.</p><p>That&#8217;s all cool, but I could never remember what modules I needed and how to enable them.  If you don&#8217;t load any modules at compile time, this is the most likely error you&#8217;ll get when you start apache web server:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">Invalid <span class="kw3">command</span> <span class="st_h">'Order'</span>, perhaps misspelled or defined by a module not included <span class="kw1">in</span> the server configuration</pre></div></div></div></div></div></div></div><p>So the following steps worked well for me.</p><p>1. <a
title="Apache 2.2 Web Server source code" href="http://httpd.apache.org/download.cgi#apache22">Download Apache 2.2 source code<br
/> </a><br
/> 2. Extract the source code and configure apache with required modules. These modules are the ones I normally need. You can customise this to your needs:</p><div
class="wp-geshi-highlight-wrap5"><div
class="wp-geshi-highlight-wrap4"><div
class="wp-geshi-highlight-wrap3"><div
class="wp-geshi-highlight-wrap2"><div
class="wp-geshi-highlight-wrap"><div
class="wp-geshi-highlight"><div
class="bash"><pre class="de1">.<span class="sy0">/</span>configure  <span class="re5">--prefix</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>apache2 \
<span class="re5">--enable-mods-shared</span>=all \
<span class="re5">--enable-shared</span> \
<span class="re5">--enable-deflate</span> \
<span class="re5">--enable-proxy</span> \
<span class="re5">--enable-proxy-http</span> \
<span class="re5">--enable-ssl</span> \
<span class="re5">--enable-cgi</span> \
<span class="re5">--enable-cgid</span> \
<span class="re5">--enable-cache</span>
&nbsp;
<span class="kw2">make</span> \
&nbsp;
<span class="kw2">make</span> <span class="kw2">install</span> \</pre></div></div></div></div></div></div></div><p>Check /usr/local/apache2/modules directory and make sure required modules have been installed.</p><p>Marko</p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/apache/compile-apache2-from-source-on-os-x/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Extract z01 files on Mac OS X &#8211; howto</title><link>http://www.markomedia.com.au/osx/extract-z01-files-on-mac-os-x-howto/</link> <comments>http://www.markomedia.com.au/osx/extract-z01-files-on-mac-os-x-howto/#comments</comments> <pubDate>Thu, 22 Sep 2011 12:22:25 +0000</pubDate> <dc:creator>Marko Tomic</dc:creator> <category><![CDATA[HOWTO]]></category> <category><![CDATA[OS X]]></category><guid
isPermaLink="false">http://www.markomedia.com.au/?p=1739</guid> <description><![CDATA[The first of multiple files that make up a split archive created with WinZip; uses the same compression as a standard .ZIP file, but must be decompressed along with the related split archives (.Z02, .Z03, etc.). Split archives are often used to shrink the size of large files for e-mail attachments or file downloads. They...]]></description> <content:encoded><![CDATA[<p>The first of multiple files that make up a split archive created with WinZip; uses the same compression as a standard .ZIP file, but must be decompressed along with the related split archives (.Z02, .Z03, etc.).</p><p>Split archives are often used to shrink the size of large files for e-mail attachments or file downloads. They can only be decompressed if all the split archive segments are available.</p><p>To decompress a series of z01, z02&#8230; files you need to do the following</p><p>1) Change all .z01, .z02 extensions to .001, .002 and so on.<br
/> 2) The last extension in compressed series will have a .zip extension. If you have 8 segments, change .zip to .008.<br
/> 3) Join all segments using &#8220;<a
title="MacHacha" href="http://homepage.mac.com/julifos/soft/machacha/index.html">MacHacha</a>&#8221;<br
/> 4) Change the extension of the file produced by <a
href="http://homepage.mac.com/julifos/soft/machacha/index.html">MacHacha</a> to .zip<br
/> 5) Use &#8220;<a
href="http://wakaba.c3.cx/s/apps/unarchiver.html">The Unarchiver</a>&#8221; to decompress the .zip file produced by MacHacha.</p><p>References:<br
/> <a
title="z01 extension" href="http://www.fileinfo.com/extension/z01">http://www.fileinfo.com/extension/z01</a></p> ]]></content:encoded> <wfw:commentRss>http://www.markomedia.com.au/osx/extract-z01-files-on-mac-os-x-howto/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 11/15 queries in 0.004 seconds using disk: basic
Object Caching 762/764 objects using disk: basic

Served from: www.markomedia.com.au @ 2012-05-20 17:55:55 -->
