Share a clipboard across all your devices in one network (copy/paste)

IPShare.netHow many times you wanted to copy a message/phone/email from one device to another on your local network and in order to do it you had to share a notepad file or sent an email to yourself or logged in your google account to create a note etc. Since this had happend to me quite a loot latelly I decided to do something about it and create a siple web application to perform this task.

All you have to do is open a web browser and type www.ipshare.net. No logins, signup or anything is required! Just like that you have a textbox that is shared accross all your local devices in your network. All you need is an active internet connection and you are good to go!

Next time you want to share something just give it a try. You’ll love it.

Check replication synchronization status using Transactional SQL (TSQL)

Below you will find a select that will help you check the state of all your publication on SQL server in order to know if all the subscribers are in synch or the syncronization agent has stopped running.

SELECT
(CASE
    WHEN mdh.runstatus =  '1' THEN 'Start - '+cast(mdh.runstatus as varchar)
    WHEN mdh.runstatus =  '2' THEN 'Succeed - '+cast(mdh.runstatus as varchar)
    WHEN mdh.runstatus =  '3' THEN 'InProgress - '+cast(mdh.runstatus as varchar)
    WHEN mdh.runstatus =  '4' THEN 'Idle - '+cast(mdh.runstatus as varchar)
    WHEN mdh.runstatus =  '5' THEN 'Retry - '+cast(mdh.runstatus as varchar)
    WHEN mdh.runstatus =  '6' THEN 'Fail - '+cast(mdh.runstatus as varchar)
    ELSE CAST(mdh.runstatus AS VARCHAR)
END) [Run Status],
mda.subscriber_db [Subscriber DB],
mda.publication [PUB Name],
right(left(mda.name,LEN(mda.name)-(len(mda.id)+1)), LEN(left(mda.name,LEN(mda.name)-(len(mda.id)+1)))-(10+len(mda.publisher_db)+(case when mda.publisher_db='ALL' then 1 else LEN(mda.publication)+2 end))) [SUBSCRIBER],
CONVERT(VARCHAR(25),mdh.[time]) [LastSynchronized],
und.UndelivCmdsInDistDB [UndistCom],
mdh.comments [Comments],
'select * from distribution.dbo.msrepl_errors (nolock) where id = ' + CAST(mdh.error_id AS VARCHAR(8)) [Query More Info],
mdh.xact_seqno [SEQ_NO],
(CASE
    WHEN mda.subscription_type =  '0' THEN 'Push'
    WHEN mda.subscription_type =  '1' THEN 'Pull'
    WHEN mda.subscription_type =  '2' THEN 'Anonymous'
    ELSE CAST(mda.subscription_type AS VARCHAR)
END) [SUB Type],

mda.publisher_db+' - '+CAST(mda.publisher_database_id as varchar) [Publisher DB],
mda.name [Pub - DB - Publication - SUB - AgentID]
FROM distribution.dbo.MSdistribution_agents mda
LEFT JOIN distribution.dbo.MSdistribution_history mdh ON mdh.agent_id = mda.id
JOIN
    (SELECT s.agent_id, MaxAgentValue.[time], SUM(CASE WHEN xact_seqno > MaxAgentValue.maxseq THEN 1 ELSE 0 END) AS UndelivCmdsInDistDB
    FROM distribution.dbo.MSrepl_commands t (NOLOCK)
    JOIN distribution.dbo.MSsubscriptions AS s (NOLOCK) ON (t.article_id = s.article_id AND t.publisher_database_id=s.publisher_database_id )
    JOIN
        (SELECT hist.agent_id, MAX(hist.[time]) AS [time], h.maxseq
        FROM distribution.dbo.MSdistribution_history hist (NOLOCK)
        JOIN (SELECT agent_id,ISNULL(MAX(xact_seqno),0x0) AS maxseq
        FROM distribution.dbo.MSdistribution_history (NOLOCK)
        GROUP BY agent_id) AS h
        ON (hist.agent_id=h.agent_id AND h.maxseq=hist.xact_seqno)
        GROUP BY hist.agent_id, h.maxseq
        ) AS MaxAgentValue
    ON MaxAgentValue.agent_id = s.agent_id
    GROUP BY s.agent_id, MaxAgentValue.[time]
    ) und
ON mda.id = und.agent_id AND und.[time] = mdh.[time]
where mda.subscriber_db<>'virtual' -- created when your publication has the immediate_sync property set to true. This property dictates whether snapshot is available all the time for new subscriptions to be initialized. This affects the cleanup behavior of transactional replication. If this property is set to true, the transactions will be retained for max retention period instead of it getting cleaned up as soon as all the subscriptions got the change.
--and mdh.runstatus='6' --Fail
--and mdh.runstatus<>'2' --Succeed
order by mdh.[time]

Change the SQL Server Name after Changing the Computer Name

Recently I changed the name of my SQL Server computer from the generic one given by the Windows installation to ‘SERVER’. In the beggining there was no apparent problem in the connections since I used IP addresses. After a while I wanted to use Replication and tried to create an SQL Server Publication only to find that the name of the SQL SERVER has not changed and I could not create a publication unless I connected with the correct computer name. It turns out that changing the computer name does not update the sql server name and you need to change it manually in order to be able to use replication or any other Sql Server feature that requires you to connect using the computer name!

Below is a simple code that you can use to change the name of the SQL Server.

sp_dropserver @@SERVERNAME
GO
sp_addserver 'newServerName', local
GO

