Tuesday, February 24, 2015

Published 12:53 AM by with 0 comment

Getting Started with NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:
npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser
Then create a package.json and publish it:
cd /path/to/your-project
npm init

npm install -g pakmanager
# this shows you dependencies as you `require`d them
pakmanager deps
# now edit `package.json` and add any deps you forgot about

npm publish ./

Beta and Release versions

If you don't want something to install by default
npm publish ./ --tag beta
If you published a bugfix as v1.0.7 and need to set v1.1.3 back to latest
git checkout v1.0.7
npm publish ./

git checkout v1.1.3
npm tag foobar@1.1.3 latest
Read More
    email this       edit

Wednesday, August 27, 2014

Published 11:20 PM by with 0 comment

CSS3 Animation

<style>
 @-webkit-keyframes test-css {
  0%,100%  { opacity: 0;width:100px;margin-left:50px }
  50% { opacity: 1;width:200px;margin-left:200px  }
}
@-moz-keyframes test-css {
  0%,100%  { opacity: 0;width:100px;margin-left:50px }
  50% { opacity: 1;width:200px;margin-left:200px  }
}
@-o-keyframes test-css {
  0%,100%  { opacity: 0;width:100px;margin-left:50px }
  50% { opacity: 1;width:200px;margin-left:200px  }
}
@keyframes test-css {
  0%,100%  { opacity: 0;width:100px;margin-left:50px }
  50% { opacity: 1;width:200px;margin-left:200px  }
}
  
@-moz-keyframes ani
{
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
  
  
@-moz-keyframes move {
  from { top: 0; left: 0; }
  to   { top: 100px; left: 100px; }
}  
  
.box
    {
          background-color:#000;
          width:100px;
          height:100px;
          position:relative;
          margin-left: 50px;
    }
#box {
  -webkit-animation: test-css 5s infinite; /* Safari 4+ */
  -moz-animation:    test-css 5s infinite; /* Fx 5+ */
  -o-animation:      test-css 5s infinite; /* Opera 12+ */
  animation:         test-css 5s infinite; /* IE 10+, Fx 29+ */
}
  
#box1
    {
      -webkit-animation: ani 5s infinite; /* Safari 4+ */
      -moz-animation:    ani 5s infinite; /* Fx 5+ */
      -o-animation:      ani 5s infinite; /* Opera 12+ */
      animation:         ani 5s infinite; /* IE 10+, Fx 29+ */
    }
 
#box2
    {
      -webkit-animation: move 10s steps(10) infinite alternate;
      -moz-animation:    move 10s steps(10) infinite alternate;
      -o-animation:      move 10s steps(10) infinite alternate;
      animation:         move 10s steps(10) infinite alternate;
    }
</style>
<div class="box" id="box">
    animation 1
</div>
<div style="margin-top:50px" ></div>
<div id="box1" class="box">
    animation 2
</div>  
<div style="margin-top:50px" ></div>
<div id="box2" class="box">
    animation 3
</div>



animation 1
animation 2
animation 3
Read More
    email this       edit

Sunday, January 5, 2014

Published 11:09 PM by with 0 comment

Google Excel Time Difference


Google Excel Time Difference 

  function TimeDiff(cell1, cell2) {
        return ConvertMilliSecondsToTimeSpan(Math.abs(cell1 - cell2));
    }

    function ConvertMilliSecondsToTimeSpan(t) {
        var cd = 24 * 60 * 60 * 1000,
            ch = 60 * 60 * 1000,
            d = Math.floor(t / cd),
            h = '0' + Math.floor((t - d * cd) / ch),
            m = '0' + Math.round((t - d * cd - h * ch) / 60000);
        return [h.substr(-2), m.substr(-2), '00'].join(':');
    }

How to use it

1/1/2014 21:00:002/1/2014 1:15:00

function usage

=TimeDiff(E24,F24)
Read More
    email this       edit

Monday, November 4, 2013

Published 1:18 AM by with 0 comment

google translator


Language is the human capacity for acquiring and using complex systems of communication, and a language is any specific example of such a system. The scientific study of language is called linguistics. Estimates of the number of languages in the world vary between 6,000 and 7,000. However, any precise estimate depends on a partly arbitrary distinction between languages and dialects. Natural languages are spoken or signed, but any language can be encoded into secondary media using auditory, visual, or tactile stimuli, for example, in graphic writing, braille, or whistling. This is because human language is modality-independent. When used as a general concept, "language" may refer to the cognitive ability to learn and use systems of complex communication, or to describe the set of rules that makes up these systems, or the set of utterances that can be produced from those rules. All languages rely on the process of semiosis to relate signs with particular meanings. Oral and sign languages contain a phonological system that governs how symbols are used to form sequences known as words or morphemes, and a syntactic system that governs how words and morphemes are combined to form phrases and utterances.
Read More
    email this       edit

