Spot the web RSS 2.0
# Sunday, February 17, 2008

Six months after Facebook came out with a version of its social network for the iPhone, LinkedIn is finally coming around to releasing a mobile version of its own.

It is live now. Just go to http://m.linkedin.com/ on any mobile browser. Of course, if you have an iPhone, you will see a version optimized just for that device.

This isn’t exactly what we had in mind when we noted there is still an opportunity to create a kick-ass mobile social network.

 linkedin-iphone-small-1.png

But the basic functionality is all there. You can look up people’’s profiles, invite people into your network, and see updates from your contacts. More fully-featured, downloadable mobile apps geared to specific phones may be coming in the future.

Even limited mobile browser accessibility should help LinkedIn keep its members happy. The regular Website has been on a tear lately, nearly tripling in unique visitors over the past year in the U.S., to 3.6 million in January 2008, according to comScore.

No signs of social networking fatigue there.

linkedin-chart.png

Sunday, February 17, 2008 5:37:15 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
Site Reviews | Web 2.0
# Wednesday, February 13, 2008

You see it in Google search results and a lot of other sites that have good search functionality. When you perform a search, your words or phrases are highlighted in the search results making it easy for you to find the most relevant content.

Today I’m going to show you a simple way to add this to your website or blog so your users can find what they need in style. I think that this kind of thing should be implemented more often for how easy it is to implement.

Here we go!

