Saturday, May 14, 2011

Sunday, May 1, 2011

Apache rewrite rule for Mobile Phones

Apache ReWrite rules can be used to route the users to the respective optimized version.

Here is my Apache rewrite rule that I use to check if its an Symbian, Android or Blackberry Phone and redirect to its optimized version. ( .htaccess file needs to be updated with the below rewrite code)

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_USER_AGENT} !android|avantgo|blackberry|blazer|compal|symbian
RewriteRule ^$ http://www.mydomain.com/desktop  [L,R]

RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|symbian
RewriteRule ^$ http://www.mydomain.com/mobile  [L]

as the url indicates that desktop link is made for the devices which are not symbian, blackberry and the mobile is made for the mentioned devices.

Tuesday, April 26, 2011

commands in ms sql

commands in ms sql
select @@version
select @@servername
select serverproperty('productversion')
serverproperty ('productlevel')
serverproperty ('edition')
select getdate() ( system date )
select getdate()-30 ( date before 30 days )
select * into [dbName].[dbo].[tableName_new] from [dbName].[dbo].[tableName_old]
sp_helpdb 'databaseName'
sp_spaceused ( with this we can check the free space in mdf or ldf file )
dbcc sqlperf(logspace) ( Amout in percent of logs used )

--User logins from cmd line disabled/enabled can be viewed from below simple views.
select * from sys.sql_logins select name,default_database_name,create_date,modify_date,is_disabled from sys.sql_logins
--Unlock User Account with password Reset
alter login rajesh with password = 'abc@123456' unlock;
--if the Account is Disabled.
alter login [rajesh] enable;
--alter login with set default database.
use [master] go
alter login [rajesh] with default_database=[testdb],
default_language=[us_english],
check_expiration=off,
check_policy=on go
--changing the owner for the db named my_db_test_10 previous owner rajesh and new is vijay
use [my_db_test_10] go
exec dbo.sp_changedbowner @loginame = n'vijay', @map = false go
--view the associated database schema's or dependency.
sp_helplogins 'rajesh'
--drop the login by name rajesh
sp_droplogin 'rajesh'