Posts

Showing posts from 2011

Text Lines Should Not Be Null Schema Compare

Text Lines Should Not Be Null Schema Compare Error in Visual Studio DACProjectSystemSetup_enu.msi For the last 30 minutes I'm getting crazy trying to understand  what the error " text lines should not be null " means, and why it happens every time I try to compare databases schema in Visual Studio 2010 Ultimate. It appears like my installation of the VS 2010 didn't execute correctly, so I have several packages missing. A small package called " DACProjectSystemSetup_enu.msi " was probably missing. After installing it, I can compare data and data schema easily :) The Package is available here . Hope it helped, Elad Shalom, CTO at ITweetLive.com

The Path is Already Mapped in Workspace

The path is already mapped in workspace error. The path x is already mapped in workspace. Error The path is already mapped in workspace.  TFS 2010 Mapping Issues. I've lately reinstalled my TFS 2010 and after do so, I encountered an extremely annoying error: "The path is already mapped in workspace". I searched for almost everywhere, I tried changing Visual studio files and nothing. It was only then I found out where was the problem - in my Team Foundation Cache. After realizing that - the rest was fairly easy. Simply go to this folder: C:\Users\ { UserName } \AppData\Local\Microsoft\Team Foundation\3.0\Cache and delete all that's in the folder. This was a rather quick solution to a problem that was keeping my mind busy :) Hope it helped, Elad Shalom, CTO at ITweetLive.com

Failed to Execute Url

Image
Failed to Execute URL Exception. Isapi Rewrite and Asp.Net 4 on IIS6. Failed to Execute URL asp.net 4 IIS 6 Windows Server 2003. Currently working in ITweetLive, I encountered what seemed to be a massive problem while trying to upgrade my website from .Net 3.5 to .Net 4. First thing first. Our website was compiled with .Net 3.5 up until couple of days ago when I wanted to start working with .Net 4.  A short conversion made by Visual Studio 2010 and then recompile.  The localhost works like a charm. Next step was to create a different application pool in IIS6 (I named it ".Net4") which will be only for the websites who have been converted to .Net 4 framework. After that it was simply assign the new application pool to the website and change its version to .Net 4, as simple as it sounds. But, and here came the real problem, when trying to reach the website's root without the "default.aspx" I encountered a "Failed to Execute URL" exception. ...

Split String in SQL Server

Split String in SQL Server. NVARCHAR and VARCHAR Split in MS SQL. For all of you there who wishes to preform a simple "split" on a varchar on nvarchar input in ms sql (sql server) this is for you: Basically, this post's gonna contain a Create Function Script which you will to execute in your server.  It will also contain the simplest way to use it. There will be more examples in a different post I'll upload soon... CREATE FUNCTION dbo.Split (     @RowData nvarchar(2000),     @SplitOn nvarchar(5) )  RETURNS @RtnValue table (     Id int identity(1,1),     Data nvarchar(100) ) AS  BEGIN     Declare @Cnt int     Set @Cnt = 1     While (Charindex(@SplitOn,@RowData)>0)     Begin         Insert Into @RtnValue (data)         Select         ...

Submit Blogger Sitemap to WebMaster Tools

Image
Submit Blogger Sitemap to Webmaster Tools. Submit Blogger Sitemap to Google Webmaster Tools. Atom.XML Error in Google Webmaster Tools. Hey there. Couple of hours ago I entered my Google Webmaster Tool account only to find out that my sitemap hasn't been indexed lately. After a click on the link, I found out that /atom.xml has an automatic redirect, which doesn't allow the webmaster tool to index it correctly. The fix is quite simple though. remove your current sitemap and replace it with this link:                     /at om. xml ?re dir ect =fa lse Also, enter this sitemao:                     /fe eds /po sts /de fau lt? =rs s     These two sitemaps will make sure your blog will be indexed correctly.   Have fun and keep up the good work, Elad Shalom, CTO at ITweetL...

Date Validation in JavaScript

Date Validation in JavaScript. Date Time Validation in JavaScript. Couple of days ago I had the need to validate an input as a Date in JavaScript.  I though for some time on the best way to do it so it would be as generic and stable as possible. After finalizing my method, I decided to add it to our jsValidation.js file as well as uploading the method to my post to help others in need... The method returns true if the date is a valid date and false if it's not. function isValidDate(d) {         if (Object.prototype.toString.call(d) !== "[object Date]")             return false;         return !isNaN(d.getTime());     } The way to use this method will be: function Demo() {         var d1 = new Date(...

Enabling JavaScript on Your Computer

Image
Enabling JavaScript on Your Computer Enabling JavaScript on Your Browser Lately I'm getting tons of questions from our Twitter users regarding a problem their having with their javascript. Basically, this problem says that they can't surf the web (mainly surf Twitter) because javascriupt is not enabled for their browser/computer. Well, I'm here to fix it: How to Enable JavaScript in IE (Internet Explorer) : Tools > Internet Explorer > Security Internet Zone Custom Level Scripting > Active Scripting > Enable How to Enable JavaScript in FF (Fire Fox) : Tools > Options Content Enable JavaScript   Hope it helped, Elad Shalom, CTO at ITweetLive.com

