Thursday, January 6, 2011

SEO One On One - Web of Links

Creating Links, Connecting other sites to yours.

The term Web of Links refers to creating multiple sites, each connected to the other one, in order to promote a specific website.

This is exactly what a website owner would like, an hour work (and about 50$  investment) which will generate his website 25 links.

Web of Links is mainly for indexing purposes and less for getting a higher page rank (PR) in search engines (Google).

I'll start by explaining the benefits of the Web of Links method:
Let's say you just created a website.

You've made all the right things...
Listed your site in all the indexes websites, registered to Google Analytics and Google Web Master Tool and even wrote some content pages in order to attract visitors.

This is good, the only problem is that Google may have not indexed all you pages yet.  If you're a small new website, this process can take awhile.

The Web of Links idea simply makes the linking process smoother.

Enter a domain selling website (with free hosting) like GoDaddy.
Buy a ".info" domain (costs 1.99$.  GoDaddy usually have bulk discounts).
Create a simple HTML page.

In this page you should right content which is related to your site.
Place a link to your website under the desired phrase.

After doing that, do the whole process again.
This time, make sure you link to your main website and to a secondary website.

Do that with 25 domains (as I said - 50$).
Make sure not to have sites exchanging links with each other (Google will ignore this linking).

People may tell you that this is black hat SEO...
Well...  It's not!

As long as you supply with rich, meaningful and unique content, Google doesn't care how you promote your website as long as it doesn't damage the user's surfing expirience.

Now, all you have left to do is keep up the good work as Al Bundy said:
"If you build it - They will come..."

Thanks,
Elad Shalom,
CTO at ITweetLive.com

Linked Files in Visual Studio 2010

File Linking, File Sharing and Shared Projects.

You know how it feels to have shared files on VSS?
Gooood.
Actually it felt so good that my beloved CTO (who said something about promotion?) switched to TFS just 4-5 months ago.  And ever since - I cry myself to sleep every night.

Instead of one file, shared between 5,6,7 or 10 projects, we now have a copied file for each project.  This is due to Microsoft "Best Practice" which says - No Shared Files.

Meaning...?
If I have a JavaScript file called Arrays.js.  It's all purpose is to handle arrays in JavaScript.  This file exists in 6 different projects, which mean, that if I have another addition to this small JavaScript library, I have to copy it to 6 different files in 6 different projects...

JUST SHOOT ME!!!

Finally, I have the fix we've all been waiting for, courtesy of VS 2010:
"Add File As Link"

How to Link Files to Different Projects:
Let’s say we have 2 completely different web sites.
One is 10Bet and the other is SportsBettingTech.

I will usually place the original file inside the main project, in this case - 10Bet. 
I click on the project name ->     Add ->  New Item...

A dialog box will open.

I will choose a JavaScript file.  Just for testing.  We will call it:  "LinkedFile.js".
I will place a small comment in this file, and Check In.


Now I will go to my second project.
Click on the project's name ->    Add -> Existing File...

A dialog box will open.

Go to the file you'd like to link to (hint: it's in a different project's folder) choose it, and instead of clicking the "Add" button click on that small arrow to the left.
Choose "Add As Link".
And you're done.


How File Linking Works:
The point of file linking is that you have one file.  This file physically exist in one place (the project it was created in) but has virtual copy of it wherever you want.
If you choose to change this file from the mother project -> after you check in -> you will be able to see the changes wherever you linked it to.

The Million Dollars Question:
"What happens if I change the file from elsewhere?"
That's a great question.
And the answer is: With a very (very) simple solution.
The original copy of the file is being checked out.  You will still be your secondary website's solution, but this file will automatically be checked out and displayed on your Visual Studio.
After you change it, simply check in and that's it.

Lots of luck and happiness and good night sleep,
Elad Shalom,
CTO at ITweetLive.com

Monday, January 3, 2011

First Steps In F Sharp

F# - also known as F Sharp.

As you know, there are some OOP languages out there. You probably know VB.Net, C# and Java but I'm about to talk about relatively new one.

I would like to talk a little about F Sharp.

Similar to C Sharp and VB.Net, F# is also targeting the .Net Framework and is also Object Oriented.
The main difference in F# is not it's unique syntax but rather the new point of view and better state of mind it brings to the Object Oriented Programming.

