ExtJS Sencha and Phonegap

So … its the next milestone for me …Successfully completed projects in these technologies !

Vow ! loved it !

Shall post soon…. meanwhile .. any questions…. feel free to leave a comment for it !

 

Posted in ExtJs Sencha PhoenGap | Tagged , , | Leave a comment

A powerful CSS Framework – YAML

Now most of us would be very familiar with various JavaScript frameworks. jQuery , DHTMLx , ExtJS etc are some of them.

Designing a clean web app which works amazingly well in all browsers, with a clean and neat look is always what we want , for which we invest so much of time designing the layout, the column structure, the grids , the boxes , the forms etc..

How nice it would be to have a nice framework for layout design and the whole web app design ! That is where YAML comes into picture.
As per YAML :

A modular CSS framework for truly flexible, accessible and responsive websites.

YAML provides a complete set of matched building blocks to create complex websites. Grids, navigation, forms, typography module and all provided add-ons work seamlessly together.

YAML is focussed on device independent screen design and provides bullet-proof modules for flexible layouts. This is a perfect starting point and the key to truly responsive design.

I have now used YAML for 2 of my major projects, and i find is very useful. No more browser compatibility issues. Very sleek, professional look ..

Go ahead and try out and see how it would help you too ….

YAML could be found here.

Posted in General | Tagged , , | Leave a comment

My Start on ASP.NET MVC3

So finally I am taking a plunge .. from ASP.Net , Umbraco , MS CRM .. and of course my good buddies .. PHP, Smarty and Zend .. now its time for MVC3 …

So what is this MVC3 ?

As per microsoft , here goes :

ASP.NET MVC 3 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework.

Its a way of architecting your web application in a framework which has been in existence for a looong time…. something like the powerful Zend framework for PHP.

So why MVC3 by the way ???

Now that MS has come up with the same framework , in their way .. more spoon fed , more easy IDE and stuff… why not use it .. as anyway its far better method than others frameworks from Microsoft. Afrterall, you app would be more maintainable, more scalable, more robust and what not !

So a jist of the few inevitable points we need to know :

Top Features

  • Integrated Scaffolding system extensible via NuGet
  • HTML 5 enabled project templates
  • Expressive Views including the new Razor View Engine
  • Powerful hooks with Dependency Injection and Global Action Filters
  • Rich JavaScript support with unobtrusive JavaScript, jQuery Validation, and JSON binding

Get the full list as well a complete overviewΒ here.

Its going to be a great joyous ride ahead for me …

Wishing myself all the very best !πŸ™‚

Posted in .Net, General | Tagged , , | Leave a comment

Overcoming the Writer’s Block

Just read a wonderful post from Tony Davis : On the art of self promotion.

In fact what is said in the post is always something we would reflect to… totally loved the article… Have a wonderful readΒ  ….

 

Posted in General | Tagged , | Leave a comment

WordPress – Locking files for non-logged in users

Many a times… you would have set up your WordPress site with access levels, memberships … And also would have given links to certain documents on he protected pages . Of course you have restricted the pages and posts to only logged in users. But , if we copy the download link ( direct to the document or image or any media for that matter) , the resource would be shown to any user irrespective of the logged in status.

That is in fact a security issue. There areΒ  many plugins which restricts the usersΒ  … and also which restrict folders etc … but plugins cannot come into a picture like this, where in the request is to the server directly to a media resource…

Also, these documents could be crawled and shown by search engines irrespective of your user access and memberships.

The need for us to restrict files / folders within our app could be easily done using the .htaccess file.

For those who are new to .htaccess file, you could have a good understanding of the same !. Below you would find some helpful links to give you a fair idea…

1. The wiki would be anybody’s first choice

2. Apache tutorial has a good section for it.

3. A Comprehensive Guide for the same.

4. A site dedicated for .htaccess !

First type is the Basic Blocking :

Here we would restrict all requests for files of certain extensions to be blocked and shown the 403 – forbidden page message. Create a .htaccess file and have it under the root directory of WordPress.

