Thursday, 19 February 2015

Permission denied when pushing to GitHub remote repository

When I tried to push code to GitHub recently, I got the following error despite running PuTTY and loading the SSH key that was associated with my GitHub account:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

It turned out that one of my settings in Git Extensions had reverted. I went into Settings, Settings, Ssh and selected the option against PuTTY. I was then able to push successfully.

Tuesday, 3 February 2015

List All Stored Procedures Within a SQL Database and Then Grant Execute on Them

It's been too long since I last blogged.

Thought I'd dust things off with this little snippet of T-SQL to list all stored procedures that exist within a specified SQL database:

USE YourDatabaseNameHere

AND LEFT(NAME,2) <> 'sp'
AND LEFT(NAME,2) <> 'dt'

This can be useful if you wish to grant execute permissions on these objects to your database login. For example, the following T-SQL will literally write out the commands you need to run in order to grant such execute permissions:

SELECT 'GRANT EXECUTE ON ' + NAME + ' TO YourDatabaseLoginNameHere'
AND LEFT(NAME,2) <> 'sp'
AND LEFT(NAME,2) <> 'dt'

You can take the output from the above, paste into a query window and run:

GRANT EXECUTE ON MyStoredProc TO YourDatabaseLoginNameHere
GRANT EXECUTE ON AnotherStoredProc TO YourDatabaseLoginNameHere
GRANT EXECUTE ON AndAnotherStoredProc TO YourDatabaseLoginNameHere

Friday, 19 July 2013

RESTORE cannot process database 'X' because it is in use by this session

When running a restore database query, I got the above error in SQL Management Studio. This was due to having the database 'X' selected in the dropdown list of databases, as suggested by the second part of the error message, which stated "It is recommended that the master database be used when performing this operation."

I changed the dropdown to another database 'Y' and was able to re-run the query without error.

Tuesday, 9 July 2013

Missing Context Menu on Item in Team Development for Sitecore (TDS)

I recently had a problem in which I tried to "get" items from Sitecore using TDS. The item I was trying to get had several immediate children; however, the get only fetched the top item. When I right-clicked it to try to delete, no context menu appeared. I checked the file system and found that the .item file did not physically exist, so I reloaded the Visual Studio solution. This removed the item from the Solution Explorer, but did not explain what had gone wrong.

I eventually discovered the issue was due to having an alias item of the same name at the same level in Sitecore. Once I'd renamed the alias, I could correctly get the item and all of its children.

Thursday, 24 May 2012

Using the jQuery Equivalent of Body OnLoad

Prior to jQuery, the way to get JavaScript to fire on loading a page was to add an onload attribute to the body HTML tag:

<body onload="mycode();">

In jQuery, this can be replaced by:

<script type="text/javascript">$(mycode);</script>

The important thing is not to include the method brackets. $(mycode()); will not work.

Wednesday, 13 July 2011

Lucene: Compression support not configured

I got this error when trying to extract Hits.Doc from Lucene:

Compression support not configured

at SupportClass.CompressionSupport.CheckCompressionSupport()
at SupportClass.CompressionSupport.Uncompress(Byte[] input)
at Lucene.Net.Index.FieldsReader.Uncompress(Byte[] input)
at Lucene.Net.Index.FieldsReader.AddField(Document doc, FieldInfo fi, Boolean binary, Boolean compressed, Boolean tokenize)
at Lucene.Net.Index.FieldsReader.Doc(Int32 n, FieldSelector fieldSelector)
at Lucene.Net.Index.SegmentReader.Document(Int32 n, FieldSelector fieldSelector)
at Lucene.Net.Index.IndexReader.Document(Int32 n)
at Lucene.Net.Search.IndexSearcher.Doc(Int32 i)
at Lucene.Net.Search.Hits.Doc(Int32 n)

The solution was to add the following missing keys into Sitecore AppSettings.config:

<add key="Lucene.Net.FSDirectory.class" value="Sitecore.Data.Indexing.FSDirectory, Sitecore.Kernel" />
<add key="Lucene.Net.CompressionLib.class" value="Sitecore.IO.Compression, Sitecore.Kernel" />

Tuesday, 17 May 2011

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

I get this error from time to time when editing plain text files in Visual Studio. I tried correcting it by going to File, Save As, Save with Encoding (in the Save dropdown). This seemed to do the trick about 50% of the time. However, it would seem this was just coincidence. Latest findings suggest it is a Firefox cache problem. I tried the same URL in another browser and it worked. Fingers crossed this is a fix.