Friday, November 1, 2013

Published 4:21 AM by with 1 comment

Simple pagination using http://flaviusmatis.github.io/simplePagination.js


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>  
   <link rel="stylesheet" type="text/css" href="http://flaviusmatis.github.io/simplePagination.js/simplePagination.css" />  
   <script type="text/javascript" src="http://flaviusmatis.github.io/simplePagination.js/jquery.simplePagination.js"></script>  
   <script type="text/javascript" charset="utf-8">  
     $(document).ready(function () {  
       var itemsOnPage = 3;  
       $('#paging').pagination({  
         items: $('#content > div').length,  
         itemsOnPage: itemsOnPage,  
         cssStyle: 'light-theme',  
         onPageClick: function (pageNumber, event) {  
           var pageN = pageNumber != 0 ? (pageNumber - 1) : pageNumber;  
           var from = (pageN * itemsOnPage) + 1;  
           var to = (pageNumber * itemsOnPage);  
           console.log('page :'+pageNumber+' from: ' + from + ' to :' + to);  
           $('#content > div').css({ 'display': 'none' });  
           for (var i = from; i <= to ; i++) {  
             console.log('loop :'+i);  
             $('#content > div:eq(' + (i-1) + ')').css({ 'display': 'block' });  
           }  
         },  
         onInit: function () {  
           $('#content > div').css({ 'display': 'none' });  
           for (var i = 0; i <itemsOnPage; ++i) {  
             $('#content > div:eq('+i+')').css({ 'display': 'block' });  
           }  
         }  
       });  
     });  
   </script>  
  <div id="content" style="width:210px">  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">1</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">2</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">3</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">4</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">5</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">6</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">7</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">8</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">9</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">10</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">11</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">12</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">13</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">14</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">15</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">16</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">17</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">18</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">19</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">20</div>  
     <div style="width:200px;height:20px;background-color:blueviolet;margin-bottom:5px">21</div>  
   </div>  
   <div id="paging" ></div>  

Read More
    email this       edit

Monday, June 17, 2013

Published 10:29 AM by with 0 comment

Increase Virtual Box VDI disk size on MAC or Windows

Need more space on your Virtual Box disc? I installed Windows 7 on Oracle Virtual Box but didn’t estimate the size of disk correctly. The drive is now nearing it’s capacity, how do you extend the size? It will take the following steps to achieve an extended disk capacity:
  1. Create a new virtual disk
  2. Clone the old disk to this newly created virtual disk
  3. Disconnect the old disk via storage settings in Virtual Box
  4. Connect/Attach the new disk to the Virtual Machine
  5. Boot up using the new disk
  6. Go to Windows Computer Management and Extend the disk space
Let’s go each step in a bit of detail now.
1. Create new virtual disk via Settings –> Storage. Make sure you choose enough size as per your requirements when creating this new disk. Choose Dynamically expanding storage for the disk storage type.
Create new virtual disk
2. Clone the old disk to this new disk – the idea is that the bigger new disk receives a disc copy of the old one. Use the following command for this (assuming Oracle VirtualBox is installed at C:\VirtualBox on your machine, otherwise navigate to the appropriate directory first):
1C:\VirtualBox>
2C:\VirtualBox>VBoxManage clonehd [OldHDDFile.vdi] [NewHDDFile.vdi] --existing
3C:\VirtualBox>
Note: Use full path with [OldHDDFile.vdi] and [NewHDDFile.vdi]. It can take few minutes for the Clone process to complete.
3. Disconnect the old disk via storage settings in Virtual Box

4. Connect/Attach the new disk to the Virtual Machine
5. Boot/Start the Virtual Machine
6. Go to Windows Computer Management –> Disk/Storage management and Extend the disk space on C drive to use the newly created/unallocated disk space
That’s all enjoy the extended sized disk!!
Read More
    email this       edit

Sunday, June 9, 2013

Published 1:14 AM by with 0 comment

Abstract Classes C#

Abstract


The abstract modifier can be used with classes, methods, properties, indexers, and events.
Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.
Abstract classes have the following features:
  • An abstract class cannot be instantiated.
  • An abstract class may contain abstract methods and accessors.
  • It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
  • A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation.
Abstract methods have the following features:
  • An abstract method is implicitly a virtual method.
  • Abstract method declarations are only permitted in abstract classes.
  • Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example:
