Tuesday, November 20, 2012

Javascript to detect Arabic characters

http://stackoverflow.com/questions/4446244/how-to-check-if-any-arabic-character-exists-in-the-string-javascript
(Other related links are in Diigo)

function hasArabic(character)
{
var arabic = /[\u0600-\u06FF]/; // http://stackoverflow.com/questions/4446244/how-to-check-if-any-arabic-character-exists-in-the-string-javascript
return (arabic.test(character));
}

function hasEnglish(s)
{
var english = /[a-zA-Z]/;
return english.test(s);
}

function hasNumbers(s)
{
var numbers = /[0-9]/;
return numbers.test(s);
}

Sunday, November 4, 2012

Important difference between 'function statements' and 'function expressions' in Javascript

EXAMPLE 1 - select the "RESULT" tab to execute the code
When the below code runs, "Yes" is printed, but not "No".
The reason is - before the code runs, "function statements" are interpreted and added to the execution stack/context, but the same is not done for "function expressions"
(Book - JavaScript Succinctly, Pg 102)

Therefore, the order in which functions are invoked & defined, becomes important when using "function expressions"
(Have to read more about this)


EXAMPLE  2 - using jQuery - $(document).ready()
Click on "RESULT" to see the result

Saturday, November 3, 2012

To enable .Net 3.5, 3.0,2.5 in Windows 8

http://helpdeskgeek.com/windows-8/install-net-framework-3-5-3-0-2-0-on-windows-8/

Excerpt:

"With Windows 8, .NET Framework 4.5 comes installed by default. Since .NET 4.5 is an in-place upgrade of 4.0, you can automatically run any applications that are geared towards .NET Framework 4.5 or 4.0. That’s fine, but what if you need to run programs that require older versions of .NET Framework? What’s the lowest version you can run?

In Windows 8, .NET 3.5, 3.0 and 2.5 come with the OS, you just have to enable it. This is really nice because you don’t have to go and download .NET 3.5 from the Microsoft website. In this post, I’ll show you how to enable the older versions of the .NET Framework in Windows 8......."

Facebook - developer links

Sunday, October 28, 2012

Saturday, October 27, 2012

Windows 8 App Framework diagram

This image is from Pluralsight's course - Introduction to Building Windows 8 Applications

Thursday, October 25, 2012