# These next two lines will already exist in your .htaccess file
RewriteEngine On
RewriteBase /
# Add these lines right after the preceding two
RewriteCond %{REQUEST_FILENAME} ^.*(pdf|doc|docx)$
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule . - [R=403,L]

This would make sure that all files which has extensions pdf, doc and docx be blocked to users of wordpress who are not logged in. You could add as many extensions as possible.

Here , it would be nice if you would show a better message page that the Apache’s 403 page. For that , we could have a new page with a different template and then change the ‘ Rewrite Rule ‘ point to this new page.

# These next two lines will already exist in your .htaccess file
RewriteEngine On
RewriteBase /
# Add these lines right after the preceding two
RewriteCond %{REQUEST_FILENAME} ^.*(pdf|m4a|jpg|gif|jpeg|doc|docx|png)$
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule . logintoview.php [R,L]

OR WITH SLUGS extensions could be omitted…

# These next two lines will already exist in your .htaccess file
RewriteEngine On
RewriteBase /
# Add these lines right after the preceding two
RewriteCond %{REQUEST_FILENAME} ^.*(pdf|m4a|jpg|gif|jpeg|doc|docx|png)$
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule . logintoview [R,L]

Now , ALL REQUEST for pdf , doc and docx would be blocked for normal users !.. The situation would be such that your site would have several posts and [ages and several documents which are open for the public / guests ! Now in such a scenario this would not work out !

At that point , it is better to have a folder under your ‘uploads’Β  which would contain all the protected files. Now if you place the same .htaccess file under the folder which needs to be protected , then the other normal media would be untouched…

Have a great business requirement translated ! :)Β  Enjoy !

Posted in PHP | Tagged , | Leave a comment

Generate insert statements

The scripts section of SQLCentral has real wonderful scripts !πŸ˜‰ One of them is indeed so useful for our MS SQL Server … You could find many variants of the same if you google it …

but this one is really awesome i feel …

Call the stored procedure to generate insert statement for any given table.Β  Or generate inserts for all tables using something like:

exec sp_MSforeachtable @command1="exec [spd_Build_Insert_Into_Stmt_With_Identity] '?','?','[LINKEDSERVERNAME].DATABASENAME.'"

/**********************************
Originally written by:β€ˆβ€ˆβ€ˆβ€ˆJesse McLain
Updated by:β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆDarren Gordon
***********************************/

Here goes the script :

alter PROCEDURE [dbo].[spd_Build_Insert_Into_Stmt_With_Identity]
@Source_Table varchar(200),β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- req'd; the name of the source table
@Target_Table varchar(200) = '',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- req'd; the name of the target table
@FromPrefix varchar(500)='',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- String that will be added to the from statement, this lets you use linked server data sources
@Print_Truncate char(1) = 'Y',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- optional; 'Y' to print truncate statement
@Print_Identity_Insert_Stmts char(1) = 'Y',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- optional; 'Y' to include the SET IDENTITY_INSERT
-- statements in the output
@Show_Matchless_Columns char(1) = 'N',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- optional; 'Y' to include the columns from each
-- table that have no match in the other table (if
-- the tables have slightly different structures);
-- these columns will be commented-out in output
@AddGo char(1) = 'Y'β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- Add a GO to the end which will allow you to view progress when a batch is running
AS
IF @Source_Table = 'help'
BEGIN
PRINT 'PROCEDURE [dbo].[spd_Build_Insert_Into_Stmt_With_Identity]'
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆ@Source_Table varchar(200),β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- required; the name of the source table '
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆ@Target_Table varchar(200) = '''',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- required; the name of the target table '
PRINT ' @FromPrefix varchar(500)='''',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- String that will be added to the from statement, this lets you use linked server data sources '
PRINT ' @Print_Truncate char(1) = ''Y'',β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- optional; ''Y'' to print truncate statement '
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆ@Print_Identity_Insert_Stmts char(1) = ''Y'',β€ˆβ€ˆβ€ˆβ€ˆ-- optional; ''Y'' to include the SET IDENTITY_INSERT '
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- statements in the output'
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆ@Show_Matchless_Columns char(1) = ''N''β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- optional; ''Y'' to include the columns from each '
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- table that have no match in the other table (if '
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- the tables have slightly different structures);'
PRINT 'β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- these columns will be commented-out in output'
PRINT ' @AddGo char(1) = ''Y''β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- Add a GO to the end which will allow you to view progress when a batch is running'