The JavaScript code:

  1. function highlightOnLoad() {  
  2.   // Get search string  
  3.   if (/s\=/.test(window.location.search)) {  
  4.     var searchString = getSearchString();  
  5.     // Starting node, parent to all nodes you want to search  
  6.     var textContainerNode = document.getElementById("content");  
  7.     // The regex is the secret, it prevents text within tag declarations to be affected

  8.     var regex = new RegExp(">([^<]*)?("+searchString+")([^>]*)?<","ig");  
  9.     highlightTextNodes(textContainerNode, regex);  
  10.   }  
  11. }  
  12. // Pull the search string out of the URL  
  13. function getSearchString() {  
  14.   // Return sanitized search string if it exists  
  15.   var rawSearchString = window.location.search.replace(/[a-zA-Z0-9\?\&\=\%\#]+s\=(\w+)(\&.*)?/,"$1");  
  16.   // Replace '+' with '|' for regex  
  17.   return rawSearchString.replace(/\+/g,"\|");  
  18. }  
  19. function highlightTextNodes(element, regex) {  
  20.   var tempinnerHTML = element.innerHTML;  
  21.   // Do regex replace  
  22.   element.innerHTML = tempinnerHTML.replace(regex,">$1<span class='highlighted'>$2</span>$3<");  
  23. }  
  24. // Call this onload, I recommend using the function defined 
    // at: http://untruths.org/technology/javascript-windowonload/  

  25. addOnLoad(highlightOnLoad()); 

Now, the CSS:

  1. span.highlighted {  
  2.   background-color#161616;  
  3.   font-weightbold;  

Code explanation

First, the highlightOnLoad function checks window.location.search to see if we need to be running any of this stuff, then calls getSearchString to get a sanitized search string so that nothing funky can happen if, say, the user searches for ‘<script>’. You should really be sanitizing all search inputs at least on the back-end anyway.

Then, the highlightTextNodes function uses a regex replace on our textContainerNode’s innerHTML. The regex verifies that the text is between a > and a < (and not the other way around). Actually nice and simple!

Caveats

This may end up being a bit slow if you are doing this on a LOT of text, but for my blog text, it seems quite snappy to me. Also, the CSS does not bold text inside links, but the background color is there to make it obvious.

Wednesday, February 13, 2008 5:06:52 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [0] - Trackback
CSS | Javascript | Programming
# Tuesday, February 12, 2008

There are at least 5 ways to return data from one table which is not in another table. Two of these are SQL Server 2005 and greater only. This is a post mostly for beginners but hopefully everyone will get something out of it.

Here are the 5 different ways

NOT IN
NOT EXISTS
OUTER JOIN
OUTER APPLY (2005+)
EXCEPT (2005+)

Let's see how this all works
First create these two tables with the Celko approved naming convention.

 

CREATE TABLE #testnulls (ID INT)

INSERT INTO #testnulls VALUES (1)

INSERT INTO #testnulls VALUES (2)

INSERT INTO #testnulls VALUES (null)

 

CREATE TABLE #testjoin (ID INT)

INSERT INTO #testjoin VALUES (1)

INSERT INTO #testjoin VALUES (3)

NOT IN
Run the following Code

 

SELECT * FROM #testjoin WHERE ID NOT IN(SELECT ID FROM #testnulls)

What happened? Nothing gets returned! The reason is because the subquery returns a NULL and you can't compare a NULL to anything

Now run this

SELECT * FROM #testjoin

WHERE ID NOT IN(SELECT ID FROM #testnulls WHERE ID IS NOT NULL)

That worked because we eliminated the NULL values in the subquery

This also works

SELECT * FROM #testjoin j

WHERE j.ID NOT IN(SELECT ID FROM #testnulls n WHERE n.ID = j.ID)

 


NOT EXISTS
NOT EXISTS doesn't have the problem that NOT IN has. Run the following code

 

SELECT * FROM #testjoin j

WHERE NOT EXISTS (SELECT 1

FROM #testnulls n

WHERE n.ID = j.ID)

Everything worked as expected


LEFT and RIGHT JOIN
Plain vanilla LEFT and RIGHT JOINS

 

SELECT j.* FROM #testjoin j

LEFT OUTER JOIN #testnulls n ON n.ID = j.ID

WHERE n.ID IS NULL

With a RIGHT Join you just switch the tables around

SELECT j.* FROM #testnulls n

RIGHT OUTER JOIN #testjoin j ON n.ID = j.ID

WHERE n.ID IS NULL

 

And we can also do a full outer join

SELECT j.* FROM #testnulls n

FULL OUTER JOIN #testjoin j ON n.ID = j.ID

WHERE n.ID IS NULL

AND j.ID IS NOT NULL


You might wonder why we have LEFT and RIGHT Joins, here is why:
<AttemptToBeFunny>LEFT joins are for people who tend to vote for the democrats, RIGHT joins are for people who tend to vote for Republicans. FULL Joins are for independents/undecided people. </AttemptToBeFunny>

You can be real silly and do a subquery LEFT join
 

SELECT j.* FROM #testjoin j

LEFT OUTER JOIN (SELECT ID FROM #testnulls ) n ON n.ID = j.ID

WHERE n.ID IS NULL

 

Now let's talk about SQL 2005 and up

OUTER APPLY (SQL 2005 +)
OUTER APPLY is something that got added to SQL 2005

SELECT j.* FROM #testjoin j

OUTER APPLY

(SELECT id FROM #testnulls n

WHERE n.ID = j.ID) a

WHERE a.ID IS NULL

 

EXCEPT(SQL 2005 +)
EXCEPT is something that got added to SQL 2005. It basically returns everything from the top table which is not in the bottom table

 

SELECT * FROM #testjoin

EXCEPT

SELECT * FROM #testnulls


I am also mentioning INTERSECT since some people might not have seen it before. INTERSECT returns what ever is in both tables(like a regular join)

 

SELECT * FROM #testjoin

INTERSECT

SELECT * FROM #testnulls

 

So there you have it, most likely you already know all these types of joins. If you learned something from this post that is a good thing also.

Tuesday, February 12, 2008 5:05:36 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [1] - Trackback
Programming | SQL
Navigation
Archive
<February 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Guy Levin
Sign In
Statistics
Total Posts: 63
This Year: 0
This Month: 0
This Week: 0
Comments: 14
Themes
All Content © 2012, Guy Levin