Simple Templating in C#

Hi Kids!

Here is a simple templating Sample and replacing placeholders in C#

StringBuilder str = new StringBuilder();          
string temp = "";

foreach (Item item in items)
     temp = Template.Text;    
     StringBuilder strTemplace = new StringBuilder(temp);
     strTemplace.Replace("{title}", item.title);
     strTemplace.Replace("{url}", item.url);
     strTemplace.Replace("{location}", item.location);

Alright Kids!

How to love C# and Entity Framework

This is how to fall in love with Entity Framework Kids.

 [RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$", ErrorMessage = "Invalid Characters")]
 [Display(Name = "Firstname")]
 public string FirstName { get; set; }

 [RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$", ErrorMessage = "Invalid Characters")]
 [Display(Name = "Lastname")]
 public string LastName { get; set; }

How can anyone not love that piece of art Kids.
It’s a thing of beauty.

Creating Simple Serial Number in C# and Entity Framework

Hi Kids,

If you want to create a simple serial generator with prepended Characters in C#, here is how you do it Kids.

    var guestCode = "SERIAL00000000";
    // coming from newly created database entry from using Entity Framework
    var customerNumber =;
    // this code is self explainatory or do I have to explain it for you? c'mon...
    guestCode = guestCode.Remove(guestCode.Length - customerNumber.Length);
    // you know what's going on right?
    guest.GuestNumber = guestCode + customerNumber.ToString();

   // then apply the update to database using the db Context
    db.Entry(guest).State = EntityState.Modified;

Ciao Kids!

The best and Proper Way to code in Javascript is not to use Globals

Hi Kids,

You must avoid using globals in Javacript, its because
They are slower to look up than local variables and will clutter up the global namespace as well.

So here take a look kids. This is how you do it properly. 🙂

      var createObject = function(){
            var count = 0;
            var todo1 = function(){
                count += 1;

            var todo2 = function(){
                count += 2;

            return {
                task1: todo1,
                task2: todo2

      var obj = createObject();

Alright Kids! Ciao!

Smooth Animated anchor Scrolling using Jquery

Hi Kids,

Here is a simple snippet to add scrolling effect with anchor and js.

$('.some_div > a').click(function(){
            $('html, body').animate({
                  scrollTop: $( $.attr(this, 'href') ).offset().top + (some_adjustments)
            }, 800);
            return false;

And here is for your HTML dom structure.

<div class="some_div">
        <a href="#achor">Anchor Link Here</a>

<div id="anchor">
     Your Load of BS here Kids!

Alright Kids. Enjoy! Ciao!

How to add custom post in WordPress

Hi Kids,

If you want to add custom post in wordpress, aside from the default POST and PAGE type posts.
all you have to do is add this piece of code in your functions.php

You have to change the “custompost “variable though.

  'labels' => array(
  'name' => __( 'Custom Post' ),
  'singular_name' => __( 'Custom Post' ),
  'description' => __('Custom Post'),
  'public' => true,
  'register_meta_box_cb' => 'custompost_meta_boxes',
  'show_ui' => true,
  'supports' => array(

register_taxonomy_for_object_type('category', 'custompost');
register_taxonomy_for_object_type('post-tag', 'custompost');

function custompost_meta_boxes() {
 //add_meta_box( 'testpost_meta', __('TEST POST'), 'testpost_meta_box', 'testposts','normal', 'high' );

Alrigh kids,


Injecting String within a String in Javascript (substring)

Hi Kids,

This is how to insert String within a String using Javascript’s Substring.

    $(".footer-icons > .icon-item > a").mouseover(function(e){          
          var currentSrc = $(this).find("img").attr("src");
          var newSrc = currentSrc.substring(0,currentSrc.lastIndexOf('.'));
          newSrc += "-green.jpg";
    $(".footer-icons > .icon-item > a").mouseout(function(e){          
          var currentSrc = $(this).find("img").attr("src");
          var newSrc = currentSrc.substring(0,currentSrc.lastIndexOf('.')-6);
          newSrc += ".jpg";

Drop a comment for your questions Kids.

Common Techniques for aligning DIVs horizontally

1. Floating

     <div class="floatleft">LEFT</div>
     <div class="floatright">RIGHT</div>
     <div class="clearboth"></div>
    .floatleft{ float:left; }
    .floatright{ float:right; }
    .clearboth{ clear:both; }

2. Inline-Block

     <div class="item">LEFT</div>
     <div class="item">RIGHT</div>
    .item{ display:inline-block; }

3. Using Bootstrap

     <div class="row">
         <div class="md-col-6">Left</div>
         <div class="md-col-6">Right</div>

4. Foundation

     <div class="row">
         <div class="medium-6 columns">Left</div>
         <div class="medium-6 columns">Right</div>

5. Using Display:Tables

     <div style="display:table-row">
         <div style="display:table-cell">Left</div>
         <div style="display:table-cell">Right</div>

If you know other techniques let the kids know.