Friday, July 23, 2010

Twitter like notification bar in jquery

Just designed a twitter like notification bar in jquery... See it in action demo here...

Just add the following jquery,

            $(document).ready(function({
            var $alertdiv $('<div id = "alertmsg"/>');
            $alertdiv.text("Welcome to twitter");
            $alertdiv.bind('click'function({
                $(this).slideUp(200);
            });
            $(document.body).append($alertdiv);
            $("#alertmsg").slideDown("slow")
            setTimeout(function($alertdiv.slideUp(200}3000);
                            });

Css:

   #alertmsg
    {
      font-family:Arial,Helvetica,sans-serif;
      font-size:135%;
      font-weight:bold;
      overflowhidden;
      width100%;
      text-aligncenter;
      positionabsolute;
      top0;
      left0;
      background-color#333F31;
      height20;
      color#F3FDED;
      font20px/40px arialsans-serif;
      opacity.9;
        display:none;
}

Thursday, July 22, 2010

Simple Jquery Dropdown menu...

I ve designed a simple jquery dropdown Menu without using any jquery menu plugins....


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.min.js"></script>
    <style type="text/css">
        ul, li{margin:0; padding:0; list-style:none;}
    /* Targeting both first and second level menus */
#Programming li { float: left; position: relative;font-family:Arial,Helvetica,sans-serif; }
#Programming li a { background: #f3fded; border: 3px solid #333f31; color: #333; display: block; margin: 0 5px 0 0; padding: 5px 8px;text-decoration:none; font-size:110%;font-weight:bold;}
#Programming li a:hover { background: #333f31;color:#fff; text-decoration: none; font-size:110%;font-weight:bold;}

/* Targeting the first level menu */
#Programming { display: block; height: 35px; padding: 10px 0; width: 700px; z-index: 100; position: absolute;}
#Programming > li > a { font-size:110%;font-weight:bold; }

/* Targeting the second level menu */
#Programming li ul { background: #f3fded; border: 3px solid #333f31; color: #333; display: none; margin: -3px 0 0 0; width: 105px; position: absolute; }
#Programming li ul li { width: 100% }
#Programming li ul li a { background: none; border: none; line-height: 30px; margin: 0; padding: 0 0 0 5px; text-decoration:none;  font-size:110%; font-weight:bold;}
#Programming li ul li a:hover { background: #333f31;color:#fff;font-size:110%;font-weight:bold;}

/* A class of current will be added via jQuery */
#Programming li.current > a { background: #333f31;color:#fff; font-size:110%;font-weight:bold;}

/* CSS fallback */
#Programming li:hover > ul.child { display: block; }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div id="ProgMenu" style="padding-left: 45px;">
                            <ul id="Programming">
                                <li><a href="#">.net</a>
                                    <ul class="child">
                                        <li><a href="#">asp.net</a></li>
                                        <li><a href="#">WPF</a></li>
                                        <li><a href="#">Winforms</a></li>
                                        <li><a href="#">Silverlight</a></li>
                                     </ul>
                                </li>
                                <li><a href="#">java</a>
                                    <ul class="child">
                                        <li><a href="#">Struts</a></li>
                                        <li><a href="#">Spring</a></li>
                                        <li><a href="#">Hibernate</a></li>
                                    </ul>
                                </li>
                               </ul>
                        </div>

                        <script type="text/javascript">
                            $(document).ready(function() {

                                $("#Programming ul.child").removeClass("child");

                                $("#Programming li").has("ul").hover(function() {
                                    $(this).addClass("current").children("ul").fadeIn();
                                }, function() {
                                    $(this).removeClass("current").children("ul").stop(true, true).css("display", "none");
                                });

                            });
                        </script>
    </div>
    </form>
</body>
</html>

Monday, July 19, 2010

Quartz.net with ASP.NET implementation...

Just now finished my sample scheduled task with quartz.net in my asp.net web application.....


Here's a complete example how to do this using quartz.net. First of all, you have to create a class which implements the IJobinterface defined by quartz.net. This class is called by the quartz.net scheduler at tne configured time and should therefore contain your send mail functionality:



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.IO;
    using Quartz;
    
    /// <summary>
    /// Summary description for SendMailJob
    /// </summary>
    public class SendMailJob : IJob
    {
        public void Execute(JobExecutionContext context)
        {
            WriteToFile();
        }
        private static void WriteToFile()
        {
            StreamWriter SW;
            SW = File.CreateText("C:\\Documents and Settings\\chendur\\Desktop\\samp.txt");
            SW.WriteLine("God is greatest of them all");
            SW.WriteLine("This is second line");
            SW.WriteLine(getIndianStandardTime());
            SW.Close();
        }
        public static DateTime getIndianStandardTime()
        {
            TimeZoneInfo IND_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE);
        }
    }
Next you have to initialize the quartz.net scheduler to invoke your job once a day at 06:00. This can be done in Application_Start of global.asax:
<%@ Application Language="C#" %>
<%@ Import Namespace="Quartz"%>
<%@ Import Namespace="Quartz.Impl" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        ISchedulerFactory schedFact = new StdSchedulerFactory();
        // get a scheduler
        IScheduler sched = schedFact.GetScheduler();
        sched.Start();
        // construct job info
        JobDetail jobDetail = new JobDetail("mySendMailJob", typeof(SendMailJob));
        // fire every day at 06:00
        //Trigger trigger = TriggerUtils.MakeDailyTrigger(06, 00);
        SimpleTrigger trigger2 = new SimpleTrigger("myTrigger",
                                null,
                                DateTime.UtcNow,
                                null,
                                SimpleTrigger.RepeatIndefinitely,
                                TimeSpan.FromSeconds(60)); 
        //Trigger trigger = TriggerUtils.MakeHourlyTrigger();
        //// start on the next even hour
        //trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);  
        //trigger.Name = "mySendMailTrigger";
        // schedule the job for execution
        sched.ScheduleJob(jobDetail, trigger2);
    }

That's it. Your job should be executed every day at 06:00. For testing, you can create a trigger which fires every minute (for example). Have a look at the method of TriggerUtils.

Friday, July 16, 2010

Get Indian Standard Time(IST) in c#

When you are hosting you application to a production server outside india, its often we need indian time so i ve created a c# method which returns indian standard time from your server wherever it is located in india...


public DateTime getIndianStandardTime()
{
 TimeZoneInfo IND_ZONE=TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
 return TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IND_ZONE);}

Thursday, July 15, 2010

Grant Mysql Database access...

Today morning i was just looking around for a mysql query which grants me access to another database....



GRANT ALL PRIVILEGES ON dbname.* TO 'dbname'@'urpartnerip'    IDENTIFIED BY 'dbname' WITH GRANT OPTION;
GRANT SELECT ON mysql.proc TO 'dbname'@'urpartnerip' IDENTIFIED BY 'dbname'