Native apps, Mobile Web apps, Hybrid apps


  • From http://icenium.com/community/blog/icenium-team-blog/2012/06/14/what-is-a-hybrid-mobile-app-
  • Native apps are built for a specific platform with the platform SDK, tools and languages, typically provided by the platform vendor (e.g. xCode/Objective-C for iOS, Eclipse/Java for Android, Visual Studio/C# for Windows Phone).
  • Mobile Web apps are server-side apps, built with any server-side technology (PHP, Node.js, ASP.NET) that render HTML that has been styled so that it renders well on a device form factor.
  • Hybrid apps, like native apps, run on the device, and are written with web technologies (HTML5, CSS and JavaScript). Hybrid apps run inside a native container, and leverage the device’s browser engine (but not the browser) to render the HTML and process the JavaScript locally. A web-to-native abstraction layer enables access to device capabilities that are not accessible in Mobile Web applications, such as the accelerometer, camera and local storage.

Sunday, September 30, 2012

Standup meetings, Asking, Mistakes - different opionion from Mike Hill

By "lose the 3 questions" - he is asking us to do away with the 3 questions - 'what did i do yesterday, what i am planning to do today, any blocking issues'

By "do not solve anything" - he says "we do not solve problems in standups, we raise them"

And he also mentions that the last 2 points - - "make asking a safe thing to do" , "make mistaking a safe thing to do",
which he calls "values", are "really critical". He says "we dont want our team not to make mistakes... we want to our team to make mistakes and repair them, in good cheer..." and adds "we want things to be pretty safe inside the team"

Full link to his talk - http://www.infoq.com/presentations/Individual-Coach

Tuesday, September 18, 2012

Referencing github from jsfiddle

From http://stackoverflow.com/questions/9841026/reference-github-file-in-jsfiddle :


-- And yes, it is, just get the raw copy. Take the URL (https://github.com/minitech/Sprint2/blob/master/sprint.js), addraw. before github, and remove the blob/ part:
https://raw.github.com/minitech/Sprint2/master/sprint.js
-- You can also just replace /blob/ with /raw/ and Github will 301 you to the correct url.

Sunday, September 9, 2012

Dialectic vs Debate

From http://en.wikipedia.org/wiki/Dialectic:
Dialectic (also dialectics and the dialectical method) is a method of argument for resolving disagreement that has been central to Indian and European philosophy since antiquity. The word dialectic originated in ancient Greece, and was made popular by Plato in the Socratic dialogues. The dialectical method is dialogue between two or more people holding different points of view about a subject, who wish to establish the truth of the matter by dialogue, with reasoned arguments.[1] Dialectics is different from debate, wherein the debaters are committed to their points of view, and mean to win the debate, either by persuading the opponent, proving their argument correct, or proving the opponent's argument incorrect – thus, either a judge or a jury must decide who wins the debate. Dialectics is also different from rhetoric, wherein the speaker uses logos, pathos, or ethos to persuade listeners to take their side of the argument.

Friday, September 7, 2012

Recursive lambda expression

void Main()
{
///////////////////////////////////////////////
// BOOK - C# Unleashed 4.0
// Chapter, Page - Chap 18 Events, Pg 859-861

/*
///////////////////////////////////////////////
// PROBLEM - recursive lambda expression
//
Func fac2 = n => n == 0 ? 1 : n * fac2(n - 1); // will not work
fac2(5).Dump();
*/

///////////////////////////////////////////////
// SOLUTION - initialize the lambda expression variable to null before assigning it the actual lambda expression
//
Func fac = null;
fac = n => n == 0 ? 1 : n * fac(n - 1); // will work
Console.WriteLine(fac(5));
}





Action finishedHandler = () => {
Console.Beep();
// Finished has been called: we can unhook both Tick and Finished now.
countDown.Tick -= tickHandler;
countDown.Finished -= finishedHandler;
};

Action finishedHandler; // this variable is unassigned!
Action __temp = () => {
Console.Beep();
// Finished has been called: we can unhook both Tick and Finished now.
countDown.Tick -= tickHandler;
countDown.Finished -= finishedHandler;
};

Monday, September 3, 2012

LINQPad - Adding references

To get access to HttpUtility -
From http://stackoverflow.com/questions/5015363/linqpad-4-doesnt-know-about-httputililty-how-to-resolve

1. You need to a reference System.Web.dll. Press F4 (References) and add a reference to that DLL.
2. Or, if you have an autocompletion license, just type your original query: HttpUtility.UrlPathEncode("Make sure"); and open the smart-tag that automatically appears. It will present a menu option to add the reference to System.Web.dll and import the System.Web namespace in a one-fell-click!

Friday, July 20, 2012

Taskkill

Taskkill /F /IM notepad.exe
/F => Forcefully terminate
/IM => image name of process e.g. notepad.exe, note*.exe (i.e. Wildcard '*' is supported)

Taskkill /?

Thursday, July 5, 2012

Fixed table header -using HTML and CSS only

From - http://www.scientificpsychic.com/blogentries/html-and-css-scrolling-table-with-fixed-heading.html

Excerpt from above (with some added formatting) -
It is possible to have a table with a scrolling body and fixed header with only HTML and CSS.

The solution is to use 3 tables.
    • An outer table consists of 2 rows
    • The top row contains a table for the heading and the bottom row contains a <div> containing the table for the scrollable body. 
    • The outer table and the <div> container have to be 25 pixels wider than the tables for the heading and the body to allow room for the vertical scroll bar. The column widths of the tables are defined through CSS.
Click on HTML tab and Result tab

Monday, May 28, 2012

javascript console - To get value of an element from an iframe

var d = ($$('iframe')[0]).contentDocument; d.getElementsByName('ID')[0]

Saturday, May 26, 2012

Title: Become a Javascript Console Power-User



To be able to access, from Console, elements in an iframe:
1. get id of iframe -  

2. use the cd() command -

Wednesday, May 16, 2012

DateTime.Now.CompareTo() method

var dt1 = DateTime.Now; while (DateTime.Now.CompareTo(dt1.AddSeconds(10)) <= 0) { }

Tuesday, May 15, 2012

Store Form Values bookmarklet

Drag & Drop the following bookmarklets to 'store' and 'load' a form's values.
Form Values - Store
Form Values - Load

Monday, March 19, 2012

Search stored procedure's text

http://blog.sqlauthority.com/2007/09/03/sql-server-2005-search-stored-procedure-code-search-stored-procedure-text/

USE AdventureWorks
GO

--Searching for Empoloyee table
SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Employee%'
GO
--Searching for Empoloyee table and RateChangeDate column together
SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%Employee%'AND   OBJECT_DEFINITION(OBJECT_ID) LIKE '%RateChangeDate%'
GO 

Wednesday, February 29, 2012

Display all "display:none" elements

$("*").filter(function() { return $(this).css("display") == "none" }).css("display","")

Sunday, February 19, 2012

HTTP Caching 101, Sebastien Lambla

HTTP Caching 101, Sebastien Lambla (@serialseb) of CodeBetter.com


http://vimeo.com/36409207


Sunday, February 12, 2012

More examples using Correlated Subquery

More examples using Correlated Subquery-

In my opinion, although Method 1 has the extra select statement at the top, it conveys the logic of the query better than Method 2.

In Method 2, we basically have pushed the 'join' statement inside the outer query.


Method 1:



SELECT 
A.*, Challenge.* 
FROM 
(SELECT CE1.Challenge_ID,Question1,Question2,Question3,Question4,Question5,Question6
FROM Challenge_Enter as CE1
WHERE CE1.ID = 
(SELECT max(CE2.ID) 
From Challenge_Enter as CE2
WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0)
) A
INNER JOIN 
Challenge 
on A.Challenge_ID = Challenge.ID



Method 2:



SELECT Challenge.*,CE1.Challenge_ID,Question1,Question2,Question3,Question4,Question5, Question6
FROM Challenge_Enter as CE1
INNER JOIN Challenge on CE1.Challenge_ID = Challenge.ID 
WHERE CE1.ID = 
(SELECT max(CE2.ID) 
From Challenge_Enter as CE2
WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0)

Correlated Subquery, Common Table Expression example


Here are 3 different ways to write the same query.



The difference between using Self-Join method, CTE method, and Correlated Subquery method --> in Correlated Subquery method, I could use the ID column (which is the primary key column); but we cannot use ID in Group By (since it will be unique for each row), so we cannot use it in the Self-Join & CTE methods 
Hence, while writing Correlated Subqueries, we 'probably' have to focus on this --> returning the Primary Key of the outer query's table from the subquery
(This has to be verified by looking at examples)

From the table Challenge_Enter,
find out all the details of the latest Challenge to which the Customer 1123607 has entered into.

Self-Join
---------
SELECT
xx.*, Question1, Question2, Question3, Question4, Question5, Question6
FROM
Challenge_Enter yy
INNER JOIN
(SELECT
CustomerID, Challenge_Id, max(EnterDate) AS EnterDate
FROM
Challenge_Enter
WHERE
customerid = 1123607 AND Challenge_ID > 0
GROUP BY
Challenge_Id, CustomerID
) xx
ON yy.Challenge_ID = xx.Challenge_ID
WHERE
yy.EnterDate = xx.EnterDate

Common Table Expression
-----------------------
WITH
max_entries (Challenge_ID, maxEnterDate) As
(
SELECT
Challenge_id, max(EnterDate) maxEnterDate
from
Challenge_Enter
where CustomerID = 1123607 AND Challenge_ID > 0
group BY
Challenge_ID
)
SELECT
*
FROM
max_entries
INNER JOIN
Challenge_Enter
ON
max_entries.Challenge_ID = Challenge_Enter.Challenge_ID AND
max_entries.maxEnterDate = Challenge_Enter.EnterDate


Correlated Subquery
-------------------
SELECT
Challenge_ID,Question1,Question2,Question3,Question4,Question5,Question6
FROM
Challenge_Enter as CE1
WHERE
ID = (SELECT max(CE2.ID) From Challenge_Enter as CE2 WHERE CE2.CustomerID = 1123607 AND CE2.Challenge_ID = CE1.Challenge_ID AND Challenge_ID > 0 )

Followers

Blog Archive