Tuesday, November 26, 2013

Sass Vs SCSS

Css is taking its form to next level, by including scripts in it and I'm seeing lot of question, discussion about the SASS and SCSS... which one to follow, which is easy....what is the difference...

Here, I'm going to summarize what i found and examples are taken from wikipedia...;-)

SASS


Sass (Syntactically Awesome Stylesheets) is the scripting laugage that is interpreted into CSS. And It has 2 syntaxes.

1.  Indented syntax - uses indentation to separate code blocks
2. SCSS (Sassy CSS) - uses block formatting like that of CSS

SassScript provides the following mechanisms: variables, nesting, mixins, and selector inheritance

Variables : 

$margin: 20px;

body
 margin : $margin / 2

Nesting:

table.hl {
  margin: 2em 0;
  td.ln {
    text-align: right;
  }
}

Equilent CSS : 

table.hl {
  margin: 2em 0;
}
table.hl td.ln {
  text-align: right;
}

Mixins:

Most helpful feature, to avoid repeated code and easy modification in CSS.

@mixin table-base {
  th {
    text-align: center;
    font-weight: bold;
  }
  td, th {padding: 2px}
}

#data {
  @include table-base;
}

Equivalent Css:

#data th {
  text-align: center;
  font-weight: bold;
}
#data td, #data th {
  padding: 2px;
}

Selector Inheritance:

Interestingly, you can implement inheritance as like java / c# by using extend keyword.

.error {
  border: 1px #f00;
  background: #fdd;
}
.error.intrusion {
  font-size: 1.3em;
  font-weight: bold;
}

.badError {
  @extend .error;
  border-width: 3px;
}

Equivalent to

.error, .badError {
  border: 1px #f00;
  background: #fdd;
}

.error.intrusion,
.badError.intrusion {
  font-size: 1.3em;
  font-weight: bold;
}

.badError {
  border-width: 3px;
}

You can get more information from : http://sass-lang.com/guide

SCSS


The new main syntax (as of Sass 3) is known as “SCSS” (for “Sassy CSS”)

So, most people with interchange the term SASS and SCSS...Dont get confused....
When you become the master of SASS, check out the "Foundation" framework....
http://foundation.zurb.com/docs/index.html

Its simply awesome (http://foundation.zurb.com/business/why-foundation.html ).... You can design the website so quick and fast with Responsive Web design. 

Thursday, November 14, 2013

Git Commands - Quick Reference

Install git in Mac
http://code.google.com/p/git-osx-installer, Other OS, please refer here : http://git-scm.com/book/en/Getting-Started-Installing-Git


Initialize a Git repository and make the first commit

$ git init
$ git add .
$ git commit -m "Initial commit"

Create a new repository and push it up to GitHub:

$ git remote add origin git@github.com:<username>/demo_app.git
$ git push origin master

Create a branch and switch to the branch at the same time

$ git checkout  - b newbranch-dev
(or)

$ git branch  newbranch-dev
$ git checkout newbranch-dev

To List out the available Branch

$ git branch -a

To switch to master branch

$ git checkout master
$ git branch -a

To push the changes to particular branch. (origin is the remote created for the git url using <<git remote add command>>)

$ git push origin newbranch-dev

To get the latest version by cloning the git project, for first time (Reference : http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository)

$ git clone <<git clone public URL>>

To get the latest version from the git project after cloning. (origin is the remote created for the git url using <<git remote add command>>)

$ git pull origin newbranch-dev

To find the difference between current working copy and last version

$ git diff HEAD


To find the difference between any commit and Last version, you can get the commit_id by using this command(
$ git log -4 --pretty="%h - %s" - will give last 4 commits)

$ git diff commit_id HEAD


To find the difference between last version and previous commit


$ git diff HEAD^ HEAD

To get the current configured git user information

$ git config --list

To undo local changes and restore them to the current versions in the repository

$ git reset --hard

Thursday, November 7, 2013

Parameter Count Mismatch

O boy!.... Today, I bang my head to solve this issue....

I was trying to Send an attachment email through Dot Net Amazon SDK. But, got stuck with this issue.. Since the following code is standard, that you can get from internet, to convert the MailMessage To MemoryStream. Finally identify the issue and solved.

public static MemoryStream ConvertMailMessageToMemoryStream(MailMessage message)
        {
            Assembly assembly = typeof(SmtpClient).Assembly;
            Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
            MemoryStream fileStream = new MemoryStream();
            ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
            object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream });
            MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);
            sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true}, null); // Throws Error , Parameter Count Mismatch
            MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
            closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);
            return fileStream;
        }


You have to change the parameter array object. Since "Send" Private method has three parameters System.Net.Mail.MailMessage.Send(BaseWriter writer, bool sendEnvelope, bool allowUnicode).

Correct Code


public static MemoryStream ConvertMailMessageToMemoryStream(MailMessage message)
        {
            Assembly assembly = typeof(SmtpClient).Assembly;
            Type mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
            MemoryStream fileStream = new MemoryStream();
            ConstructorInfo mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
            object mailWriter = mailWriterContructor.Invoke(new object[] { fileStream });
            MethodInfo sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);
            sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true, true}, null); // Success
            MethodInfo closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
            closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);
            return fileStream;
        }

Tuesday, November 5, 2013

Processing the Error Log

It hard to search the specific error occurred in the log file, to go through manually, when the file is of huge size.

- to find number times it occurred
-to find the pattern of the error
-or quick review of the error message

I found an easy way to do that, You can use this command not only for log file, any text file. This commands is for Windows machine

>Find "Sent alert email to admin for email" ErrorLog11052013.log >EmailErr.txt

Display all the line that matches ""Sent alert email to admin for email" in the file "ErrorLog11052013.log" and the Output will be redirected to "EmailErr.txt" file.