<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4113137560643006742</id><updated>2011-11-27T16:41:24.508-08:00</updated><category term='opennlp'/><category term='apache'/><category term='nlp'/><category term='LAMP'/><category term='mysql'/><category term='getting started with nlp'/><category term='permission'/><title type='text'>Code insights</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codeinsights.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codeinsights.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>vikas</name><uri>http://www.blogger.com/profile/17139064836239545202</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4113137560643006742.post-9123446548471448070</id><published>2010-12-22T02:27:00.000-08:00</published><updated>2010-12-22T02:34:54.146-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='permission'/><category scheme='http://www.blogger.com/atom/ns#' term='LAMP'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><title type='text'>Changing LAMP permission to run as a different user</title><content type='html'>We faced issues in our production server where apache was running as nobody and our crons were running under root and mysql under some other user permissions. The below steps were done by creating a linux user apusr and assigning mysql and apache to run under apusr permissions. Also all crons were moved to crontab under this user profile.&lt;br /&gt;&lt;br /&gt;1. Create a new user apusr and a new group apusr.&lt;br /&gt;&lt;br /&gt;2. Assign a ppassword for the new user apusr&lt;br /&gt;&lt;br /&gt;3. Change the apache config file (httpd.conf)to reflect the new user and group for apache.&lt;br /&gt;User apusr&lt;br /&gt;Group apusr&lt;br /&gt;&lt;br /&gt;3.1 Add user=apusr in the mysqld section in my.cnf file&lt;br /&gt;&lt;br /&gt;And restart apache.&lt;br /&gt;&lt;br /&gt;4. Change the ownership of the /opt folder and any other folder your application is accessing to apusr&lt;br /&gt;chown -R apusr:apusr /opt /mnt&lt;br /&gt;&lt;br /&gt;5. Remove all cron entries from root profile and add to the apusr profile.&lt;br /&gt;&lt;br /&gt;6. Access to the production server as root should be avoided in future&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4113137560643006742-9123446548471448070?l=codeinsights.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeinsights.blogspot.com/feeds/9123446548471448070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4113137560643006742&amp;postID=9123446548471448070' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/9123446548471448070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/9123446548471448070'/><link rel='alternate' type='text/html' href='http://codeinsights.blogspot.com/2010/12/changing-lamp-permission-to-run-as.html' title='Changing LAMP permission to run as a different user'/><author><name>vikas</name><uri>http://www.blogger.com/profile/17139064836239545202</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4113137560643006742.post-5849708428116382548</id><published>2009-02-18T00:08:00.000-08:00</published><updated>2009-02-18T01:11:10.826-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nlp'/><category scheme='http://www.blogger.com/atom/ns#' term='getting started with nlp'/><category scheme='http://www.blogger.com/atom/ns#' term='opennlp'/><title type='text'>Getting started with OpenNLP(Natural Language Processing)</title><content type='html'>I am not someone who have worked much on Java and so when the openNLP tools(www.opennlp.com) were in java i knew i was going to have some difficult time. On top of this the documentation for this is almost non-existent. After spending some time on the net I came across this nice article from Daniel which had code snippets to get started on NLP. He has very well explained the basic starting steps and there is no point in me repeating the steps. This is the link to &lt;a href="http://danielmclaren.net/2007/05/11/getting-started-with-opennlp-natural-language-processing/"&gt;Daniel's blog&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;After some firefighting I have finally been able to write a sample code which can complement steps provided by Daniel.I have uploaded the source code of the same.It contains all required external libraries including maxent, opennlp-tools, opennlp and trove. Also I have included required models to parse english sentences. You can download the code from &lt;a href="http://www.ip2l.com/downloads/nlp.zip"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4113137560643006742-5849708428116382548?l=codeinsights.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeinsights.blogspot.com/feeds/5849708428116382548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4113137560643006742&amp;postID=5849708428116382548' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/5849708428116382548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/5849708428116382548'/><link rel='alternate' type='text/html' href='http://codeinsights.blogspot.com/2009/02/getting-started-with-opennlpnatural.html' title='Getting started with OpenNLP(Natural Language Processing)'/><author><name>vikas</name><uri>http://www.blogger.com/profile/17139064836239545202</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4113137560643006742.post-2352274175771940740</id><published>2008-10-16T02:25:00.000-07:00</published><updated>2008-10-16T02:35:15.704-07:00</updated><title type='text'>Directory locking in perl</title><content type='html'>Directory locking in perl can be achieved by using the file locking construct flock().In the below code, only one thread can access the files contained in the directory. Once the first thread is finished, then only the other thread can start reading the contents of the directory.&lt;br /&gt;&lt;br /&gt;use Fcntl ':flock';&lt;br /&gt;chdir('orders');&lt;br /&gt;open( FILE_LOCK, "&gt;file.lock");&lt;br /&gt;&lt;br /&gt;#Get exclusive lock on a lock file.Waits till the lock is acquired&lt;br /&gt;if (flock FILE_LOCK, LOCK_EX) {&lt;br /&gt;  opendir(DIR, '.');&lt;br /&gt;  @dir_contents = readdir(DIR);&lt;br /&gt;  #Sleep will help you test the code. Run the same code on two different shells&lt;br /&gt;  sleep(5);&lt;br /&gt;  foreach $file (@dir_contents){&lt;br /&gt;    print $file."\n";&lt;br /&gt;  }&lt;br /&gt;  sleep(5);&lt;br /&gt;}&lt;br /&gt;close FILE_LOCK;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4113137560643006742-2352274175771940740?l=codeinsights.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeinsights.blogspot.com/feeds/2352274175771940740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4113137560643006742&amp;postID=2352274175771940740' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/2352274175771940740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/2352274175771940740'/><link rel='alternate' type='text/html' href='http://codeinsights.blogspot.com/2008/10/directory-locking-in-perl.html' title='Directory locking in perl'/><author><name>vikas</name><uri>http://www.blogger.com/profile/17139064836239545202</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4113137560643006742.post-6798494395557197111</id><published>2008-10-15T22:50:00.000-07:00</published><updated>2008-10-15T22:58:18.475-07:00</updated><title type='text'>DB Row locking without using inbuilt DB locks</title><content type='html'>I had come across a scenario where multiple threads would access the same row in the DB and would result in race condition. I was unable to use inbuilt lock as the mysql DB table was MyISAM. Also wanted a generic solution which could work for DBs with minimal locking mechanism.&lt;br /&gt;&lt;br /&gt;The example is quite generic in nature and can be applied to any other language/DB.&lt;br /&gt;The example is where multiple threads are trying to send the orders from the DB.&lt;br /&gt;&lt;br /&gt;# Use process ID as our lock ID.  Could really use any unique identifier.&lt;br /&gt;$lock_id = getpid();&lt;br /&gt;$lock_timestamp = time();&lt;br /&gt;&lt;br /&gt;# "Claim" the orders that this process will attempt to re-upload, so that other&lt;br /&gt;# processes cannot grab them - this prevents the race condition&lt;br /&gt;sql("UPDATE order_table SET lock_id = $lock_id, lock_timestamp = $lock_timestamp WHERE lock_id IS NULL");&lt;br /&gt;&lt;br /&gt;# Figure out which orders I was able to "claim"&lt;br /&gt;$orders_to_retransmit = sql("SELECT * FROM order_table WHERE lock_id = $pid");&lt;br /&gt;&lt;br /&gt;# ... process orders, if any were successful&lt;br /&gt;&lt;br /&gt;# Clear locks - in case we still couldn't transmit, give a future process the opportunity&lt;br /&gt;&lt;br /&gt;sql("UPDATE order_table SET lock_id = NULL WHERE lock_id = $pid");&lt;br /&gt;&lt;br /&gt;# Extra: Clean up any abandoned locks from previous crashed runs&lt;br /&gt;# (shouldn't happen but you never know)&lt;br /&gt;sql("UPDATE order_table SET lock_id = NULL, lock_timestamp = NULL WHERE NOW() - lock_timestamp &gt; 3600");&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4113137560643006742-6798494395557197111?l=codeinsights.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeinsights.blogspot.com/feeds/6798494395557197111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4113137560643006742&amp;postID=6798494395557197111' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/6798494395557197111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4113137560643006742/posts/default/6798494395557197111'/><link rel='alternate' type='text/html' href='http://codeinsights.blogspot.com/2008/10/db-row-locking-without-using-inbuilt-db.html' title='DB Row locking without using inbuilt DB locks'/><author><name>vikas</name><uri>http://www.blogger.com/profile/17139064836239545202</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
