<?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>Cyril Maithily Gupta&#039;s Blog</title>
	<atom:link href="http://cyrilgupta.com/Index.php?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://cyrilgupta.com</link>
	<description>Work &#38; Life</description>
	<lastBuildDate>Thu, 05 Aug 2010 05:53:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google Wave Alternatives &#8211; Some websites you can use instead of Google Wave</title>
		<link>http://cyrilgupta.com/?p=472</link>
		<comments>http://cyrilgupta.com/?p=472#comments</comments>
		<pubDate>Thu, 05 Aug 2010 05:53:38 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Latest]]></category>
		<category><![CDATA[collaboration]]></category>
		<category><![CDATA[google wave]]></category>
		<category><![CDATA[project management]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=472</guid>
		<description><![CDATA[Google Wave is a cancelled project. I am looking now for other products that could provide me functionality similar to Google wave. So let me create a list of links that were considered. If anything measures up, I will tell you guys and gals.
Xoboni.com &#8211; Xoboni is a plugin for outlook express that lets you [...]]]></description>
			<content:encoded><![CDATA[<p>Google Wave is a cancelled project. I am looking now for other products that could provide me functionality similar to Google wave. So let me create a list of links that were considered. If anything measures up, I will tell you guys and gals.</p>
<p><a href="http://www.xobni.com/">Xoboni.com</a> &#8211; Xoboni is a plugin for outlook express that lets you track emails better. Reject.<br />
<a href="https://www.syphir.com/">Syphir</a> &#8211; Gmail plugin lets you organize your inbox. Rejected because it does not provide collaboration features. I want Wave like feature that lets me have a conversation!.<br />
<a href="http://www.tokbox.com/">Toqbox</a> &#8211; While I want chat, I don&#8217;t want Video chat. Simple msging is fine, and not like IRC. Each msg should have its own space with facility to put in images and attachments.<br />
<a href="http://titanpad.com/">Titanpad</a> &#8211; Provides facility to collaboratively edit a document. Maybe if you close one eye and squint really hard with the other you can pretend it hobbles close to a mile away from GWave. But a problem it only supports public documents for free. I don&#8217;t want my project info public.<br />
<a href="http://sync.in/">Sync.in</a> &#8211; Based on the same technology as Titanpad, reject for the same reason.<br />
<a href="http://biz.zenbe.com/cyrilgupta.zenbe.com/shareflow"><strong>Zenbe.com</strong></a> &#8211; Looks interesting. I signed in but the interface is more complex. But it supports private collaboration. Was very sluggish. Saved for later.<br />
<a href="http://incipi.com/"><strong>Incipi.com</strong></a> &#8211; Online collaboration, msging, tasking. Look promising. It seems they offer a free account too. Saved for later.<br />
<a href="http://vyew.com/site/"><strong>Vyew</strong></a> &#8211; This one actually sounds like Wave! It&#8217;s free and though it sounds like it&#8217;s got too many features, it might offer me something. Saved for later.<br />
<a href="http://www.scribblar.com/">Scribblar</a> &#8211; Targeted mainly at education. It has some collaboration features, but didn&#8217;t excite me enough. Reject.<br />
<a href="http://www.snipia.com/login.html"><strong>Snipia</strong></a> &#8211; Share tasks, msgs in groups. Hmm.. That&#8217;s what I used Google Wave for. Saved for later.<br />
<a href="http://coopapp.com/">Coopap.com</a> &#8211; This sounds interesting. But I don&#8217;t know if they offer separate workspaces. Need to check.<br />
<a href="https://www.obayoo.com/features"><strong>Obayoo</strong></a> &#8211; Lets you make groups, and share data within them including images and files. Need to check again.<br />
<a href="http://www.huddle.net/"><strong>Huddle.net</strong></a> &#8211; This one looks like a pretty good alternative with project management features and separate workspaces. Need to check it out!</p>
<p>This list sounds like it has some potentially good candidates for the needs I fulfilled with Google wave. Let me find out what will work for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=472</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Kills Google Wave, Why did it Jump the Gun?</title>
		<link>http://cyrilgupta.com/?p=470</link>
		<comments>http://cyrilgupta.com/?p=470#comments</comments>
		<pubDate>Thu, 05 Aug 2010 04:50:50 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[collaboration]]></category>
		<category><![CDATA[google wave]]></category>
		<category><![CDATA[project management]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=470</guid>
		<description><![CDATA[Okay, let me say I was wrong. Google built up so much excitement around Wave that when I first looked at it, frankly I was disappointed. So I wrote on Wave, &#8216;What will I use it for?&#8217;&#8230; That was almost an year ago.
Now I think that it wasn&#8217;t because Google didn&#8217;t have a solid product, [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, let me say I was wrong. Google built up so much excitement around Wave that when I first looked at it, frankly I was disappointed. So I wrote on Wave, &#8216;What will I use it for?&#8217;&#8230; That was almost an year ago.</p>
<p>Now I think that it wasn&#8217;t because Google didn&#8217;t have a solid product, or they didn&#8217;t have a good idea, but because they were trying to wean a generation of email users away from something they always used. Then they built so much hype around it that people expected a miracle. Sadly that takes a while to deliver and nobody, including Google had patience.</p>
<p>This sort of thing should be allowed to grow on people, with more and more people using it and recommending it. All the growth should have been organic, but that wasn&#8217;t so and now Google has killed an excellent product. Frankly it hurts to see wave go.</p>
<p>After an year of rejecting wave I implemented it in my organisation some days ago and I was surprised at how brilliant it is for the purpose of collaboration. It does beat email hands down, and I was really upbeat about the productivity benefits it could bring me. Over the past few days I&#8217;ve been talking about wave to a lot of people, I am sure there are others..</p>
<p>All the people in my company are now using Google Wave for collaboration and monitoring projects, and now we feel let down by Google.</p>
<p>So while we know it&#8217;s probably not going to work I want to send Google a msg on behalf of all the people who love and use Wave everyday. </p>
<p>Don&#8217;t kill it Google, maintain it. It will grow to become an awesome product if you give it just some more time.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=470</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Impressions from AgileNCR 2010</title>
		<link>http://cyrilgupta.com/?p=464</link>
		<comments>http://cyrilgupta.com/?p=464#comments</comments>
		<pubDate>Sat, 17 Jul 2010 11:45:52 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Latest]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=464</guid>
		<description><![CDATA[I returned a couple of hours ago from the AgileNCR 2010 conference at Ansal AIT Gurgaon. I have been hearing a lot about Agile of late and I thought it would be a good idea to find out what all the buzz is about when I ran into the notice about AgileNCR 2010 event in [...]]]></description>
			<content:encoded><![CDATA[<p>I returned a couple of hours ago from the AgileNCR 2010 conference at Ansal AIT Gurgaon. I have been hearing a lot about Agile of late and I thought it would be a good idea to find out what all the buzz is about when I ran into the notice about AgileNCR 2010 event in one of the online forums.</p>
<p>The conference had multiple sessions running concurrently addressing various issues about Agile Technologies. Since I am an Agile n00b I decided to attend the sessions for newbies and I made it through 3 sessions this morning. The first about Agile buzzwords, the second explaining what Agile is and the third about the challenges in adoption of Agile.</p>
<p>Most of the participants and speakers from some specific companies, particularly Xebia and Thoughtworks. I guess these companies are using Agile in a big way so it makes sense for their developers to be there. So I saw t-shirts with Xebia and Thoughtworks emblazoned all around me. </p>
<p>In the first session itself I was disappointed a bit. Amit King, the presenter was talking about team sizes I&#8217;ve never worked with. With 2 Quality Analysts, 4 developers, 2 Project Managers, and so on&#8230; with the devs working in pairs (on the same computer). That&#8217;s the kind of team that a small software producer like mine won&#8217;t have for quite a while.</p>
<p>I guess the way Agile is being worked in India is suitable most for the bigger companies handling mid or large sized customized projects at the enterprise level. Most of my projects last for 3 months or less and I certainly won&#8217;t be sprinting very far if I am stuck to Agile as is being used by these guys.</p>
<p>What I was seeking was basically to write more robust code, and I guess I don&#8217;t need to work with the full Agile toolset. All I need to do is to seriously start working with Unit tests so that my code doesn&#8217;t accumulate sap as I move forward with it.</p>
<p>Since I didn&#8217;t see myself getting much out of the rest of the conference I moved out after lunch. What it did for me though was make the picture clearer. Now I have a better idea of what Agile is, and what I need to adopt.</p>
<p>I&#8217;ve also realized that in my company we won&#8217;t be scrumming so soon, though I plan to adopt (and I already have adopted) certain practices. </p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=464</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MySQL Throws NullReferenceException in Finalize… How I coped with this.</title>
		<link>http://cyrilgupta.com/?p=461</link>
		<comments>http://cyrilgupta.com/?p=461#comments</comments>
		<pubDate>Mon, 07 Jun 2010 07:01:02 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql .net connector]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=461</guid>
		<description><![CDATA[There are times when I believe that I am the only programmer in the world who leaves bugs in his code and it certainly is a humiliating feeling to feel like a sloppy coder, watching all the ultra-cool code go by working efficiently every inch of the way. So now and then when I see [...]]]></description>
			<content:encoded><![CDATA[<p>There are times when I believe that I am the only programmer in the world who leaves bugs in his code and it certainly is a humiliating feeling to feel like a sloppy coder, watching all the ultra-cool code go by working efficiently every inch of the way. So now and then when I see a bug in a professional application&#8217;s code it irritates me, but it also brings me a warm glow &#8212; I am not so alone after all. The latest victim in this ego-boosting series is MySql. Yes that excellent open source data project that is now owned by Oracle (so you know where it&#8217;s heading&#8230; NoSQL Anyone?).</p>
<p>I am migrating one of my websites to MySQL from SQL Server and ran into a bug in the MySQL .Net connector code. </p>
<p>MySQL .Net connector (at least till 6.23) gives a NullReferenceException if you have used the MySQLHelper classes to initialize a MySqlDataReader object when the Application tries to run the finalizer on the connection. </p>
<p>The error can occur at totally random places in your code because it happens in the finalizer. This kept me stumped for a little while because I was searching for the error in my own code. Finally I deduced from the stack trace that the error was in MySQL .Net Connector.</p>
<p>I did realize that this would be a bug, but I didn&#8217;t know exactly what part of my code caused this bug to surface. So I checked the stack once more and discovered that there was a call to MySQLDataReader earlier in the trace. So it was clear then that it was definitely something related to the MySQLDataReader. </p>
<p>At this point I did a search on Google and found the details of this  <a href="http://bugs.mysql.com/bug.php?id=53457">bug report</a>. It sounded like this one alright, and it hadn&#8217;t been fixed yet. I wasn&#8217;t completely sure how I could fix this or why it was occurring so I posted a <a href="http://bugs.mysql.com/bug.php?id=53457">question on Stackoverflow</a> to see if anyone else had faced the same. The insightful answer from Evegyn which reminded me that if I had used &#8216;using&#8217; then the finalizer wouldn&#8217;t be called on the connection object made it clear that it had to be the MySQLHelper object which was responsible because I am very particular about releasing any resources I have grabbed and I never miss a &#8216;using&#8217; statement.</p>
<p>MySQLHelper in the MySQL .Net connector takes the responsibility of releasing the connection so I wasn&#8217;t using `using` <img src='http://cyrilgupta.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Acting on the hunch I removed the reference to MySQLHelper wherever I was using the MySqlDataReader and pronto, things started working again.</p>
<p>So don&#8217;t use MySqlHelper to spawn MySqlDataReader if you are working on .Net on a 64 bit Windows machine for version 6.22, 6.23 (might be fixed in later versions).</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=461</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I Love the MySqlHelper Class in MySql .Net Connector</title>
		<link>http://cyrilgupta.com/?p=457</link>
		<comments>http://cyrilgupta.com/?p=457#comments</comments>
		<pubDate>Sat, 05 Jun 2010 12:29:22 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqlhelper]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=457</guid>
		<description><![CDATA[Which code do you like better?
1:

       SqlConnection cnn = new SqlConnection(Globals.CONNSTRINGJYOTISH);
        cnn.Open();

        using (cnn)
        {
            string qry [...]]]></description>
			<content:encoded><![CDATA[<p>Which code do you like better?</p>
<p>1:</p>
<pre class="brush: csharp;">
       SqlConnection cnn = new SqlConnection(Globals.CONNSTRINGJYOTISH);
        cnn.Open();

        using (cnn)
        {
            string qry = &quot;UPDATE [Order] SET PaymentDone=1 WHERE OrderCode=@ordcode&quot;;
            SqlCommand cmd = new SqlCommand(qry, cnn);
            cmd.Parameters.AddWithValue(&quot;ordCode&quot;, orderCode);
            int res = cmd.ExecuteNonQuery();
            if (res &gt; 0) return true; else return false;
        }
</pre>
<p>Or</p>
<p>2:</p>
<pre class="brush: csharp;">
            return MySqlHelper.ExecuteNonQuery(Globals.CONNSTRINGJYOTISH, &quot;UPDATE `order` SET PaymentDone=1 WHERE orderCode=?ordCode&quot;,
                new MySqlParameter[] { new MySqlParameter(&quot;ordCode&quot;, orderCode) }) &gt; 0;
</pre>
<p>The second version does exactly the same job as the first version. I admit I got a little carried away with terseness in directly comparing the result of the ExecuteNonQuery to an integer, but skip that and leave the rest of the code. Not only is it compact, it is also easier to read and quicker to write.</p>
<p>The MySQLHelper class is an awesome piece of work and I haven&#8217;t been using the traditional command execution scheme ever since I first used it. If you are using MySQL with .Net, then check it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=457</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Submit JSON Data to an ASP.Net MVC Action, and then Deserialize it</title>
		<link>http://cyrilgupta.com/?p=452</link>
		<comments>http://cyrilgupta.com/?p=452#comments</comments>
		<pubDate>Fri, 04 Jun 2010 10:25:53 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Ajax/Javascript]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[asp.net-mvc]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=452</guid>
		<description><![CDATA[I just had some negative fun (negative fun is something that you enjoy in a painful kind of a way) trying to submit some simple JSON data to my ASP.Net MVC action method without having to create a Custom Model Binder for it.
Basically all I wanted was a simple Dictionary object, and since I&#8217;ve been [...]]]></description>
			<content:encoded><![CDATA[<p>I just had some negative fun (negative fun is something that you enjoy in a painful kind of a way) trying to submit some simple JSON data to my ASP.Net MVC action method without having to create a Custom Model Binder for it.</p>
<p>Basically all I wanted was a simple Dictionary<string , object> object, and since I&#8217;ve been serializing Dictionary</string><string , object> to JSON so easily all this while using JSONResult I just wanted to do the reverse in a single, easy to use step. Unfortunately it didn&#8217;t turn out to be so simple and it was hard finding the right resource because most of the blogs online are trying to convince you very hard to use a Custom Model Binder (which I am adamant I won&#8217;t use this time).</p>
<p>I needed to submit the data from multiple forms (collected using Ajax) bunched together in one huge JSON object. A custom model binder would be very hard to program because there are so many objects with insane hierarchy while a Dictionary</string><string , object> is god-send for something like this.</p>
<p>Here&#8217;s the code.</p>
<p>Javascript side:</p>
<pre class="brush: jscript;">
        function processPay(payData) {
            var encod = JSON.stringify({ birthD: birthData, language: langSel, paymethod: payMethod, paySettings: payData });

            $.post(&quot;/horoscope/horoscopeajax/&quot;, { encod: encod },
                function (res) {
                    return res;
                });
        }
</pre>
<p>I am using JSON.stringify function which is a part of the <a href="http://www.json.org/js.html">JSON in Javascript</a> library by Dave Ward. This function converts a JSON object into string. </p>
<p>At the server:</p>
<pre class="brush: csharp;">
        [HttpPost]
        public ActionResult HoroscopeAjax(string encod)
        {
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();

            Dictionary&lt;string, object&gt; ts = (Dictionary&lt;string, object&gt;)js.DeserializeObject(encod);
            return null;
        }
</pre>
<p>encod is a simple string which the .Net&#8217;s inbuilt javascript serializer  can deserialie(No need of <a href="http://json.codeplex.com/">JSON.Net</a>). That&#8217;s it, a single line of code just like I wanted.</string></p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=452</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to backup your server data, (MySql, SQL Server, Directories) with Powershell</title>
		<link>http://cyrilgupta.com/?p=441</link>
		<comments>http://cyrilgupta.com/?p=441#comments</comments>
		<pubDate>Sun, 30 May 2010 13:08:10 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Latest]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[automated backup]]></category>
		<category><![CDATA[mysql backup]]></category>
		<category><![CDATA[mysql powershell]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[powershell backup]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[server backup]]></category>
		<category><![CDATA[sql server backup]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=441</guid>
		<description><![CDATA[How to backup your server data, (MySql, SQL Server, Directories) with Powershell
Not a very long time ago I lost some data on my Windows server. It was a totally unexpected failure of the hard disk. Back then I had a local backup system which failed along with the hard-disk failure. So later when I got [...]]]></description>
			<content:encoded><![CDATA[<h3>How to backup your server data, (MySql, SQL Server, Directories) with Powershell</h3>
<p>Not a very long time ago I lost some data on my Windows server. It was a totally unexpected failure of the hard disk. Back then I had a local backup system which failed along with the hard-disk failure. So later when I got a second server to host some of my websites I decided to create a backup system that would take a total backup of each server on the second server.</p>
<p>That included MySQL databases, SQL Server databases and some folders. There were some custom solutions available for taking MySQL and SQL Server backups, but nothing that would nicely package all my files into one unit, so I decided to roll my own using Powershell, that awesome new toy for Windows Scripting. It was a chance to learn and work with something new, so how could I let it pass me by?</p>
<p>So dear reader, for all three of you (hi dad!) who actually read my blog, here’s TOTAL SERVER BACKUP through Powershell.</p>
<p><strong>1. Taking MySQL Backup through Powershell</strong></p>
<p>That should have been trivial, after all, all I need to do is script the commandline executable mysqldump which is already present in the bin folder of the Mysql installation on the server. How hard could that have been?</p>
<p>It turns out that was the hardest part of the job. Some of my websites are in Hindi (using Unicode), while mysqldump worked just fine from the command line, it just didn’t encode my content right from within <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">Powershell</a>. I tried every encoding method I could fine, and almost all the options (Unicode, UTF8), but I was still getting gibberish.</p>
<p>I gave up at one stage and wrote a backup script in C# .net. It worked just fine with some encoding settings and that told me it was possible. So I went back to Powershell and dug a little more. Thank you Rene Saarsoo for this <a href="http://stuck-in-windows.blogspot.com/2009/01/smoking-powershell-pipes.html">gem of wisdom</a> which told me that the correct encoding setting wasn’t UTF8, or Unicode which I had been battling with, but ‘oem’ (whatever that is supposed to mean).</p>
<p>So here’s finally my correct Mysql backup function that works.</p>
<pre class="brush: cpp;">
function Backup-MySqlDB([string]$dbname)
{
&quot;Backing up mysql &quot; + $dbName + &quot;...&quot;
#Backup all mysql DBs

#Set-Location D:\MySQL\bin
Set-Location 'C:\Program Files\Parallels\Plesk\Databases\MySQL\bin'
$bkfile = 'C:\autobackup\Databases\' + $dbname + '.sql'

cmd /c mysqldump -u username -ppassword $dbname | Out-File $bkfile -encoding oem

Write-Host $dbName + &quot;backup complete&quot;
}
</pre>
<p>Notice that this is a function which accepts the database name as the argument. I have set up a new admin level user with powers over all the databases for the backup purpose. </p>
<p>Calling this function is as easy as this:</p>
<pre class="brush: cpp;">Backup-MySqlDB('blogvani')</pre>
<p><strong>2. SQL Server Backup Through Powershell</strong><br />
Some of the content on my server is on legacy (yeah! I don&#8217;t use SQL Server anymore) SQL Server database. I&#8217;ve got the SQL Server Express on my servers which is free, but not powerful and I really can&#8217;t automate backups. But Powershell can tap into .Net, use .Net DLLs and the full .Net Framework, so you can do practically anything with Powershell, including writing your own .Net library and consuming that within Powershell. That should teach those BASH script kiddies a volume or two! </p>
<p>Back to business. So basically because you can tap into .Net from Powershell it isn&#8217;t very hard to use the SQL Server backup objects exposed in .Net. Here&#8217;s the code which I collected and modified from the Internet.</p>
<pre class="brush: cpp;">
function Backup-SqlDB([string]$db)
{
	&quot;Backing Up Sql Server Databases...&quot;
    #Backup SQL Server DBs
    [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.SMO&quot;) | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.SmoExtended&quot;) | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.ConnectionInfo&quot;) | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.SmoEnum&quot;) | Out-Null

    $backupDir = 'c:\autobackup\databases\'
    $server = New-Object (&quot;Microsoft.SqlServer.Management.Smo.Server&quot;) '.\SQLEXPRESS'
    Write-Host $server
    $smoBackup = New-Object(&quot;Microsoft.SqlServer.Management.Smo.Backup&quot;)

    Write-Host $db

    $smoBackup.Action = &quot;Database&quot;
    $smoBackup.BackupSetDescription = &quot;Full backup of &quot; + $db
    $smoBackup.BackupSetName = $db + &quot; Backup&quot;
    $smoBackup.Database = $db
    $smoBackup.MediaDescription = &quot;Disk&quot;

    Write-Host ($backupDir + $db)

    $smoBackup.Devices.AddDevice(($backupDir + $db) + &quot;.bak&quot;, &quot;File&quot;)

    $smoBackup.SqlBackup($server) #Make the backup

    Write-Host $db &quot;Sql Server Backup Finished&quot;
}
</pre>
<p>Like the Mysql backup function this function too takes the name of the database as an argument and backs the db up in a predefined location which I have hard-coded because I don&#8217;t want to change it.</p>
<p><strong>3. Zip the DBs up</strong><br />
Even in the backed up state the DBs are pretty large, not to mention they are all different files. So if I want to upload all the DBs to the second server that&#8217;s a problem. So I decided to zip everything up in a single file. There could be other solutions, but the one I decided to implement was using that cute command line zip utility <a href="http://www.info-zip.org/Zip.html">Infozip</a> which I have been using since I was a teenager. All I needed to do was set up a command line call. Another little function for you:</p>
<pre class="brush: cpp;">
function Zip-DBs()
{
&quot;Zipping the files...&quot;
    #Zip the backup files
    Set-Location C:\autobackup\databases
    ./zip backup.zip *.sql *.bak | out-null

    remove-Item *.bak
    remove-Item *.sql
	&quot;Files zipped.&quot;
}
</pre>
<p>Note that I called &#8216;Set-Location&#8217; commandlet to set the location of the Powershell prompt to the folder where I have zip.exe and the SQL server (.bak files) and Mysql (.sql files) backup. After zipping them up I deleted the actual backup files using the &#8216;remove-item&#8217; commandlet.</p>
<p><strong>4. Backup Directories Through Powershell</strong><br />
We just finished backing up MySQL and SQL Server DBs through powershell, how hard can backing up a directory be? Since I have a zip file already set up I just wanted to add those website folder to my zip file. Here&#8217;s how the code works:</p>
<pre class="brush: cpp;">
   function BackupDir([string]$bkdir)
   {
	    Set-Location C:\autobackup\databases
		./zip -r backup.zip $bkdir

		&quot;Directory zipped: &quot; + $bkdir
   }
</pre>
<p>This one is a function too. We can just pass it the folder name, and it will zip it nicely up in the backup.zip file. Notice the &#8216;-r&#8217; argument sent to zip.exe, that&#8217;s to make it recurse the folder and collect all the sub-directories too.</p>
<p><strong>5. Upload it all</strong><br />
Wow! We just backed up all our DBs, and all our website folders in one zip file through Powershell. It&#8217;s resting nicely in a separate folder on our hard disk, but what good is that if we have another hard drive failure? We need to upload it our second server. At first I considered doing this from Powershell using the ftp program which is a part of Windows and then the .Net Webclient class. I even wrote some code</p>
<pre class="brush: cpp;">
   function Ftp-Upload {
	$File = &quot;c:\autobackup\databases&quot;
	$ftp = &quot;ftp://userlogin:userpass@blogsvani.com/httpdocs/Server1Backup.zip&quot;

	&quot;ftp url: $ftp&quot;

	$webclient = New-Object System.Net.WebClient
	$uri = New-Object System.Uri($ftp)

	&quot;Uploading $File...&quot;

	$webclient.UploadFile($uri, $File)
   }
</pre>
<p>This is the webclient code, I can&#8217;t provide the ftp program code cause I deleted it, but it&#8217;s easy. Unfortunately that didn&#8217;t work for me for some reason and when I ran out of patience I decided to use that wonderful program <a href="http://www.educ.umu.se/~cobian/cobianbackup.htm">Cobian Backup</a> which automates backup and ftp upload. I set it up to copy my zip file to my second server using ftp everyday at a specific time.</p>
<p><strong>6. Setting up Powershell to run daily</strong><br />
Did you miss the last piece of the puzzle? To have a completely automated backup we need to ensure that the Powershell script that we wrote so painstakingly runs daily at a certain time. We can do this using the Windows Task Scheduler. This wasn&#8217;t as easy as it was supposed to. To run the script correctly you need to run powershell, and pass it the name of the script you want to run along with some other arguments using the &#8216;Add Arguments&#8217; field. Here are the arguments:</p>
<pre class="brush: cpp;">
–Noninteractive –Noprofile -command &quot;&amp; 'c:\scripts\serverback.ps1'&quot;
</pre>
<p>Notice that before I pass the script name I prepend &#8216;&#038;&#8217;, and that I have the entire thing in double quotes. If you don&#8217;t have that your script won&#8217;t run. I found this online from another <a href="http://www.techhead.co.uk/using-task-scheduler-to-run-a-powershell-script">webpage </a> helpfully provided by Kiwi Si.</p>
<p>Oh and yes, don&#8217;t forget to run the command &#8211; &#8220;set-executionpolicy RemoteSigned&#8221; on your Powershell command prompt once to set up the necessary permissions or the script execution won&#8217;t work.</p>
<p>So this finally concludes the automated backup system for our server through Powershell. </p>
<p>Now wasn&#8217;t that a piece of cake?</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=441</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Godfather Teaches Business 1 : Make them an offer they can&#8217;t refuse</title>
		<link>http://cyrilgupta.com/?p=436</link>
		<comments>http://cyrilgupta.com/?p=436#comments</comments>
		<pubDate>Tue, 25 May 2010 17:35:05 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Godfather]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=436</guid>
		<description><![CDATA[Have you watched the Godfather carefully? It&#8217;s not just a movie about the mafia or the organized crime world in Godfather&#8217;s time. Ignore all the crime for a moment and just look at the lessons learnt. It is a practical treatise on business and success. Watch Godfather and you can learn how to survive and [...]]]></description>
			<content:encoded><![CDATA[<p>Have you watched the Godfather carefully? It&#8217;s not just a movie about the mafia or the organized crime world in Godfather&#8217;s time. Ignore all the crime for a moment and just look at the lessons learnt. It is a practical treatise on business and success. Watch Godfather and you can learn how to survive and succeed in the modern business world that is full of sharks. In the &#8216;Godfather teaches business&#8217; series I am going to take business wisdom from the three Godfather movies using the famous Godfather quotes, and show you what Godfather really meant, and how you can use that wisdom in your own business endeavors. </p>
<p>I started this series a long time ago and I wrote 9 parts. My intention was to write 12 complete parts, but I never got there and later a crash on the server deleted the work I had done. That was about 3 years ago. I am re-starting that series with this article, and hopefully I will have my 12 this time. </p>
<h3>Godfather Teaches business 1 : Make them an offer they can&#8217; refuse</h3>
<p><strong><a href="http://cyrilgupta.com/blogpics/GodfatherTeachesBusiness1Makethemanoffer_144A0/doncorleone.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="don-corleone" border="0" alt="don-corleone" align="left" src="http://cyrilgupta.com/blogpics/GodfatherTeachesBusiness1Makethemanoffer_144A0/doncorleone_thumb.jpg" width="200" height="244" /></a> &quot;I am gonna make him an offer he can&#8217;t refuse&quot;</strong>    <br /><em>Don Corleone</em></p>
<p>Don Corleone, the prodigal patriarch of the Corleone family was a very extraordinary man. Arriving in America after narrowly escaping death in Sicily at a very young age, he learnt the harsh lessons of life early on. He understood what motivates men, and he taught himself to exploit that. No wonder then that one of the most important lessons he taught us were to make them an offer they couldn&#8217;t refuse. </p>
<p>Let&#8217;s talk about that a bit. </p>
<p>When you are running a business you&#8217;re out to sell something. It could be a product, or even a service. Your aim is to get the buyer to give you money in exchange for the service. Why would he give you the money? When he thinks that he needs what you are selling, and that it is more valuable to him than the money that&#8217;s in his pocket. When he&#8217;s convinced about that he will hand over his cash happily. </p>
<p>When the elderly Godfather talked about an offer one can&#8217;t refuse he meant exactly that. An offer that makes the buyer pause, and wonder, and then come rushing to you with his purse in his hands. When you can make that kind of offer, you&#8217;ve scripted success for yourself. </p>
<p>When I think of offers like that many things come to mind, but nothing like the one from another elderly patriarch. Very removed from the Godfather in character and culture. He probably didn&#8217;t ever watch Godfather in his life. But he understood business and understood what an offer like that could bring. </p>
<p>That man &#8211; Dhirubhai Ambani told his son Mukesh that when he launched his phone services in India he should launch it at a rate cheaper than that of a post-card (the cheapest form of mailed letter in India), and if he could do that he would become a grand success. Beating the rate of a postcard wasn&#8217;t easy. It would require the establishment of infrastructure, and economies of scale that were never done in India before, but Mukesh did just that and Reliance India Mobile (as it was called then) introduced pan-Indian telephone calls at 40 paisa (.30 dollars) per minute, with free incoming calls (unheard of at that time), and achieved a subscriber base of 6.9 million in less than a year. </p>
<p>That unbelievable growth was the turning point of the Indian telecom industry. It woke up the rest of the industry and soon the prices of communication crashed which have been in part responsible for the communication revolution in India, and in bringing the information age to India. Today of course we have tariff plans that charge as low as 20 paisa a minute for outgoing calls and actually pay you money on incoming ones! </p>
<p>That one offer the subscribers couldn&#8217;t refuse finally ended up putting a cellphone in the hands of more than 250 million people in India. </p>
<p>If you can make an offer like that to your market then nobody can stop you from being a success. That offer doesn&#8217;t have to be about price alone. It could be an offer of better service, an offer of a better product, advanced technology, better treatment of customers, better after-sales, better communication, faster turnaround, you tell me! </p>
<p>So if you haven&#8217;t found an offer like that it&#8217;s time you stopped everything that you were doing. Sat down, and thought long and hard about your business. </p>
<p>Think about your operations, your customers, your competition, your margins, your processes. How can you squeeze out room for that one offer. Don&#8217;t stop thinking, wondering, seeking until you&#8217;ve found it. And when you finally find it, you will have won yourself a niche. </p>
<p>Go on. Make them an offer they can&#8217;t refuse.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=436</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy CS S Trick &#8211; How to Create CSS Tabs &#8211; 2 Easy ways</title>
		<link>http://cyrilgupta.com/?p=421</link>
		<comments>http://cyrilgupta.com/?p=421#comments</comments>
		<pubDate>Sun, 23 May 2010 03:52:43 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css tabs]]></category>
		<category><![CDATA[Website designing]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=421</guid>
		<description><![CDATA[Finally I have some breathing time away from the projects I was working on from January, so yesterday I fixed an issue on Codebix and in the night I worked on Blogvani. I wanted to improve the bad looking tabs in the side-bar, making the look like full-fledged tabs instead of white button-spaces. 
The only [...]]]></description>
			<content:encoded><![CDATA[<p>Finally I have some breathing time away from the projects I was working on from January, so yesterday I fixed an issue on <a href="http://codebix.com">Codebix</a> and in the night I worked on <a href="http://blogvani.com">Blogvani</a>. I wanted to improve the bad looking tabs in the side-bar, making the look like full-fledged tabs instead of white button-spaces. </p>
<p>The only problem in the exercise was to get he bottom line below the tabs to look right. The line should be gone from below the active tab, and should be visible below the inactive ones. Like in Blogvani</p>
<p><a href="http://cyrilgupta.com/blogpics/EasyCSSTrickHowtoCreateCSSTabs2Easyways_834E/tabs.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tabs" border="0" alt="tabs" src="http://cyrilgupta.com/blogpics/EasyCSSTrickHowtoCreateCSSTabs2Easyways_834E/tabs_thumb.png" width="240" height="25" /></a> </p>
<p>It wasn’t too hard, but I had to spin the CSS around a bit. I did this in a particular way (explained later), and later discovered that Google does it in another, excellent way. In this article I am going to explain how to do this in both the ways.</p>
<p>The individual tab items are li elements. Here’s the code</p>
<pre class="brush: xml;">
&lt;ul&gt;
 &lt;li&gt;
  &lt;a id=&quot;buzzhot&quot; href=&quot;&quot; class=&quot;&quot;&gt;हॉट&lt;/a&gt;
 &lt;/li&gt;
 &lt;li&gt;
  &lt;a class=&quot;sel&quot; id=&quot;buzzliked&quot; href=&quot;&quot;&gt;पसंद किये गये&lt;/a&gt;
 &lt;/li&gt;
  &lt;li&gt;
    &lt;a id=&quot;buzzread&quot; href=&quot;&quot;&gt;पढ़े गये&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a id=&quot;buzzcomment&quot; href=&quot;&quot;&gt;टिप्पणी प्राप्त&lt;/a&gt;
  &lt;/li&gt;
 &lt;/ul&gt;
 </pre>
<p>
The selected element has a ‘sel’ class which specifies the border, and changes the background color to white. The li elements have generous padding, and I’ve set a min-width of 50 so that no tab is too narrow. Here’s the css:</p>
<p><pre class="brush: css;">
.tpbtns li a.sel
{
    background:none repeat scroll 0 0 #FFFFFF;
    border-color:#B8B8B8 #B8B8B8 -moz-use-text-color;
    border-style:solid solid none;
    border-width:1px 1px medium;
} 

.tpbtns li a
{
    display:block;
    font-weight:700;
    margin:5px 5px 0;
    min-width:50px;
    padding:4px;
}
</pre>
</p>
<p>The only riddle is how to get the background line to disappear for the selected tags. Like I said earlier there are 2 ways. Here’s the way I used.</p>
<p><strong>Method 1: Making Tabs Using a Background Image for the bottom line.</strong></p>
<p>Since the li elements are enclosed in a div, if I set a border on the div it will be over the li elements and the border will not disappear for the selected tab. So I used a simple 1px * 10 px image which was of the same color as the border.</p>
<p>Here’s the css    </p>
<pre class="brush: css;">
background:url(&quot;/img/gln.png&quot;) repeat-x scroll center bottom #D9E1E5;</pre>
</p>
<p>It’s a simple image with repeat set to horizontal, and alignment to bottom. So the selected div will be able to cover the border (since it’s in background) and will give the impression of a proper tab.</p>
<p>One line story: Use an image set to background to create the border instead of using the css border property on the containing div.</p>
<p><strong>Method 2: Set the border on the ul</strong></p>
<p>Incidentally google had the same effect on the new Google font API and out of curiosity I checked how they did it. It turns out this was simpler than the method I employed.</p>
<p>All Google did was set the border property on the ul element itself on the enclosing div, then they padded the selected div a bit on the bottom, and set it’s bottom position to –1 after setting the position property to ‘relative’ in the CSS.</p>
<p>Here’s the css:</p>
<p><pre class="brush: css;">
.g-tabs ul
{
    background:none repeat scroll 0 0 #EBEFF9;
    border-bottom:1px solid #6B90DA;
    display:block; list-style-type:none;
    margin:1.5em 0 2em;
    padding:8px 10px 0;
    white-space:nowrap;
}     

.g-tabs li.g-tab-selected a
{
    background:none repeat scroll 0 0 #FFFFFF !important;
    border-color:#6B90DA #6B90DA #FFFFFF;
    border-style:solid; border-width:1px 1px 2px;
    bottom:-1px; color:#000000 !important;
    cursor:default; font-weight:bold;
    padding:6px 14px 4px;
    position:relative;
    text-decoration:none;
}
</pre>
</p>
<p>The second method is slightly easier to implement and in hindsight I should have thought of that <img src='http://cyrilgupta.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=421</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How far back do you have to go back to reach history?</title>
		<link>http://cyrilgupta.com/?p=418</link>
		<comments>http://cyrilgupta.com/?p=418#comments</comments>
		<pubDate>Sun, 09 May 2010 17:08:57 +0000</pubDate>
		<dc:creator>Cyril</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Economics]]></category>
		<category><![CDATA[World]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[countries]]></category>
		<category><![CDATA[economy]]></category>
		<category><![CDATA[friedman]]></category>

		<guid isPermaLink="false">http://cyrilgupta.com/?p=418</guid>
		<description><![CDATA[I am reading a book these days of which this is the second copy. The first time I bought it, I lost it while I had read only half. That was some months ago, I thought I would find it later so I kept looking… I gave up a few days ago and bought a [...]]]></description>
			<content:encoded><![CDATA[<p>I am reading a book these days of which this is the second copy. The first time I bought it, I lost it while I had read only half. That was some months ago, I thought I would find it later so I kept looking… I gave up a few days ago and bought a fresh copy. It was a good book, good enough to force me to spend the money on it again.</p>
<p>The book is ‘The Lexus and The Olive Tree’. The writer is Thomas Friedman. It’s on the same topic as ‘The Clash of Civilizations’, but is easier to read. So I am reading it with more attention than I read the Clash of Civilizations.</p>
<p>We’re almost halfway into 2010, and this book’s first edition was written at the beginning of the decade. So while a lot is still the same, too much has changed.</p>
<p>The book talks about the telecom and the Internet revolution, globalization vs. protectionism, and other topics which are still relevant. Thomas Friedman does an excellent job of showing me how globalization isn’t just good and necessary, but how it is unavoidable. Friedman is a well-traveled writer and through anecdotes from his own journeys and meetings he makes it quite clear that whether governments like it or not globalization is going to happen, and that there is going to be a plenty of resistance to it because people see it as a threat to their culture.</p>
<p>“There’s no use protesting against globalization wearing a blue jeans.” Well the process is still on. Globalization isn’t global yet, but it’s pretty much everywhere.</p>
<p>But the book has its funny bits too. Thomas Friedman is an American patriot and he makes it a point to make it quite clear why America is so successful. He compares the American way of working to Japan and Europe and comes to the conclusion that they can’t compete with America, he mentions China but only to reject its &#8216;brand of globalization&#8217;. He thinks globalization can&#8217;t work without capitalism, and because China is communist dominated it is likely to hit some serious snags which will remove it form the scene. Well, Mr. Friedman. Heh Heh&#8230;</p>
<p>He doesn&#8217;t mention India and use the  phrase  ‘competition to USA’ in the same paragraph.</p>
<p>That was 10 years ago. In 10 years a lot hasn’t changed, but a lot has. America, the greatest place for innovation and business is now feeling the heat from India and China.</p>
<p>American senators want Indians to quit taking away American jobs (globalization goes full circle, you see the globe is round). They want Indian companies to quit coming to America, and they want Indians to quit working so hard on everything.</p>
<p>America is still the greatest place for business and innovation, but I see Indians coming back from America to innovate in India, and others who want to come back.</p>
<p>I love America, its culture, its freedom and its attitude. There’s no denying that, but in 10 years India has changed enough that the American president tells his country’s children to buckle up cause the Indians are coming.</p>
<p>If Thomas Friedman wrote that book again now, he would talk more about India and China than he talked about Europe and Japan.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyrilgupta.com/?feed=rss2&amp;p=418</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
