Saturday, January 29, 2011

How to Add code snippets to blogger ??

This is my first post with something interesting. Although many such posts exist out there, i made a collection of those to make things easy for myself and the guys out there.

I prefer SyntaxHighlighter, a open source project hosted at code.google.com.Or now hosted at http://alexgorbatchev.com/SyntaxHighlighter/

After you've checked out the the source code, or downloaded a package (Might be outdated, as compared to trunk) from somewhere, its time to add them to blogger.
Its better if you checkout the latest trunk.

Now you need to host the source files somewhere, I am using my google sites  for this job. We can as well use the code.google.com itself, but the directory structure might change in the future, leaving your blog in a bad look.

Anyways getting to the point, there are some javascript (.js) files in the code (See Scripts Folder e.g. shBrushCpp.js etc). Each of this script is for a particular language(Cpp for c++ , vb for visual basic etc), so u might want all of them or just few depending on your needs. Use as minimum as required, as javascript can take some time to load.

Apart from these language specific files, you need to use shCore.js . Also You need the SyntaxHighlighter.css which defines all the classes for our use. and other file clipboard.swf .

Upload these files to your webhost (or google sites for that matter).


Now add the following snippet before </body>  tag. 
Add you domain name to the to the links before moving on.

Example program in c++ ,


int main()
  {
    printf("Hello World !");
    return 0;
  }

Friday, January 28, 2011

Introduction

Hi All,

Some of you might be returning visitors from http://blog.gunjanbansal.in (Computers and Technology). This is my new blog were i will "try" to hone my programming skills as well as give hints to people. I am not the best programmer out there, but sure I'll try my very best to be. Hope I succeed. Please add a comment to a post if you feel something is not as its supposed to be. I will update it within a day or two. Drop me a mail if i miss.