F Sharp uses "type inference" - meaning, the programmer doesn't need to keep his mind in the needed data type parameter and can just use the word "let" (similar to "var").
The data type will be deduce by the compiler itself during compilation (F# also allows explicit data types declaration).

After this short introduction to F# (very short) I would like to start the practical section.  and this post will be all about Lists in F Sharp.

Let’s make a small experiment:
Create a List of Ints in C#
List<int> newList = new List<int>();

Add the following values to this list:
newList.Add(5);
newList.Add(2);
newList.Add(-3);
newList.Add(1);

Now please try to sort it using "Absolute Value".
You'll probably find out that if you -did- manage to do this - you've used functionality programming.

In F# it's almost the same and as easy as can be once you get the point:
[5; 2; -3; 1] |> List.sortBy(fun intElem -> abs intElem)

Let’s test our C# abilities again by mapping that List of ints (each number will be powered by 3)
Again, most of you, who succeed used LINQ or other functional programming that C #allows, this is how it's don’t in F Sharp:
[5; 2; -3; 1] |> List.map(fun x-> x * x * x)

Another test for our C# (or Java) strength will be to try and filter that list for all ints that returns 0 when divided by 2.  In F Sharp it as easy as they come:
[5; 2; -3; 1] |> List.filter(fun x -> x % 2 = 0)

These were just couple of examples about F# and it's usability.  Hopefully it will help you understand the syntax and even more important - it will help you to think in functional programming.

BTW
How can we forget the immortal first program: "Hello World!" ?
printfn "Hello World!"


Good luck,
Elad Shalom,
CTO at ITweetLive.com

Sunday, January 2, 2011

String Manipulation - IsNullOrEmpty Method

I guess we all need to check strings all around the code. And for that, we have about gazillion ways, and here are some -BAD- examples:
  1. if (ourString == null)
  2. if (ourString == "")
  3. if (ourString.trim() == "")
  4. if (ourString == string.empty)

Luckily, Microsoft have came up with this great method "IsNullOrEmpty" which has something like this:

return val == null || val == String.Empty;

This is a great function thought it doesn't cover 100% of the cases.  Lets say, for example, that I have this string: "    ".

Now, according to Microsoft the IsNullOrEmpty method will return false.
Unfortunately, this is not a good result for us.

In order to fix this in our projects, we added this small method:
public static bool IsNullOrEmpty(this String val)
{
    return val == null || val.trim() == String.Empty;
}

This will resolve our problem.
So now we can use:
bool b = String.IsNullOrEmpty("  ");
And we will get true.

.Net 4 Users:
For you guys Microsoft fixed that thing in the form of
bool b = string.IsNullOrWhiteSpace("   ");
Which will return true.

Good luck
Elad Shalom,
CTO at ITweetLive.com

Get Query String

There are enormous number of ways to get a specific key value that lays in the query string.

JavaScript:
function getQueryString(key, default_)
{
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}

This means the default value of this key (in case it does not exist) will be "en".
var language = getQueryString("lng", "en");

ASP.Net:
string language = Page.Request.QueryString["lng"];

PHP: 
$var = "lng";
$language = isset($_GET[$var]) ? $_GET[$var] : "en";

Hope this was helpful and / or saved you some time,
Elad Shalom,
CTO at ITweetLive.com

JSON Object Code Example

The first example is to demonstrate the power and the accessibility JSON offers to developers.
This is a JavaScript code designed to make things easier for the -new to JSON- developer:

    function User(fName, lName, age, friends)
    {
        var UserObject = {
            FirstName: fName,
            LastName: lName,
            Age: age,
            Friends: [],
            IsUnderAge: function()
            {
                return this.Age > 21 ? true : false;
            }
        };
       
        var FriendsCounter = 0;
        for (var frnd in friends)
        {
            UserObject.Friends[FriendsCounter] = friends[frnd];
            FriendsCounter++;
        }
       
        return UserObject;
    }

This is the constructor.  Same as in every OOP language, each object needs to have constructors.

Now, lets say I let a user named Igor fill an information form containing the following fields:
  1. First Name
  2. Last Name
  3. Age
  4. Friends - each friend will have the same fields.
On the "Submit" button I have a call for a "CreateUser" function which will take the needed fields (using jQuery - but that's for another post) and send to the User constructor.

         function createUser()
        {
            var IgorsFriends = [];
            IgorsFriends[0] = new User("Uri", "GamingTech", 29, []);
            IgorsFriends[1] = new User("Sergey", "
GamingTech", 35, [
                new User("Noam", "
GamingTech", 27, [])
            ]);
           
            var Igor = new User("Igor", "
GamingTech", 33, IgorsFriends);
        }


The outcome of this function will be a varaible named Igor which will have the following attributes:
  1. First Name
  2. Last Name
  3. Age
The following methods:
  1. IsUnderAge
And the following Arrays:
  1. Friends - which will contain list of friends as User objects. 

Good luck,
Elad Shalom,
CTO at ITweetLive.com

Quick JSON Tutorial

JSON.

In my first 2-3 year as developer I defined myself as a "Control Developer". The definition for Control Developer is a very simple one. 
A developer who believes that anything and everything can be created using Ctrl + C and Ctrl + v (meaning copy and paste).

This approach was working great as long as I didn't need to create brand new solutions for brand new features with brand new problems.

As I was saying,
About 15 months ago when I was working in my old company (FixYa) I was asked by my team leader to pass a JSON object to the server and to expect to get a different JSON object back.

As a young proud developer the first thing I said was - “sure.  No problem".  And then the problem started.
I couldn't find any good quick tutorial for JSON. What I needed was how to write a JSON object easily, not a full explanation of the JSON parser.

Now, 15 months later I'm proud to present what I was looking for then - a very quick and usable tutorial for JSON:

JSON - JavaScript Object Notation.

The data types a JSON object can contain are:
* Number.
* String.
* Boolean.
* Array.
* Another JSON Object.
* Functions.
* Null.

Here I'm about to slowly fill a JSON object called: User.

var User = {};

This is the definition of User object.
I can write also this:

User.Age = 15;
User.Name = "Igor";
User.IsUnderAge = true;

of course, a better way would be:
var User = {
                Age: 15,
                Name: "Igor",
                IsUnderAge: true
};

As I mentioned earlier, you can also insert arrays inside the JSON object:

var User = {
                Friends: [
                                "Sergey",
                                "Uri",
                                "Noam"
                ]
};

If you wanted to make things more complicated you would make each friend as a User object:

var User = {
                Name: "Igor",
                Age: 15,
                Friends: [
                                {Name: "Sergey", Age: 15},
                                {Name: "Uri", Age: 15},
                                {Name: "Noam", Age: 15}
                ],
                IsUnderAge: function() {
                                return this.Age > 21 ? true : false;
                }
};

Now you have Igor as a very detailed and easy to read user object.


In order to understand how to make "User" a generic system object, read "JSON Midsection".
You  can also view my post called "JSON Object Code Example" for a clean code example.

Good luck,
Elad,
Lead Developer at Sports Betting Tech.

IE CSS Hacks

Internet Explorer.

It doesn't matter if it's IE 6, IE 7 or IE 8, they all suck.
Even though IE 8 has made some progress concerning CSS issue, IE 7 and obviously IE 6 are the worst browsers.

With CSS compatibility issues from here to Bill's office it takes too much work to make one CSS file fit all. That's why I thought of a small hack that I make in every HTML / XSLT / ASPX document I'm working with.

at the body tag of each page I insert a small html if:

<!--[if IE 6]>
<body class="ie6">
<![endif]-->

<!--[if IE 7]>
<body class="ie7">
<![endif]-->

<!--[if IE 8]>
<body class="ie8">
<![endif]-->

After placing that, you can easily create inside your general CSS file an inherited styling such as:
body
    { margin: 0 0 0 0; }
body.ie6
    { margin: 0 5px 0 0; }
body.ie7
    { margin: 0 0 5px 0; }
body.ie8
    { margin: 0 0 0 5px; }


This is the easiest way for me to work with IE 6 and IE 7 (and sometimes IE 8).  There is another way to make style compatible with IE browsers which involves creating different CSS file for every IE:


<link rel="stylesheet" type="text/css" href="general.css" />

<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="generalIE6.css" />
<![endif]-->

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="generalIE7.css" />
<![endif]-->

<!--[if IE 8]>
    <link rel="stylesheet" type="text/css" href="generalIE8.css" />
<![endif]-->


Good luck, and hopefully we won’t need any CSS hacks for Internet Explorer 9,
Elad Shalom,
CTO at ITweetLive.com

IE Blocking IFrame Cookies

Microsoft.
A company wishes to set development standards.
A company you must know how to work with.
A company we all hate to love.

A little story, if I may.
I work in a company that supply sports betting solutions for online gaming web sites.  About 2 months ago we got a new client with a slightly weird request - The solution should be placed in an existing site's IFrame.

The minute I heard that request I thought to myself that the amount of problems we'll encounter will give us tremendous amount of work.  But as always - The client's always right.

Three weeks ago we were almost ready for beta when our QA discovered some small issues regarding user preferences: Odds, Time Zone and Languages are not displayed correctly only on IE 7 and IE 8.

After wishing some bad things to happen to Bill, my next action was to open the HttpWatch tool IE has and locating where the cookies are being set.  I saw that whenever the cookies are set as Session Cookie i all work as it should, the problem then lays with cookies that have expiration date.

Since I was responsible for deploying 3 white labels (each project is called white label) this whole process took me about 2 weeks!

So, after writing some angry emails to Microsoft (but not sending them) I started looking for someone's solution to that problem.  And that it was when I encountered a very small and cute article talking about P3P or as you might know it: "Platform for Privacy Preferences (P3P) Project".

In short, unless you have some identifier in the page's header - IE wont except you third-party cookie.  So you need to set the P3P header in every page you wish the cookie to appear.

I took the time to write the header addition in some languages / platforms:

PHP:
   header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

ASP.Net:
   HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

Django:
   response = render_to_response('mytemplate.html')
    response["P3P"] = 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'

JSP:
   response.addHeader("P3P","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"")


If you want to read more about these boring technical stuff (and I know you do) you can enter Platform for Privacy Preferences (P3P) Project.
Good luck,
Elad Shalom,
CTO at ITweetLive.com