(new Date).zeroTime is not a function jQuery Error

Image
 "(new Date).zeroTime is not a function". jQuery DatePicker JS Error. One of my developers recently encountered a jquery issue.  He tried to use the jquery DatePicker.js and for some reason (this error) couldn't make it work. When he tried to open the DatePicker.js calendar he got the error: " (new Date).zeroTime is not a function ". This error happens because the function "zeroTime" is not being added to the data prototype.  it should be added in the date.js file, which was not updated. After updating the date.js (available here ) it all went smooth. Hope it helped, Elad Shalom, CTO at ITweetLive.com

Looping through Object's properties in C Sharp

Loop to Find All Properties Info of an Object In C Sharp.. Loop to Find All Properties Info of an Object In C#. Have you ever tried to make a dynamic test page? To build and HTML element contains all the properties of a specific .Net object? Well, I encountered this problem couple of days ago and while searching Google I barely found good matches.  So I decided that for my sake, and yours, I will simply post a short explanation about how to do it, followed by a quick and simple example of how to loop though object properties in C#. First I'll provide a short explanation about Reflection : Reflection enables you to discover an object's properties, methods, events and properties values at run-time .  Reflection can give you a full mapping of an object (well, it's public data). In order to use reflection, and to loop through the object's properties, we'll first have to import the namespace: using System.Reflection; Now, lets say I have an object called U...

JavaScript Looping Through Object Properties

Looping Through JSON Object Properties in JavaScript. My previous post contained a small piece of code explaining how to loop through object properties with the Reflection namespace in C# . In this post I'd like to explain how do loop through JavaScript object. Let's create an object in JavaScript: var myObject = {     Name: "Elad",     LastName: "Shalom",     Age: 26,     Kids: ["Daniel"] }; This object contains 4 properties: Name (string) LastName (string) Age (int) Kids (array) Now  for the loop part: function LoopThroughProperties(obj) {     for (var propName in obj)     {         alert(propName + ": " + obj[propName]);     } } The function will receive an object and loop through all of it's properties. I'd like to take 2-4 more lines to explain a bit about the for syntax I used. Those of you who write in C# / VB /...

Test Driven Development In C Sharp

Test Driven Development in C#. This is a Short Introduction for Test Driven Development in Visual Studio 2010. This tutorial will contain short and basic explanation of Test Driven Development followed by a quick walk through in Visual Studio 2010 written in C Sharp. For those of you who don't know, Test Driven Development is a different way of coding.  Some say a different way of life.  Instead of first developing your software and then test it, What Test Driven Development Methodology offers is to first test, then code. Basically it allows us to cover a variety of User Stories and Test Cases, build the tests for them and only after all is covered - start coding while testing our code every step of the way.   Some principles of Test Driven Development: Tests serve as examples of how to use a class or method. Naming. be explicit as possible so that everyone will be able to understand, rewrite and maintain your tests. There's a simple "3 A's" pattern ...

MSSQL Advanced Join Statements

Image
Advanced Join Statements in MS SQL Management Studio. There are several different Join types in here I will discuss them: Cross Join Statement Full Join Statement Joining tables is one of the most useful operations we have. Large data should be divided to several tables (see Normalization Rules) for maximum flexibility and minimum resources usage. Cross Join Statement: In the Cross Join statement, based on the two tables within the Join, a Cartesian product is created if a 'Where' statement filter the rows.  The size of the Cartesian product is based on multyplying the number of rows from the left table by the number of rows from the right one. Be careful when using the Cross Join.  it might cause more damage than good. Example:     SELECT  TOP 100 P.ProductID,         P.Name,         P.ListPrice,         P.Size,    ...

MSSQL Join Statements

Image
Join Statements in MS SQL Management Studio. There are several different Join types in here I will discuss them: Inner Join Statement Left Outer Join Statement Right Outer Join Statement Self Join Statement Joining tables is one of the most useful operations we have. Large data should be divided to several tables (see Normalization Rules) for maximum flexibility and minimum resources usage. Inner Join Statement: Inner Join is meant for combining rows between two tables, based on at least one column with the same data. Although columns with the same data are the most common way to use the Inner Join, there is also a possibility to conduct it with "greater then", "not equal" etc. Example:     SELECT TOP 10 P.ProductID,         P.Name,         P.ListPrice,         S.UnitPrice,         S. OrderQty     FROM Sales.SalesOrderDetail S  ...

Asp.Net Configuration - Open Broswer When Debug