You need to restart the SQL Server in order for the changes to take effect.

Umbraco IP2Location Integration Package

IP to Location Integration PackageRecently I found a package that would help people that want to separate content of their site depending on the geografical location. It will allow you to distinguise your visitors location and therefore the content they will see.

It can be user to differentiate or hide content depending on the users location.Let’s for example say that you have an eshop and want to promote different products to different countries this package will allow you to filter your products by country.

An IP2Location database is required for this package to function properly which can be found on any of the sites below:

A Database with a table filled using any of the geolocation database above is required!

There is a trial mode that can be used on by having a sub-domain starting with development, dev, stage, test or demo.

You can download the package and see more details here.

Win a lifetime Dropbox Pro account for life ($99/year)

I believe you all know dropbox and most of you i’m sure are using it as a free account.
Now there is a chance to win a Pro subscription for life!!! All you have to do is enter your email at the contest below…

http://appsumo.com/ (Expires 10/13/2011)

Good luck to you all…

Umbraco Fix – Content tree not loaded on very large sites

Recently one of my sites that was created using umbraco has started to behave somewhat strange. There was nothing that seem to be wrong and all the errors produced were:
 No Document exists with Version ’00000000-0000-0000-0000-000000000000′

As it turned out the problem was due to extreme delay in the SQL Server. What made me look  into that was that the tree in the content area of the backend was not loading for the folder with all the articles in it.

Also it seemed that the problem might have originated because I also use DateFolders extention. Adding the index below dramatically increased the speed of the sql that runs to generate the content trees (from 32sec to less that 2sec for more than 7000 records) and it seems to resolved all my other problems as well.

/****** Object:  Index [IDX_cmsDocument_nodeId_versionId]    Script Date: 09/20/2011 13:13:20 ******/
CREATE NONCLUSTERED INDEX [IDX_cmsDocument_nodeId_versionId] ON [cmsDocument]
(
	[nodeId] ASC,
	[versionId] ASC
)
INCLUDE ( [published]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
S3GCC5KF6B2M

Alter Schema Owner at Tables, Views and Stored Procedures

Here is a quick and easy way to alter the schema of any of the objects in your sql server that has been created with any other user than the dbo. This has been giving me troubles when using TSQL and has been difficult to change it using the sql managment studio.

SELECT 'ALTER SCHEMA dbo TRANSFER ' + SCHEMA_NAME(schema_id) + '.' + name
FROM sys.tables
WHERE schema_id != SCHEMA_ID('dbo');

Umbraco Fix – No Document exists with Version

Recently I had problems with a site I have created using umbraco. The problem was that for some reason in the version control of the application there were many orphan versions that where visible on the cmsContentVersion table but not on the cmsDocument. You can find those using the query below:

SELECT * FROM cmsContentVersion
WHERE
	cmsContentVersion.VersionId NOT IN (SELECT VersionId FROM cmsDocument) AND
	cmsContentVersion.ContentId IN (SELECT nodeId FROM cmsDocument)

Deleting those record fixed my problem and the problematic nodes where shown again in both the content tree view and edit view in umbraco CMS. To delete those versions in your database use the code below:

DELETE FROM cmsContentVersion
WHERE
	cmsContentVersion.VersionId NOT IN (SELECT VersionId FROM cmsDocument) AND
	cmsContentVersion.ContentId IN (SELECT nodeId FROM cmsDocument)

XSLTSearch extension error when saving XSLT file in Umbraco 4.6 beta

If you have problems when using XSLTsearch extension for umbraco on version 4.6 installation the easiest way to resolve it is to simply complile the .cs file to a .dll using Visual Studio and then declare it as an xslt extension using the line below:

<ext assembly="XSLTsearch" type="PS.XSLTsearch" alias="PS.XSLTsearch" />

To make this even easier for you here is the .dll you need.

Convert a comma separated nvarchar to a list that can be used in any T-SQL

Many times in many projects I had to filter some records in a list by selecting not one but multiple categories. This has been a nightmare to be done in a stored procedure since you had to have a limited numbers of parameters and it would be inefficient to have @category1, @category2, etc. What you wanted to do is have one value that you would name @categories and then pass there any number of values separated by a character.

Now this can be achieved by using an intermediate stored procedute that converts a string delimited by a char to a table list of values. This stored procedure is the following:

CREATE FUNCTION dbo.spListToTable
(
	@List VARCHAR(MAX),
	@Delim CHAR
) RETURNS @ParsedList TABLE ( item VARCHAR(MAX) )
AS
BEGIN
	DECLARE @item VARCHAR(MAX), @Pos INT

	SET @List = LTRIM(RTRIM(@List))+ @Delim
	SET @Pos = CHARINDEX(@Delim, @List, 1)

	WHILE @Pos > 0
	BEGIN
		SET @item = LTRIM(RTRIM(LEFT(@List, @Pos - 1)))
		IF @item <> ''
		BEGIN
			INSERT INTO @ParsedList (item)
			VALUES (CAST(@item AS VARCHAR(MAX)))
		END

		SET @List = RIGHT(@List, LEN(@List) - @Pos)
		SET @Pos = CHARINDEX(@Delim, @List, 1)
	END
	RETURN
END
GO

Then in an example as the one described above you would use it like this :

SELECT *
FROM [tblList]
WHERE [categoryID] IN (
	SELECT [item] FROM dbo.spListToTable('1,2,3',',')
)

That would return you all the items that are in categories 1,2,3 !