public abstract void MyMethod();

  • The implementation is provided by an overriding method, which is a member of a non-abstract class.
  • It is an error to use the static or virtual modifiers in an abstract method declaration.
Abstract properties behave like abstract methods, except for the differences in declaration and invocation syntax.
  • It is an error to use the abstract modifier on a static property.
  • An abstract inherited property can be overridden in a derived class by including a property declaration that uses the override modifier.
An abstract class must provide implementation for all interface members.
An abstract class that implements an interface might map the interface methods onto abstract methods. For example:
interface I 
{
   void M();
}
abstract class C: I 
{
   public abstract void M();
}

Example

In this example, the class MyDerivedC is derived from an abstract class MyBaseC. The abstract class contains an abstract method, MyMethod(), and two abstract properties, GetX() and GetY().
// abstract_keyword.cs
// Abstract Classes
using System;
abstract class MyBaseC   // Abstract class
{
   protected int x = 100; 
   protected int y = 150;
   public abstract void MyMethod();   // Abstract method

   public abstract int GetX   // Abstract property
   {
      get;
   }

   public abstract int GetY   // Abstract property
   {
      get;
   }
}

class MyDerivedC: MyBaseC
{
   public override void MyMethod() 
   {
      x++;
      y++;   
   }   

   public override int GetX   // overriding property
   {
      get 
      {
         return x+10;
      }
   }

   public override int GetY   // overriding property
   {
      get
      {
         return y+10;
      }
   }

   public static void Main() 
   {
      MyDerivedC mC = new MyDerivedC();
      mC.MyMethod();
      Console.WriteLine("x = {0}, y = {1}", mC.GetX, mC.GetY);    
   } 
}
Abstract classes are closely related to interfaces. They are classes that cannot be instantiated, and are frequently either partially implemented, or not at all implemented. One key difference between abstract classes and interfaces is that a class may implement an unlimited number of interfaces, but may inherit from only one abstract (or any other kind of) class. A class that is derived from an abstract class may still implement interfaces. Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code.



// C#
abstract class WashingMachine
{
   public WashingMachine()
   {
      // Code to initialize the class goes here.
   }

   abstract public void Wash();
   abstract public void Rinse(int loadSize);
   abstract public long Spin(int speed);
}

// C#
class MyWashingMachine : WashingMachine
{
   public MyWashingMachine()
   {  
      // Initialization code goes here.    
   }

   override public void Wash()
   {
      // Wash code goes here.
   }

   override public void Rinse(int loadSize)
   {
      // Rinse code goes here.
   }

   override public long Spin(int speed)
   {
      // Spin code goes here.
   }
}
Ref:http://msdn.microsoft.com/en-us/library/sf985hc5(v=vs.71).aspx
Read More

    email this       edit
Published 1:13 AM by with 0 comment

Abstract Classes C#


Read More
    email this       edit

Wednesday, May 29, 2013

Published 12:31 PM by with 0 comment

Installing Active Directory Domain Services (AD-DS)


Method 1 – Server Manager/Initial Configuration Tasks

