<?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>A nerds discoveries</title>
	<atom:link href="http://nerdsdiscoveries.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://nerdsdiscoveries.com</link>
	<description>My path through nerd matter</description>
	<lastBuildDate>Wed, 28 Mar 2012 15:22:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>How to import (revert) views in Drupal 7.x</title>
		<link>http://nerdsdiscoveries.com/?p=80</link>
		<comments>http://nerdsdiscoveries.com/?p=80#comments</comments>
		<pubDate>Wed, 28 Mar 2012 15:18:40 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=80</guid>
		<description><![CDATA[Developing web applications using CMS like Drupal may be chalanging when there are more than one developer working on the same project. Source code is managed easily with Git (or other VCS), but the database content must be treated with care. Either you go for a relay baton method: One developer updating the database at [...]]]></description>
			<content:encoded><![CDATA[<p>Developing web applications using CMS like Drupal may be chalanging when there are more than one developer working on the same project. Source code is managed easily with Git (or other VCS), but the database content must be treated with care. Either you go for a relay baton method: One developer updating the database at the time and all other must get new dumps after the update, or you can export / import features stored in the database.</p>
<p>I wanted to try the latter with Drupal Views, and could not find any documentation that worked out-of-the-box with my project so here is what I ended up with:</p>
<p><strong>Create a new module</strong><br />
See <a href="http://drupal.org/node/1074360">Creating modules &#8211; a tutorial: Drupal 7.x</a></p>
<pre>
viewsimport/
├── views
│   └── view.my_exported_view.inc
├── viewsimport.info
├── viewsimport.module
└── viewsimport.views_default.inc
</pre>
<p><strong>Export view(s)</strong><br />
Export whatever views you want to be able to import (revert). From the views list (admin/structure/views) you should be able to select &#8220;Export&#8221; on the views you want to export.<br />
This will display PHP code in a textarea. You should copy the contents and paste it in a file, say named view.my_exported_view.inc.<br />
Remember to add &#8220;&lt;?php&#8221; on the first line.</p>
<p><strong>My example files</strong><br />
Here is my modules/viewsimport/viewsimport.info file:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Views Import&quot;</span><br />
description <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;A module that allows views to be imported&quot;</span><br />
core <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;7.x&quot;</span><br />
dependencies<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;views&quot;</span></div></td></tr></tbody></table></div>
<p>Here is my modules/viewsimport/viewsimport.module file:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* Implementation of hook_views_api().<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> viewsimport_views_api<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'api'</span> <span style="color: #339933;">=&gt;</span> <span style="color:#800080;">3.0</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Here is my modules/viewsimport/viewsimport.views_default.inc:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* @file<br />
&nbsp;* Load default views for this module <br />
&nbsp;*/</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* iframe_views_default_views<br />
&nbsp;*<br />
&nbsp;* Load the default views<br />
&nbsp;* <br />
&nbsp;* @access public<br />
&nbsp;* @return void<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> viewsimport_views_default_views<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$views</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/views/view.my_exported_view.inc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$views</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$views</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$view</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$views</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Some of the articles I stumbled over:</p>
<ul>
<li><a href="http://techcommons.stanford.edu/topics/drupal/adding-default-views-and-pages-custom-module">Adding Default Views and Pages to a Custom Module</a></li>
<li><a href="http://www.mc-kenna.com/drupal/2009/05/managing-drupal-views-the-proper-way">Managing Drupal Views, the proper way</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=80</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fake php time on your ubuntu server</title>
		<link>http://nerdsdiscoveries.com/?p=48</link>
		<comments>http://nerdsdiscoveries.com/?p=48#comments</comments>
		<pubDate>Fri, 16 Dec 2011 11:07:45 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=48</guid>
		<description><![CDATA[Some time it is necessary to fool your PHP application to test functionality related to a &#8220;current date&#8221;. Fooling php cli is simple using faketime: Say you have this PHP script: 123#!/usr/bin/env php &#60;?php print date&#40; 'F j. Y [H:i]' &#41;.&#34;\n&#34;; Rendering this script with php through faketime will give you results like this: 12$ [...]]]></description>
			<content:encoded><![CDATA[<p>Some time it is necessary to fool your PHP application to test functionality related to a &#8220;current date&#8221;.</p>
<p>Fooling php cli is simple using <a href="http://packages.ubuntu.com/search?keywords=faketime">faketime</a>:</p>
<p>Say you have this PHP script:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#!/usr/bin/env php <br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #b1b100;">print</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'F j. Y [H:i]'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Rendering this script with php through faketime will give you results like this:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ faketime <span style="color: #ff0000;">'last Friday 5 pm'</span> .<span style="color: #000000; font-weight: bold;">/</span>time.php <br />
December <span style="color: #000000;">9</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">17</span>:00<span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p>The same can be achieved using the <a href="http://packages.ubuntu.com/lucid/datefudge">datefudge</a> command:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ datefudge <span style="color: #ff0000;">&quot;2007-04-01 10:23&quot;</span> .<span style="color: #000000; font-weight: bold;">/</span>time.php <br />
April <span style="color: #000000;">1</span>. <span style="color: #000000;">2007</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">10</span>:<span style="color: #000000;">23</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p><strong>Faking time for a webapplication</strong></p>
<p>Faking time for a web application is not that simple since apache will fork a process for each request and thus create a new php processes.<br />
In this post I will show you how to use <a href="http://freecode.com/projects/libfaketime">FakeTime Preload Library</a> to fake time system wide while running tests on a web application.</p>
<p>First I need to install faketimelib as described on the librarys <a href="http://www.code-wizards.com/projects/libfaketime/">homepage</a>.<br />
In short:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.code-wizards.com<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span>libfaketime<span style="color: #000000; font-weight: bold;">/</span>libfaketime-0.8.1.tar.gz<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> libfaketime-0.8.1.tar.gz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> libfaketime-0.8.1<br />
<span style="color: #c20cb9; font-weight: bold;">vim</span> README<br />
<span style="color: #c20cb9; font-weight: bold;">make</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_PRELOAD</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>faketime<span style="color: #000000; font-weight: bold;">/</span>libfaketime.so.1</div></td></tr></tbody></table></div>
<p>For the demonstration I will use a php script like this:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;The current time of the server is: <span style="color: #009933; font-weight: bold;">%s</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'l F j. Y [H:i:s]'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Running this script should yield something like:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">16</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>08:02:<span style="color: #000000;">43</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p>Now I create a file in my home folder, faketimerc, with a new future time. I will use this file in different ways to show how I can manipulate the time.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;@2012-12-21 12:12:12&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> faketimerc</div></td></tr></tbody></table></div>
<p>If you now create an environment variable, FAKETIME, give it a future time, and running the same script would yield something like this:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">16</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>08:<span style="color: #000000;">19</span>:<span style="color: #000000;">39</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FAKETIME</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> faketimerc<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">21</span>. <span style="color: #000000;">2012</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">12</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ <span style="color: #7a0874; font-weight: bold;">unset</span> FAKETIME<br />
$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">16</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>08:<span style="color: #000000;">19</span>:<span style="color: #000000;">56</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p>As you can see, the processes you run while the environment variable is set to a future time will get a fake time. Once the variable is unset new processes will get normal time.</p>
<p>This can be achieved also by creating a file. &#8220;.faketimerc&#8221; in your home folder:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">16</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>08:<span style="color: #000000;">23</span>:<span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> faketimerc .faketimerc<br />
$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">21</span>. <span style="color: #000000;">2012</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">12</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> .faketimerc <br />
$ php time.php <br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">16</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>08:<span style="color: #000000;">23</span>:<span style="color: #000000;">36</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p>If you want to change time for a php application that runs though apache you may want to set the fake time system wide so that the php processes spowned use the faked time. To do this you need to create a file, /etc/.faketimerc, just the same as the one I created in my home folder.</p>
<p>I will use w3m for this demonstration. I assume a normal ubuntu server with apache2 installed.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> time.php <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> faketimerc <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart<br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span> Restarting web server apache2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ... waiting<br />
$ php <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>time.php<br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">21</span>. <span style="color: #000000;">2012</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">12</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">date</span><br />
fr. <span style="color: #000000;">21</span>. des. <span style="color: #000000;">12</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">12</span> +0100 <span style="color: #000000;">2012</span><br />
$ w3m <span style="color: #660033;">-dump</span> localhost<span style="color: #000000; font-weight: bold;">/</span>time.php<br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">16</span>. <span style="color: #000000;">2011</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">11</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">24</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p>As you can see, the date command and when rendering the script with php, gives me the fake time, but when rendering the script through apache I loose the fake time. This is because the environment variable LD_PRELOAD is not set for the apache process.</p>
<p>To fix this I need to set LD_PRELOAD for apache by editing /etc/apache/envvars. Lets test it again:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo <span style="color: #000099; font-weight: bold;">\&quot;</span>export LD_PRELOAD='/usr/local/lib/faketime/libfaketime.so.1'<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt;&gt; /etc/apache2/envvars&quot;</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart<br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span> Restarting web server apache2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ... waiting<br />
$ w3m <span style="color: #660033;">-dump</span> localhost<span style="color: #000000; font-weight: bold;">/</span>time.php<br />
The current <span style="color: #000000; font-weight: bold;">time</span> of the server is: Friday December <span style="color: #000000;">21</span>. <span style="color: #000000;">2012</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">12</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">16</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></td></tr></tbody></table></div>
<p>Fake time! <img src='http://nerdsdiscoveries.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS! If you also want your PostgreSQL server to use fake time:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo <span style="color: #000099; font-weight: bold;">\&quot;</span>LD_PRELOAD='/usr/local/lib/faketime/libfaketime.so.1'<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt;&gt; /etc/postgresql/8.4/main/environment&quot;</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.4</span> restart</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=48</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu-vm-builder and vmbuilder</title>
		<link>http://nerdsdiscoveries.com/?p=45</link>
		<comments>http://nerdsdiscoveries.com/?p=45#comments</comments>
		<pubDate>Sun, 23 Oct 2011 07:25:19 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Virtualization]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=45</guid>
		<description><![CDATA[In case you should wonder what is the difference between the /usr/bin/ubuntu-vm-builder and /ur/bin/vmbuilder, there is no difference. Both scripts use the same python VMBuilder library, and contain accactly the same code&#8230;]]></description>
			<content:encoded><![CDATA[<p>In case you should wonder what is the difference between the /usr/bin/ubuntu-vm-builder and /ur/bin/vmbuilder, there is no difference.</p>
<p>Both scripts use the same python VMBuilder library, and contain accactly the same code&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=45</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Veewee and ubuntu-10.04.3</title>
		<link>http://nerdsdiscoveries.com/?p=42</link>
		<comments>http://nerdsdiscoveries.com/?p=42#comments</comments>
		<pubDate>Tue, 27 Sep 2011 08:20:57 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Vagrant]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=42</guid>
		<description><![CDATA[You want to create a VirtualBox with Ubuntu 10.04.3 using Veewee, but there is no ubuntu-10.04.3 template? Here is what you can do: Download (git clone) a copy of veewee from GitHub and copy the templates. 123git clone https://github.com/jedi4ever/veewee.git cd veewee sudo cp -r templates/ubuntu-10.04.3-server-* /usr/lib/ruby/gems/1.8/gems/veewee-0.2.0/templates/ To verify that you have the new templates: 1vagrant [...]]]></description>
			<content:encoded><![CDATA[<p>You want to create a VirtualBox with Ubuntu 10.04.3 using Veewee, but there is no ubuntu-10.04.3 template?</p>
<p>Here is what you can do:</p>
<p>Download (git clone) a copy of veewee from <a href="https://github.com/jedi4ever/veewee">GitHub</a> and copy the templates.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git clone</span> https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>jedi4ever<span style="color: #000000; font-weight: bold;">/</span>veewee.git<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> veewee<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> templates<span style="color: #000000; font-weight: bold;">/</span>ubuntu-10.04.3-server-<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>veewee-0.2.0<span style="color: #000000; font-weight: bold;">/</span>templates<span style="color: #000000; font-weight: bold;">/</span></div></td></tr></tbody></table></div>
<p>To verify that you have the new templates:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">vagrant basebox templates</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash completion and git prompt</title>
		<link>http://nerdsdiscoveries.com/?p=39</link>
		<comments>http://nerdsdiscoveries.com/?p=39#comments</comments>
		<pubDate>Thu, 07 Jul 2011 08:38:26 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=39</guid>
		<description><![CDATA[Recently I discovered that the virtual server I was working on did not give me the usual bash completion I&#8217;m so used to on my Kubuntu workstations. Working on git repositories and upgrading web applications made this to an itch I just had to scratch. After a bit of searching it appeared that I was [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I discovered that the virtual server I was working on did not give me the usual bash completion I&#8217;m so used to on my Kubuntu workstations. Working on git repositories and upgrading web applications made this to an itch I just had to scratch.</p>
<p>After a bit of searching it appeared that I was missing a file: /etc/bash_completion. Next I discovered that there is a /etc/bash_completion.d/ directory and under this a file named &#8216;git&#8217;. I copied the bash_completion file from my workstation and followed the instruction in /etc/bash_completion.d/git and suddenly I had bash completion <strong>and</strong> a prompt that gave me branch name and the status of the git repository I was currently in. </p>
<p>Just to give you a hint, here is the comment from the /etc/bash_completion.d/git file:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!bash</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># bash completion support for core Git.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright (C) 2006,2007 Shawn O. Pearce &lt;spearce@spearce.org&gt;</span><br />
<span style="color: #666666; font-style: italic;"># Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).</span><br />
<span style="color: #666666; font-style: italic;"># Distributed under the GNU General Public License, version 2.0.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># The contained completion routines provide support for completing:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) local and remote branch names</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) local and remote tag names</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) .git/remotes file names</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) git 'subcommands'</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) tree paths within 'ref:path/to/file' expressions</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) common --long-options</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># To use these routines:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;1) Copy this file to somewhere (e.g. ~/.git-completion.sh).</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;2) Added the following line to your .bashrc:</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp;source ~/.git-completion.sh</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; Or, add the following lines to your .zshrc:</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp;autoload bashcompinit</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp;bashcompinit</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp;source ~/.git-completion.sh</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;3) Consider changing your PS1 to also show the current branch:</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp;PS1='[\u@\h \W$(__git_ps1 &quot; (%s)&quot;)]\$ '</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; The argument to __git_ps1 will be displayed only if you</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; are currently in a git repository. &nbsp;The %s token will be</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; the name of the current branch.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; value, unstaged (*) and staged (+) changes will be shown next</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; to the branch name. &nbsp;You can configure this per-repository</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; with the bash.showDirtyState variable, which defaults to true</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; once GIT_PS1_SHOWDIRTYSTATE is enabled.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; You can also see if currently something is stashed, by setting</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; then a '$' will be shown next to the branch name.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; If you would like to see if there're untracked files, then you can</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; untracked files, then a '%' will be shown next to the branch name.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; If you would like to see the difference between HEAD and its</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; upstream, set GIT_PS1_SHOWUPSTREAM=&quot;auto&quot;. &nbsp;A &quot;&lt;&quot; indicates</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; you are behind, &quot;&gt;&quot; indicates you are ahead, and &quot;&lt;&gt;&quot;</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; indicates you have diverged. &nbsp;You can further control</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; list of values:</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verbose &nbsp; &nbsp; &nbsp; show number of commits ahead/behind (+/-) upstream</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; legacy &nbsp; &nbsp; &nbsp; &nbsp;don't use the '--count' option available in recent</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; versions of git-rev-list</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; git &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; always compare HEAD to @{upstream}</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; svn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; always compare HEAD to your SVN upstream</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; By default, __git_ps1 will compare HEAD to your SVN upstream</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; if it can find one, or @{upstream} otherwise. &nbsp;Once you have</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; set GIT_PS1_SHOWUPSTREAM, you can override it on a</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; per-repository basis by setting the bash.showUpstream config</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; variable.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># To submit patches:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) Read Documentation/SubmittingPatches</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) Send all patches to the current maintainer:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &quot;Shawn O. Pearce&quot; &lt;spearce@spearce.org&gt;</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;*) Always CC the Git mailing list:</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; git@vger.kernel.org</span><br />
<span style="color: #666666; font-style: italic;">#</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=39</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prompt with git branch</title>
		<link>http://nerdsdiscoveries.com/?p=33</link>
		<comments>http://nerdsdiscoveries.com/?p=33#comments</comments>
		<pubDate>Wed, 10 Nov 2010 15:22:43 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=33</guid>
		<description><![CDATA[I think I like this: 12345678function parse_git_dirty &#123; &#160; &#91;&#91; $&#40;git status 2&#62; /dev/null &#124; tail -n1&#41; != &#34;nothing to commit (working directory clean)&#34; &#93;&#93; &#38;&#38; echo &#34;*&#34; &#125; function parse_git_branch &#123; &#160; git branch --no-color 2&#62; /dev/null &#124; sed -e '/^[^*]/d' -e &#34;s/* \(.*\)/[\1$(parse_git_dirty)]/&#34; &#125; export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\w\[\033[01;32m\] $(parse_git_branch) \[\033[01;36m\]$ \[\033[00m\]']]></description>
			<content:encoded><![CDATA[<p>I think I like this:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> parse_git_dirty <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git status</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;">|</span> <span style="color: #c20cb9; font-weight: bold;">tail</span> -n1<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;nothing to commit (working directory clean)&quot;</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;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;*&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> parse_git_branch <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">git branch</span> <span style="color: #660033;">--no-color</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;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'/^[^*]/d'</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/* \(.*\)/[\1<span style="color: #007800;">$(parse_git_dirty)</span>]/&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">'${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\w\[\033[01;32m\] $(parse_git_branch) \[\033[01;36m\]$ \[\033[00m\]'</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=33</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thunderbird 3 account setup tip</title>
		<link>http://nerdsdiscoveries.com/?p=30</link>
		<comments>http://nerdsdiscoveries.com/?p=30#comments</comments>
		<pubDate>Sat, 16 Oct 2010 08:06:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=30</guid>
		<description><![CDATA[Wish you could set up an account in Thunderbird manually? You&#8217;re not alone. The trick: Hit the &#8220;stop&#8221; button as soon as you enter the automatic setup window and set your settings manually. If you wait to press &#8220;stop&#8221; it will not stop and the best thing you can do is to cansel and start [...]]]></description>
			<content:encoded><![CDATA[<p>Wish you could set up an account in Thunderbird manually?</p>
<p>You&#8217;re not alone.</p>
<p>The trick: Hit the &#8220;stop&#8221; button as soon as you enter the automatic setup window and set your settings manually. If you wait to press &#8220;stop&#8221; it will not stop and the best thing you can do is to cansel and start over again.</p>
<p>Ref: http://www.givesatisfaction.com/mozilla_messaging/topics/can_t_setup_an_imap_connection_in_thunderbird_3</p>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=30</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix to vims taglist plugin (ctags tags comments in PHP)</title>
		<link>http://nerdsdiscoveries.com/?p=21</link>
		<comments>http://nerdsdiscoveries.com/?p=21#comments</comments>
		<pubDate>Sun, 31 Jan 2010 21:58:44 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=21</guid>
		<description><![CDATA[Taglist uses exuberant ctags, which supports many languages including PHP. I use vim on a daily basis to edit PHP files. Often classes and functions have PHPDoc and some like to use the words &#8216;class&#8217; or &#8216;function&#8217; in their comments. Fair enough, but ctags regex strings ignores that lines may have a preceding &#8216;*&#8217; or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://vim-taglist.sourceforge.net/index.html">Taglist</a> uses <a href="http://ctags.sourceforge.net/">exuberant ctags</a>, which supports many languages including PHP. I use vim on a daily basis to edit <a href="http://php.net">PHP</a> files. Often classes and functions have <a href="http://www.phpdoc.org/">PHPDoc</a>  and some like to use the words &#8216;class&#8217; or &#8216;function&#8217; in their comments. Fair enough, but ctags <a href="http://en.wikipedia.org/wiki/Regex">regex</a> strings ignores that lines may have a preceding &#8216;*&#8217; or &#8216;//&#8217; and thus create tags of funny classes and functions. In some cases browsing large files of PHP source code with taglist is pointless.</p>
<p>The solution to this is writing your own ctags configuration file (~/.ctags) and letting ctags know what regex strings You want to tag your PHP files with:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #660033;">-f</span> .<span style="color: #000000; font-weight: bold;">/</span>tags<br />
<span style="color: #660033;">--langmap</span>=php:+.inc<br />
<span style="color: #660033;">-h</span> <span style="color: #ff0000;">'.php.inc'</span><br />
<span style="color: #660033;">-R</span><br />
<span style="color: #660033;">--totals</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><br />
<span style="color: #660033;">--tag-relative</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><br />
<span style="color: #660033;">--PHP-kinds</span>=+cf-v<br />
<span style="color: #660033;">--regex-PHP</span><br />
<span style="color: #660033;">--regex-PHP</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>^<span style="color: #000000; font-weight: bold;">|</span>^<span style="color: #7a0874; font-weight: bold;">&#91;</span>^<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>+<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:blank:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>class<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:blank:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>+<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:alpha:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:alnum:<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;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>\<span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span>c<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #660033;">--regex-PHP</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>^<span style="color: #000000; font-weight: bold;">|</span>^<span style="color: #7a0874; font-weight: bold;">&#91;</span>^<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>+<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:blank:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:blank:<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;">&amp;</span>?<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:blank:<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;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:alpha:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:alnum:<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;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>\<span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">/</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=21</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MyPasswordSafe to KeepassX converter</title>
		<link>http://nerdsdiscoveries.com/?p=19</link>
		<comments>http://nerdsdiscoveries.com/?p=19#comments</comments>
		<pubDate>Tue, 05 Jan 2010 13:33:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[keepassx mypasswordsafe php xml convert]]></category>

		<guid isPermaLink="false">http://nerdsdiscoveries.com/?p=19</guid>
		<description><![CDATA[I&#8217;ve used MyPasswordSafe for some time, but after I installed Kubuntu Karmic Koala AMD64 it would&#8217;nt start. I googled the Internet for a better program and settled with KeepassX. Next trouble was to move my passwords from MyPasswordSafe to KeepassX. Both programs can export/import XML files, so I made a PHP file that did the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used MyPasswordSafe for some time, but after I installed Kubuntu Karmic Koala AMD64 it would&#8217;nt start. I googled the Internet for a better program and settled with KeepassX.</p>
<p>Next trouble was to move my passwords from MyPasswordSafe to KeepassX. Both programs can export/import XML files, so I made a PHP file that did the job. I even created a project on <a href="http://github.com/stribert/MyPasswordSafe-to-Keepassx-Converter">githut</a> for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customer spesific settings in vim using git branches</title>
		<link>http://nerdsdiscoveries.com/?p=17</link>
		<comments>http://nerdsdiscoveries.com/?p=17#comments</comments>
		<pubDate>Tue, 08 Sep 2009 04:58:37 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://blog.robert.strind.no/?p=17</guid>
		<description><![CDATA[I work as an consultant and thus write code for different customers that may have quite different coding standards and license policies. Adapting to a customer often involves changing many files in the vim config files and plugins, but after I initialized a git repo in my ~/.vim folder I only have to change branch [...]]]></description>
			<content:encoded><![CDATA[<p>I work as an consultant and thus write code for different customers that may have quite different coding standards and license policies. Adapting to a customer often involves changing many files in the vim config files and plugins, but after I initialized a git repo in my <em>~/.vim</em> folder I only have to change branch for each customer I work for. <em>git br</em> (<em>git branch</em>) gives me a neat list of predefined customer settings to choose from. Then its just <em>git co [customer]</em> and start to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://nerdsdiscoveries.com/?feed=rss2&#038;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