RETURN
END

DECLARE @sql_into varchar(8000)
DECLARE @sql_from varchar(8000)
DECLARE @sql varchar(8000)

DECLARE @crlf char(2)
SET @crlf = CHAR(13) + CHAR(10)

DECLARE @indent char(1)
SET @indent = CHAR(9)

DECLARE @ColName1 varchar(250)
DECLARE @ColOrder1 smallint
DECLARE @ColType1 varchar(50)
DECLARE @ColLength1 smallint
DECLARE @ColPrec1 smallint
DECLARE @ColScale1 smallint
DECLARE @IsNullable1 tinyint
DECLARE @ColName2 varchar(250)
DECLARE @ColOrder2 smallint
DECLARE @ColType2 varchar(50)
DECLARE @ColLength2 smallint
DECLARE @ColPrec2 smallint
DECLARE @ColScale2 smallint
DECLARE @IsNullable2 tinyint
DECLARE @OrderBy decimal(9,1)

DECLARE Table_Struct_Compare_Cursor CURSOR FOR
SELECT
ColName1,
ColOrder1,
ColType1,
ColLength1,
ColPrec1,
ColScale1,
IsNullable1,
ColName2,
ColOrder2,
ColType2,
ColLength2,
ColPrec2,
ColScale2,
IsNullable2,
OrderBy = ISNULL(CONVERT(decimal(9,1), ColOrder1), CONVERT(decimal(9,1), ColOrder2) + 0.5)
FROM
(SELECT DISTINCT
ColName1 = C.Name,
ColOrder1 = C.ColOrder,
ColType1 = T1.Name,
ColLength1 = C.Length,
ColPrec1 = C.XPrec,
ColScale1 = C.XScale,
IsNullable1 = C.IsNullable
FROM SysColumns C
JOIN SysObjects O1 ON O1.Id = C.Id
JOIN SysTypes T1 ON T1.XType = C.XType
WHERE O1.Name = REPLACE(REPLACE(REPLACE(@Target_Table,'[dbo].',''),'[',''),']','') and T1.Name <> 'sysname') AS C1
FULL OUTER JOIN
(SELECT DISTINCT
ColName2 = C.Name,
ColOrder2 = C.ColOrder,
ColType2 = T2.Name,
ColLength2 = C.Length,
ColPrec2 = C.XPrec,
ColScale2 = C.XScale,
IsNullable2 = C.IsNullable
FROM SysColumns C
JOIN SysObjects O2 ON O2.Id = C.Id
JOIN SysTypes T2 ON T2.XType = C.XType
WHERE O2.Name = REPLACE(REPLACE(REPLACE(@Source_Table,'[dbo].',''),'[',''),']','') and T2.Name <> 'sysname') AS C2
ON C2.ColName2 = C1.ColName1
ORDER BY OrderBy, ColOrder1, ColOrder2

-- init vars:
SET @sql_into = 'INSERT INTO ' + @Target_Table + ' ('
SET @sql_from = 'SELECT '
SET @sql = ''

OPEN Table_Struct_Compare_Cursor

FETCH NEXT FROM Table_Struct_Compare_Cursor INTO
@ColName1,
@ColOrder1,
@ColType1,
@ColLength1,
@ColPrec1,
@ColScale1,
@IsNullable1,
@ColName2,
@ColOrder2,
@ColType2,
@ColLength2,
@ColPrec2,
@ColScale2,
@IsNullable2,
@OrderBy