Roles can and should be added from Server Manager (but they can also be initiated from the Initial Configuration Tasks wizard that auto-opens the first time you log on to the server).
    1. Open Server Manager by clicking the icon in the Quick Launch toolbar, or from the Administrative Tools folder.
    2. Wait till it finishes loading, then click on Roles > Add Roles link.
    1. In the Before you begin window, click Next.
    1. In the Select Server Roles window, click to select Active Directory Domain Services, and then click Next.
    1. In the Active Directory Domain Services window read the provided information if you want to, and then click Next.
    1. In the Confirm Installation Selections, read the provided information if you want to, and then click Next.
    1. Wait till the process completes.
    1. When it ends, click Close.
    1. Going back to Server Manager, click on the Active Directory Domain Services link, and note that there's no information linked to it, because the DCPROMO command has not been run yet.
    1. Now you can click on the DCPROMO link, or read on.
      1. To run DCPROMO, enter the command in the Run command, or click on the DCPROMO link from Server Manager > Roles > Active Directory Domain Services.
      1. Depending upon the question if AD-DS was previously installed or not, the Active Directory Domain Services Installation Wizard will appear immediately or after a short while. Click Next.
      Note: The Advanced features of DCPROMO will be discussed in a future article.

      1. In the Operating System Compatibility window, read the provided information and click Next.
      1. In the Choosing Deployment Configuration window, click on "Create a new domain in a new forest" and click Next.
      1. Enter an appropriate name for the new domain. Make sure you pick the right domain name, as renaming domains is a task you will not wish to perform on a daily basis. Click Next.
      Note: Do NOT use single label domain names such as "mydomain" or similar. You MUST pick a full domain name such as "mydomain.local" or "mydomain.com" and so on.
      The wizard will perform checks to see if the domain name is not already in use on the local network.
      1. Pick the right forest function level. Windows 2000 mode is the default, and it allows the addition of Windows 2000, Windows Server 2003 and Windows Server 2008 Domain Controllers to the forest you're creating. Read my "Understanding Windows Server 2008 Active Directory Domain and Forest Functional Levels" article for more information on that.
      1. Pick the right domain function level. Windows 2000 Native mode is the default, and it allows the addition of Windows 2000, Windows Server 2003 and Windows Server 2008 Domain Controllers to the domain you're creating.
      Note: If you select "Windows Server 2008" for the forest function level, you will Not be prompted to pick a domain function level. Read more about domain and forest function levels on my "Understanding Windows Server 2008 Active Directory Domain and Forest Functional Levels" article.
      1. The wizard will perform checks to see if DNS is properly configured on the local network. In this case, no DNS server has been configured, therefore, the wizard will offer to automatically install DNS on this server.
      Note: The first DCs must also be a Global Catalog. Also, the first DCs in a forest cannot be a Read Only Domain controller.
      1. It's most likely that you'll get a warning telling you that the server has one or more dynamic IP Addresses. Running IPCONFIG /all will show that this is not the case, because as you can clearly see, I have given the server a static IP Address. So, where did this come from? The answer is IPv6. I did not manually configure the IPv6 Address, hence the warning. In a network where IPv6 is not used, you can safely ignore this warning.
      1. You'll probably get a warning about DNS delegation. Since no DNS has been configured yet, you can ignore the message and click Yes.
      1. Next, change the paths for the AD database, log files and SYSVOL folder. For large deployments, carefully plan your DC configuration to get the maximum performance. When satisfied, click Next.
      1. Enter the password for the Active Directory Recovery Mode. This password must be kept confidential, and because it stays constant while regular domain user passwords expire (based upon the password policy configured for the domain, the default is 42 days), it does not. This password should be complex and at least 7 characters long. I strongly suggest that you do NOT use the regular administrator's password, and that you write it down and securely store it. Click Next.
      1. In the Summary window review your selections, and if required, save them to an unattend answer file. When satisfied, click Next.
      1. The wizard will begin creating the Active Directory domain, and when finished, you will need to press Finish and reboot your computer.
      Note: You can automate the rebooting process by checking the Reboot on Completion checkbox.
      To automate domain controller installations, you can use an answer file or you can specify unattended installation parameters at the command line. More on that in my "Creating an Unattend Installation File for DCPROMO in Windows Server 2008" article.
      Note: As written in my "Installing Active Directory on Windows 2008 Server Core" article, configuring a Windows Server 2008 Server Core machine REQUIRES you to perform an automated installation of Active Directory on that server, as there is NOT DCPROMO GUI on Server Core.
      Your server now acts as a Domain Controller. Make sure you properly back it up. You can test functionality by using AD management tools such as Active Directory Users and Computers, examine the Event Logs, services and folders and shares that have been created.

      Links

Method 2 – Servermanagercmd.exe

Servermanagercmd.exe is the command prompt equivalent of the Add Roles and Add Features wizards in Server Manager. Through the use of various command line options, you can quickly and easily add or remove features and roles to or from your server, including the AD-DS role.
To install AD-DS by using Servermanagercmd.exe, simply enter the following command in the Command Prompt window:
Servermanagercmd.exe –I ADDS-Domain-Controller
Let the command run and when it finishes, AD-DS will be installed on the server.

Method 3 – Letting DCPROMO do the job

Oh yes. If you forget to install AD-DS or simply want to skip clicking on some windows, you can run DCPROMO from the Run command and before it is executed, the server will check to see if the AD-DS binaries are installed. Since they are not, they will auto-install.
After you complete the Add Roles Wizard, either click the link to start the Active Directory Domain Services Installation Wizard, or close Server Manager and manually run DCPROMO from the Run command.

Running DCPROMO

After installing the AD-DS role, we need to run DCPROMO to perform the actual Active Directory database and function installation.
Note: This guide assumes this is the first Domain controller in the forest, thus creating a new domain in a new forest. For a guide on how to add additional Domain Controllers to existing domains, please read my upcoming "Installing Additional Windows Server 2008 Domain Controllers in your Existing Active Directory Domain" article.
Read More
    email this       edit