Image
Configuring Asp.Net To Open New Browser Window When Start Debugging. Not too long ago I encountered a small problem that occurred to one of the developers in my team when he got a new computer. Previous to the new PC, whenever he clicked on "Start Debugging" (also known as F5) the solution compiled and opened a new browser window with the default page. After the new PC arrived the configurations in his Visual Studio 2010 were different. Meaning - Whenever he clicked F5, the project was compiling, but no browser windows appeared. With a short phone call I explained the steps he needs to do, but in order for it to be clear for all of us, I decided to upload it as a brief post. Right click on the project's name. Click on "Properties". A configuration manager window will open. Click on the third tab called "Web". On that tab you will have several sections, the first the is what we're interested in. on "Start Action" section (...

Configuration and Environment Variables - Visual Studio 2010

Image
How to create configuration or Environment variables in Visual Studio 2010. Environment variables are a great thing for when you publish your website to multiple places. It doesn't matter if you publish it to testing / staging / production environment or if you're publishing your site to several servers which require different methods to be called / different values assigned to parameters. Lets create a web application project (further explanations will be granted later) Open Visual Studio 2010 Create New Project -> ASP.NET Web Application As you can see, you automatically have two configuration options: Debug Release Right click on the project in the Solution Explorer . Click on Properties . Click on Build tab. Under that tab you have many configuration options (which will be discussed in another post). The field we're interested in is " Conditional compilation symbols ". While on Debug mode, we will write a variable name in t...

MSSQL Statements Syntax

Select Statement Update Statement Insert Statement Delete Statement Select Into Statement Many times I forget the exact syntax I should use whether I'm writing in MSSQL, My-SQL or Oracle.  This post is the first out of three posts designed to gather basic database statements and show a simple and clean example to them. Select Statement: Syntax 1:  SELECT column_1, column_3                      FROM Table Example: SELECT ID, Name                 FROM tbl_customers Syntax 2: SELECT * FROM Table (meaning - select all columns). Example: SELECT * FROM tbl_customers Update Statement: Syntax 1: UPDATE Table                     column_1 = 'value' Example: UPDATE tbl_customers         ...

How To Write Good Code - Diagram

Image
How To Write Good Code Funny Stuff... source . Hope you're having a good time, Elad Shalom, CTO at ITweetLive.com

IronRuby and Visual Studio 2010 - Integration

Image
IronRuby and Visual Studio 2010. The IronRuby represents another one of Microsoft's attempts to have it all under one development environment. C / C++ VB.Net / C# / F# J# Their latest integration with jQuery IronPhyton And now - IronRuby. This addition is brand new and a very cool one.  The add-on for Visual Studio 2010 is exactly for those who like Ruby and wish it to be implemented in their .Net environment when needed. This IronRuby release (1.1.1) with Visual Studio 2010 integration includes: Ruby colorized and syntax checker. Interactive loop window. Directory based projects. Templates for common Ruby applications (including Ruby on Rails 3 , Sinatra , Gems and Silverlight based browser scripting app)    Source by Christopher Bennage. Thanks, Elad Shalom, CTO at ITweetLive.com

Multiple Solutions with the Same Structure - Visual Studio 2010 How To

Duplicating Solutions in Visual Studio 2010. As you probably know, I work in a company that provides sports betting solutions for many companies.  Each company has its own GUI and sometimes different flows inside the site. This is basically not hard to manage as long as you create a proper Skeleton Solution. A Skeleton Solution is a solution contains only the most relevant files and folders.  The same classes and JavaScript files that exist in every other solution. A Skeleton Solution will contain, in most of the times, several projects. I believe you've read my article about File Sharing in VS 2010 . This article is in some way an extension of the one I just mentioned. How to Create a Skeleton Solution from an Existing Solution: It's even easier then you think. Create a folder named: "Base Solution" or "Skeleton Solution". Copy the content of your existing solution's folder. Paste the content inside your Skeleton Solution's folder. ...

Refactoring - Manage Your Code and Layers

Refactory - Design Improvement of the Existing Code. When I say Code Management most people tell me "I know exactly what I wrote... I know exactly where everything lays". Well.. This sentence usually takes me back to when I was 6 or 7 years old.  My mother used to tell me to clean and organize my room  and that's exactly what I told her...: "But mom...  I love it when my soldiers are under the carpet, my school books are in the closet, my clothes are on my library and my shoes are where my action figures were. I'm pretty sure most of you are nodding and agreeing with me. But this is wrong. Back to development then... There are several file types that should be in a unique folder (for each) in every project:    1. JavaScript    2. HTML    3. CSS JavaScript should not be inside "script" tag. CSS should not be inside "style" tag nor inside the element it's affecting. And HTML... Well... HTML should be on his own. Now I w...

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 s...

Linked Files in Visual Studio 2010

Image
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 dif...

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 expe...

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: if (ourString == null) if (ourString == "") if (ourString.trim() == "") 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. ...

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;             }         };     ...

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 J...

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...