<?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>mikwat code</title>
	<atom:link href="http://code.mikwat.com/feed" rel="self" type="application/rss+xml" />
	<link>http://code.mikwat.com</link>
	<description>A coder's daily explorations through PHP, Java, CSS, JavaScript, Linux, OS X, Apache, Tomcat, and everything else.</description>
	<lastBuildDate>Tue, 08 Mar 2011 19:23:33 +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>Monitoring MySQL Import Progress</title>
		<link>http://code.mikwat.com/archives/47</link>
		<comments>http://code.mikwat.com/archives/47#comments</comments>
		<pubDate>Tue, 08 Mar 2011 19:22:27 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/?p=47</guid>
		<description><![CDATA[When importing a large MySQL dump file, use pv to monitor the progress of data through a pipe: pv -petr dumpfile.sql &#124; mysql -uroot my_database This will give you a progress indicator such as: 0:00:05 [3.63MB/s] [===>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;] 0% ETA 0:09:41]]></description>
			<content:encoded><![CDATA[<p>When importing a large MySQL dump file, use pv to monitor the progress of data through a pipe:<br />
<code>pv -petr dumpfile.sql | mysql -uroot my_database</code></p>
<p>This will give you a progress indicator such as:<br />
<code>0:00:05 [3.63MB/s] [===>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]  0% ETA 0:09:41</code></p>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/47/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL Bulk Insert from CSV file</title>
		<link>http://code.mikwat.com/archives/15</link>
		<comments>http://code.mikwat.com/archives/15#comments</comments>
		<pubDate>Fri, 18 Feb 2011 00:10:38 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/?p=15</guid>
		<description><![CDATA[http://www.thescripts.com/forum/thread158756.html BULK INSERT Test FROM 'X:\temp\Test.CSV' WITH ( DATAFILETYPE = 'char', FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) Could not bulk insert because file &#8216;X:\temp\Test.CSV&#8217; could not be opened. Operating system error code 3(The system cannot find the path specified.). http://support.microsoft.com/kb/316371 objBL.transaction = "FALSE"]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thescripts.com/forum/thread158756.html" onclick="pageTracker._trackPageview('/outgoing/www.thescripts.com/forum/thread158756.html?referer=');">http://www.thescripts.com/forum/thread158756.html</a></p>
<pre>
BULK INSERT Test FROM 'X:\temp\Test.CSV'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
</pre>
<p>Could not bulk insert because file &#8216;X:\temp\Test.CSV&#8217; could not be opened. Operating system error code 3(The system cannot find the path specified.).</p>
<p><a href="http://support.microsoft.com/kb/316371" onclick="pageTracker._trackPageview('/outgoing/support.microsoft.com/kb/316371?referer=');">http://support.microsoft.com/kb/316371</a></p>
<pre class="code">objBL.transaction = "FALSE"</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/15/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IllegalStateException: getAttribute: Session already invalidated</title>
		<link>http://code.mikwat.com/archives/19</link>
		<comments>http://code.mikwat.com/archives/19#comments</comments>
		<pubDate>Thu, 17 Feb 2011 23:57:50 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/?p=19</guid>
		<description><![CDATA[http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/cluster/session/DeltaSession.html http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg124558.html]]></description>
			<content:encoded><![CDATA[<p><a href="http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/cluster/session/DeltaSession.html" onclick="pageTracker._trackPageview('/outgoing/tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/cluster/session/DeltaSession.html?referer=');">http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/cluster/session/DeltaSession.html</a></p>
<p><a href="http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg124558.html" onclick="pageTracker._trackPageview('/outgoing/www.mail-archive.com/tomcat-user_jakarta.apache.org/msg124558.html?referer=');">http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg124558.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/19/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>uninitialized constant MysqlCompat::MysqlRes</title>
		<link>http://code.mikwat.com/archives/37</link>
		<comments>http://code.mikwat.com/archives/37#comments</comments>
		<pubDate>Thu, 09 Dec 2010 17:12:29 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/?p=37</guid>
		<description><![CDATA[After getting the dreaded uninitialized constant MysqlCompat::MysqlRes error on OS X Snow Leopard, I finally found a solution. Error: $ rake db:migrate ... rake aborted! uninitialized constant MysqlCompat::MysqlRes Solution from http://techliberty.blogspot.com/: sudo gem uninstall mysql sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config]]></description>
			<content:encoded><![CDATA[<p>After getting the dreaded <code>uninitialized constant MysqlCompat::MysqlRes</code> error on OS X Snow Leopard, I finally found a solution.</p>
<p>Error:</p>
<pre>
$ rake db:migrate
...
rake aborted!
uninitialized constant MysqlCompat::MysqlRes
</pre>
<p>Solution from <a href="http://techliberty.blogspot.com/" onclick="pageTracker._trackPageview('/outgoing/techliberty.blogspot.com/?referer=');">http://techliberty.blogspot.com/</a>:</p>
<pre>
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/37/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing/Upgrading Passenger + Nginx</title>
		<link>http://code.mikwat.com/archives/27</link>
		<comments>http://code.mikwat.com/archives/27#comments</comments>
		<pubDate>Tue, 07 Dec 2010 18:45:32 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/?p=27</guid>
		<description><![CDATA[After numerous searches, I found this post extremely helpful: http://www.jotlab.com/2009/11/08/installing-ruby-on-rails-mysql-imagemagick-nginx-passenger-with-macports/ Highlights: Install or update Passenger: sudo gem install passenger Find Passenger install path: passenger-config --root Configure MacPorts to use Passenger varient of Nginx: cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/www/nginx Open config file: sudo vi Portfile Insert at the bottom of the file: variant passenger description {Adds passenger support} { [...]]]></description>
			<content:encoded><![CDATA[<p>After numerous searches, I found this post extremely helpful:<br />
<a href="http://www.jotlab.com/2009/11/08/installing-ruby-on-rails-mysql-imagemagick-nginx-passenger-with-macports/" onclick="pageTracker._trackPageview('/outgoing/www.jotlab.com/2009/11/08/installing-ruby-on-rails-mysql-imagemagick-nginx-passenger-with-macports/?referer=');">http://www.jotlab.com/2009/11/08/installing-ruby-on-rails-mysql-imagemagick-nginx-passenger-with-macports/</a></p>
<p>Highlights:</p>
<p>Install or update Passenger:<br />
<code>sudo gem install passenger</code></p>
<p>Find Passenger install path:<br />
<code>passenger-config --root</code></p>
<p>Configure MacPorts to use Passenger varient of Nginx:<br />
<code>cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/www/nginx</code></p>
<p>Open config file:<br />
<code>sudo vi Portfile</code></p>
<p>Insert at the bottom of the file:</p>
<pre>
variant passenger description {Adds passenger support} {
    configure.args-append  --add-module=/Library/Ruby/Gems/1.8/gems/passenger-3.0.1/ext/nginx
}
</pre>
<p>Install/update Nginx:<br />
<code>sudo port install nginx +gzip_static +passenger +ssl</code></p>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/27/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH Tunnel in OS X</title>
		<link>http://code.mikwat.com/archives/26</link>
		<comments>http://code.mikwat.com/archives/26#comments</comments>
		<pubDate>Wed, 20 Feb 2008 22:13:28 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/archives/26</guid>
		<description><![CDATA[Open tunnel: $ ssh -L 8080:remote-host:80 -f -C -q -N me@myserver.com Close tunnel: $ ps -aux &#124; grep ssh $ kill {pid}]]></description>
			<content:encoded><![CDATA[<p>Open tunnel:<br />
<code><br />
$ ssh -L 8080:remote-host:80 -f -C -q -N me@myserver.com<br />
</code></p>
<p>Close tunnel:<br />
<code><br />
$ ps -aux | grep ssh<br />
$ kill {pid}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/26/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quartz + Spring + Hibernate with JDBC Job Store</title>
		<link>http://code.mikwat.com/archives/24</link>
		<comments>http://code.mikwat.com/archives/24#comments</comments>
		<pubDate>Thu, 04 Oct 2007 23:25:15 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[quartz]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/archives/24</guid>
		<description><![CDATA[Here is how I configured Quartz to work with Spring and Hibernate. I&#8217;m using the Quartz JDBC Job Store which stores and retrieves the job settings from a database instead of a static configuration. I use the SchedulerFactoryBean to manager the Quartz Scheduler lifecycle. spring-servlet.xml ... &#60;!-- Quartz --&#62; &#60;bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&#62; &#60;property name="applicationContextSchedulerContextKey" value="applicationContext"/&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how I configured Quartz to work with Spring and Hibernate.  I&#8217;m using the Quartz JDBC Job Store which stores and retrieves the job settings from a database instead of a static configuration.</p>
<p>I use the <a href="http://static.springframework.org/spring/docs/1.2.x/api/index.html?org/springframework/orm/hibernate3/HibernateTransactionManager.html" onclick="pageTracker._trackPageview('/outgoing/static.springframework.org/spring/docs/1.2.x/api/index.html?org/springframework/orm/hibernate3/HibernateTransactionManager.html&amp;referer=');">SchedulerFactoryBean</a> to manager the Quartz Scheduler lifecycle.</p>
<p><b>spring-servlet.xml</b></p>
<pre>
...
	&lt;!-- Quartz --&gt;
	&lt;bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt;
		&lt;property name="applicationContextSchedulerContextKey" value="applicationContext"/&gt;
		&lt;property name="configLocation" value="classpath:quartz.properties"/&gt;
	&lt;/bean&gt;
...
</pre>
<p>The Quartz settings are stored in a quartz.properties file so that they can be unique to each instance of the web application.  This setup requires that quartz.properties be on the classpath.  This file defines the JDBC connection for Quartz to use.</p>
<p><b>quartz.properties</b></p>
<pre>
...
org.quartz.dataSource.myDS.jndiURL=java:comp/env/jdbc/MyDS
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=JB_
org.quartz.jobStore.useProperties=true
</pre>
<p><b>MyBaseJob</b></p>
<pre>
public abstract class MyBaseJob extends QuartzJobBean
{
    private transient ApplicationContext applicationContext = null;

    public ApplicationContext getApplicationContext()
    {
        return applicationContext;
    }

    public void setApplicationContext(ApplicationContext applicationContext)
    {
        this.applicationContext = applicationContext;
    }
}
</pre>
<p>Each of my job classes extend MyBaseJob, overriding <code>executeInternal</code>.  The jobs can use the <code>applicationContext</code> to lookup Spring service beans.  In my environment these service beans extend <code>HibernateDaoSupport</code>.</p>
<pre>
    protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException
    {
        MyServiceManager sm = applicationContext.getBean("myServiceManager"); // lookup Spring service bean
        ...
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/24/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find and Replace String in Multiple Files</title>
		<link>http://code.mikwat.com/archives/23</link>
		<comments>http://code.mikwat.com/archives/23#comments</comments>
		<pubDate>Mon, 01 Oct 2007 22:53:11 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/archives/23</guid>
		<description><![CDATA[Periodically I need to replace a string in multiple files on Linux. I find myself looking up this command or a variant every time. grep -rl OLDSTRING *.FILEEXTENSION &#124; xargs perl -pi~ -e 's/OLDSTRING/NEWSTRING/']]></description>
			<content:encoded><![CDATA[<p>Periodically I need to replace a string in multiple files on Linux.  I find myself looking up this command or a variant every time.</p>
<p><code>grep -rl OLDSTRING *.FILEEXTENSION | xargs perl -pi~ -e 's/OLDSTRING/NEWSTRING/'</code></p>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/23/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSL + gzip Compression with Apache and Tomcat</title>
		<link>http://code.mikwat.com/archives/21</link>
		<comments>http://code.mikwat.com/archives/21#comments</comments>
		<pubDate>Mon, 27 Aug 2007 16:28:25 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/archives/21</guid>
		<description><![CDATA[My setup is a single Fedora Core 6 server running Apache 2.2.4 (with mod_ssl and mod_proxy) and Tomcat 5. With mod_ssl the following virtualhost is setup using an SSL certificate from GoDaddy. Notice the SSLCertificateChainFile /etc/httpd/conf/ssl.crt/gd_intermediate_bundle.crt reference. This intermediate certificate comes from GoDaddy and is required. I didn&#8217;t catch this at first and couldn&#8217;t understand [...]]]></description>
			<content:encoded><![CDATA[<p>My setup is a single Fedora Core 6 server running <a href="/archives/category/apache">Apache</a> 2.2.4 (with mod_ssl and mod_proxy) and <a href="/archives/category/tomcat">Tomcat</a> 5.</p>
<p>With <strong>mod_ssl</strong> the following virtualhost is setup using an SSL certificate from GoDaddy.  Notice the <strong>SSLCertificateChainFile /etc/httpd/conf/ssl.crt/gd_intermediate_bundle.crt</strong> reference.  This intermediate certificate comes from GoDaddy and is required.  I didn&#8217;t catch this at first and couldn&#8217;t understand what my web browser was unhappy about.  When I called GoDaddy support they told me my certificate was setup correctly and worked in all of there &#8220;off-site&#8221; test browsers.  They were no help, so I continued to dig around and finally found the answer.</p>
<p>The <strong>mod_proxy</strong> lines pass all requests to the <a href="/archives/category/tomcat">Tomcat</a> instance listening on port 9014.</p>
<p><b>/etc/httpd/conf.d/ssl.conf</b></p>
<pre>
&lt;virtualhost&gt;
DocumentRoot  /var/www/html/
ServerName    myserver.com:433</virtualhost>  SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt/myserver.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/myserver.key
SSLCertificateChainFile /etc/httpd/conf/ssl.crt/gd_intermediate_bundle.crt
SetEnvIf User-Agent ".*MSIE.*"
         nokeepalive ssl-unclean-shutdown
         downgrade-1.0 force-response-1.0
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
CustomLog logs/ssl_request_log
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

ProxyPreserveHost On
ProxyPass / http://localhost:9014/
ProxyPassReverse / http://localhost:9014/
SetEnv proxy-nokeepalive 1
&lt;/virtualserver&gt;
</pre>
<p>For the <a href="/archives/category/tomcat">Tomcat</a> setup, a proxy connector is configured to listen on port 9014 and to proxy port 443 requests (SSL).  The communication between <a href="/archives/category/apache">Apache</a> and <a href="/archives/category/tomcat">Tomcat</a> is not secure, but this is not a concern since this communication is local to the server.  Finally, compression is turned on for several common mime-types.</p>
<p><b>server.xml</b></p>
<pre>
  ...
  &lt;Connector acceptCount="100" connectionTimeout="60000" disableUploadTimeout="true" port="9014" redirectPort="8944"
  scheme="https" proxyPort="443" compression="on" compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript"/&gt;
  ...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/21/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problems using Digester in custom Struts Plugin</title>
		<link>http://code.mikwat.com/archives/18</link>
		<comments>http://code.mikwat.com/archives/18#comments</comments>
		<pubDate>Tue, 24 Jul 2007 21:49:22 +0000</pubDate>
		<dc:creator>mikwat</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://code.mikwat.com/archives/18</guid>
		<description><![CDATA[In migrating from Tomcat 5.0 to Tomcat 5.5, one of my custom Struts plugins started failing on startup with the following exception: org.apache.commons.digester.Digester startElement SEVERE: Begin event threw exception java.lang.ClassNotFoundException: com.mikwat.struts.config.AuthorizationActionConfig The root of the problems appears to be that the Digester defaults to using the same ClassLoader that loaded it and whichever ClassLoader this [...]]]></description>
			<content:encoded><![CDATA[<p>In migrating from <a href="/archives/category/tomcat">Tomcat</a> 5.0 to <a href="/archives/category/tomcat">Tomcat </a>5.5, one of my custom Struts plugins started failing on startup with the following exception:</p>
<pre>
org.apache.commons.digester.Digester startElement
SEVERE: Begin event threw exception
java.lang.ClassNotFoundException: com.mikwat.struts.config.AuthorizationActionConfig</pre>
<p>The root of the problems appears to be that the Digester defaults to using the same ClassLoader that loaded it and whichever ClassLoader this is, it doesn&#8217;t have access to my webapp class <code>com.mikwat.struts.config.AuthorizationActionConfig</code>.</p>
<p>After Googling around, I eventually came across this post regarding a similar problem loading the Quartz plugin: <a href="http://mail-archives.apache.org/mod_mbox/struts-user/200305.mbox/%3CB40B3D4758FBFD4AA8C4F3A015DE4446011DF774@sTamExchange1.paymentech.us%3E" onclick="pageTracker._trackPageview('/outgoing/mail-archives.apache.org/mod_mbox/struts-user/200305.mbox/_3CB40B3D4758FBFD4AA8C4F3A015DE4446011DF774_sTamExchange1.paymentech.us_3E?referer=');">Mailing list archives</a>.</p>
<p>The solution is to call setUseContextClassLoader(true) on the Digester object which forces it to use the ClassLoader found by calling <code>Thread.currentThread().getContextClassLoader()</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mikwat.com/archives/18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