WHILE @@FETCH_STATUS = 0
BEGIN
IF @ColName1 IS NULL
BEGIN
IF @Show_Matchless_Columns = 'Y'
BEGIN
--SET @sql_into = @sql_into + @crlf + '--' + @indent + ','
SET @sql_into = @sql_into + @crlf + '--' + @indent + ','
SET @sql_from = @sql_from + @crlf + '--' + @indent + '<' + @Source_Table + '.[' + @ColName2 + ']>,'
END
END
ELSE IF @ColName2 IS NULL
BEGIN
IF @Show_Matchless_Columns = 'Y'
BEGIN
SET @sql_into = @sql_into + @crlf + '--' + @indent + '<' + @Target_Table + '.[' + @ColName1 + ']>,'
--SET @sql_from = @sql_from + @crlf + '--' + @indent + 'ColName1 + '>,'
SET @sql_from = @sql_from + @crlf + '--' + @indent + 'ColName1 + ']>,'
END
END
ELSE IF @ColType1 <> @ColType2
BEGIN
SET @sql_into = @sql_into + @crlf + @indent + '[' + @ColName1 + '],'
SET @sql_from = @sql_from + @crlf + @indent + 'CONVERT(' + '[' + @ColType1 + '], [' + @ColName2 + ']),'
END
ELSE
BEGIN
SET @sql_into = @sql_into + @crlf + @indent + '[' + @ColName1 + '],'
SET @sql_from = @sql_from + @crlf + @indent + '[' + @ColName2 + '],'
END

FETCH NEXT FROM Table_Struct_Compare_Cursor INTO
@ColName1,
@ColOrder1,
@ColType1,
@ColLength1,
@ColPrec1,
@ColScale1,
@IsNullable1,
@ColName2,
@ColOrder2,
@ColType2,
@ColLength2,
@ColPrec2,
@ColScale2,
@IsNullable2,
@OrderBy
END

CLOSE Table_Struct_Compare_Cursor
DEALLOCATE Table_Struct_Compare_Cursor

SET @sql_into = LEFT(@sql_into, LEN(RTRIM(@sql_into)) - 1) + ')' + @crlfβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- remove trailing comma, add closing paren

SET @sql_from = LEFT(@sql_from, LEN(@sql_from) - 1) + @crlfβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ-- remove trailing comma
SET @sql_from = @sql_from + 'FROM ' + @FromPrefix + @Source_Table + ';'+ @crlf

PRINT 'select ''Started Populating: ' + @Target_Table + '''+ CONVERT(varchar,GETDATE(),108) ;'
IF @AddGo = 'Y'
PRINT 'GO '
IF @Print_Truncate = 'Y'
PRINT 'TRUNCATE TABLE ' + @Target_Table

--If the table does not have an identity column, then do not print the set identity_insert statement which would cause an error
if NOT exists (select 1 from sys.columns sc inner join sys.objects so on so.Object_Id = sc.Object_Id where sc.is_identity = 1 and so.Type = 'u' and so.Name = REPLACE(REPLACE(REPLACE(@Source_Table,'[dbo].',''),'[',''),']',''))
set @Print_Identity_Insert_Stmts = 'N'

IF @Print_Identity_Insert_Stmts = 'Y'
PRINT 'SET IDENTITY_INSERT ' + @Target_Table + ' ON;'
PRINT @sql_into
PRINT @sql_from
IF @Print_Identity_Insert_Stmts = 'Y'
PRINT 'SET IDENTITY_INSERT ' + @Target_Table + ' OFF;'

PRINT ''
PRINT ''

This script could always come handy in times on urgent need ! Happy coding !

Posted in Database | Tagged | Leave a comment

Visual Studio 2012

That’s great news !

The Release Candidate of Visual Studio 2012, Team Foundation Server 2012, and .NET Framework 4.5 is now available.With it, you can create Metro style apps as well as desktop, web, phone, and game-console apps !

Download the release candidate here.

This one is packed with features ! The list goes on and on …

A snapshot of the features is in the image below :

What's New in Visual Studio 2012 RC

What’s New in Visual Studio 2012 RC

To know more about the features and start exploring .. check out the MSDN here.

Happy Development !

Posted in .Net, General | Tagged , | Leave a comment