I had this error on my HP Photosmart and after much fruitless searching for the answer, reinstalling drivers and tweaking settings, discovered that as of 1 September 2016, for older models, web services are no longer supported. See the following link to verify [retrieved 15/10/2019]:
https://support.hp.com/gb-en/product/hp-photosmart-wireless-e-all-in-one-printer-series-b110/4022328/model/4022329/document/c05211712/
Tuesday, 15 October 2019
Thursday, 7 March 2019
MySQL Can't create/write to file (Errcode: 13)
I wanted to export a table from MySQL to CSV format, so I wrote the following MySQL to a file:
use mydb;
select *
from mytab
into outfile '/folder/myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
I then ran the following command line:
sudo mysql -u root < myExport.sql
This generated the following error:
ERROR 1 (HY000): Can't create/write to file '/folder/myfile.csv' (Errcode: 13)
After searching for answers to no avail, I then changed the MySQL code as follows:
select *
from mytab
into outfile 'myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
use mydb;
select *
from mytab
into outfile '/folder/myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
I then ran the following command line:
sudo mysql -u root < myExport.sql
This generated the following error:
ERROR 1 (HY000): Can't create/write to file '/folder/myfile.csv' (Errcode: 13)
After searching for answers to no avail, I then changed the MySQL code as follows:
select *
from mytab
into outfile 'myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
I then re-ran the above command line command and used the following Linux command to search the entire file system for the file:
find -name myfile.csv
It found the file in /var/lib/mysql/mydb.
Monday, 30 April 2018
How to Create a Fake HttpContext to Unit Test MVC Controller
Given: I needed to unit test that a response status code had been set within a controller action.
When: I didn't particularly want to refactor due to this being existing code.
Then: After experimenting unsuccessfully with creating various HttpContext classes, I found the simplest solution to be as follows within my test method:
var request = new HttpRequest("", "http://tempuri.org/", "");
var response = new HttpResponse(TextWriter.Null);
var httpContext = new HttpContextWrapper(new HttpContext(request, response));
_myController.ControllerContext = new ControllerContext(httpContext, new RouteData(), _myController);
var result = _myController.SomeAction(...some parameters...);
Assert.AreEqual(400, response.StatusCode);
When: I didn't particularly want to refactor due to this being existing code.
Then: After experimenting unsuccessfully with creating various HttpContext classes, I found the simplest solution to be as follows within my test method:
var request = new HttpRequest("", "http://tempuri.org/", "");
var response = new HttpResponse(TextWriter.Null);
var httpContext = new HttpContextWrapper(new HttpContext(request, response));
_myController.ControllerContext = new ControllerContext(httpContext, new RouteData(), _myController);
var result = _myController.SomeAction(...some parameters...);
Assert.AreEqual(400, response.StatusCode);
Wednesday, 24 May 2017
SQL Shortcut Comparative "And" and "Or" Operator Conditions
In SQL Server Management Studio (SSMS), the following code returns "OK", suggesting that the evaluation conditions in SQL are shortcutted (ie. as soon as a condition is met, the code doesn't evaluate any subsequent conditions):
select case when 1=2 or 2=2 or 1/0 = 2 then 'ok' else 'no' end
Had all conditions been evaluated, a "divide by zero" error would have occurred.
I've not looked into whether this is standard ANSI SQL behaviour, but thought I'd share in case it is of use or interest to others.
I've not looked into whether this is standard ANSI SQL behaviour, but thought I'd share in case it is of use or interest to others.
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.
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.
Labels:
Git,
GitHub,
Troubleshooting
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
GO
SELECT NAME
FROM SYSOBJECTS
WHERE TYPE = 'P'
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'
FROM SYSOBJECTS
WHERE TYPE = 'P'
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
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
GO
SELECT NAME
FROM SYSOBJECTS
WHERE TYPE = 'P'
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'
FROM SYSOBJECTS
WHERE TYPE = 'P'
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.
I changed the dropdown to another database 'Y' and was able to re-run the query without error.
Labels:
SQL,
Troubleshooting
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.
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.
Labels:
Sitecore,
TDS,
Troubleshooting
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.
<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.
Labels:
HTML,
JavaScript,
jQuery
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" />
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" />
Labels:
.NET,
C#,
Lucene,
Sitecore,
Troubleshooting
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.
Labels:
Troubleshooting,
Visual Studio
Friday, 14 January 2011
Non white space characters cannot be added to content.
When trying to initialise an XDocument with a string containing XML, I kept getting the error:
Unhandled Exception: System.ArgumentException: Non white space characters cannot be added to content.
With help from a colleague, and recalling how I'd got around this error previously, the solution is to use the static XDocument.Parse( string ) method. Eg:
var myXDoc = XDocument.Parse( xmlString );
Unhandled Exception: System.ArgumentException: Non white space characters cannot be added to content.
With help from a colleague, and recalling how I'd got around this error previously, the solution is to use the static XDocument.Parse( string ) method. Eg:
var myXDoc = XDocument.Parse( xmlString );
Labels:
.NET,
Troubleshooting,
Xml
Wednesday, 1 December 2010
SOAP header Security was not understood
XML Web services seem to be declining in use, so finding information on this SoapHeaderException proved to be a bit difficult. I added in <soapextensionimportertypes> and installed WSE 3.0, but it made no difference. What worked for me was adding the following line to my code:
[Edit 9 Dec 2010]
Actually, this was a red herring. It worked by adding a "service reference", rather than a old-fashioned "web reference".
webService.SoapVersion =
System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
[Edit 9 Dec 2010]
Actually, this was a red herring. It worked by adding a "service reference", rather than a old-fashioned "web reference".
Labels:
ASP.NET,
Troubleshooting,
XML Web services
Wednesday, 18 August 2010
Using Sitecore with Firefox, Chrome and other browsers
Sitecore recommends the use of IE for its client. When trying to log in with Firefox or Chrome (and presumably others), you don't get the option of viewing the desktop. There is a way you can override this behaviour. Open Sitecore in IE and go to the User Manager. Select your account and click Edit to bring up the "Edit User" dialogue. Click on the Profile tab and set the start URL to "Desktop". Save your changes and then try logging in with Firefox, etc. You should now see the full desktop.
Tuesday, 15 June 2010
Sitecore link fields put /home in the target URL's href
When using sc:fld('fieldname', ., 'url') in an XSLT rendering to get a link field's target URL, you will find that the href includes '/home'. This is rarely desirable. Thankfully, it's easy to solve. Simply use sc:fld('fieldname', ., 'id') instead to get the target ID. You can then pass the ID to sc:path().
Labels:
Sitecore,
Tips,
Troubleshooting,
Xslt
Tuesday, 23 March 2010
How to remove an apostrophe from a string in Sitecore XSLT
Given a variable named "string", you can remove apostrophes by declaring a variable to hold the apostrophe and then passing that to the sc:Replace method:
<xsl:variable name="apos">'</xsl:variable>
<xsl:variable name="string"
select="sc:Replace( $input, $apos, '' )" />
Tuesday, 17 November 2009
The solution is offline because its associated Team Foundation Server is offline
When opening a solution in Visual Studio 2008, I kept getting the following message in the Output window:
I kept having to go into the "change source control" and re-bind the solution. After a while, this began to get annoying. Then I found this post: http://www.eggheadcafe.com/software/aspnet/33487526/connecting-automatically.aspx. It turned out the solution was to set some registry keys. I navigated to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers\ and changed "Offline" to 0 and "AutoReconnect" to 1. I've no idea how these got reset! (Please back-up your registry first if you want to try the same.)
This solution is offline. [Team Foundation Server:
http://server:8080/]
The solution is offline because its associated
Team Foundation Server is offline.
I kept having to go into the "change source control" and re-bind the solution. After a while, this began to get annoying. Then I found this post: http://www.eggheadcafe.com/software/aspnet/33487526/connecting-automatically.aspx. It turned out the solution was to set some registry keys. I navigated to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers\
Labels:
TFS,
Troubleshooting,
Visual Studio
Friday, 13 November 2009
System.ArgumentException: Illegal characters in path
This exception caused me a headache for an hour today on a development web site. After various rebuilds failed to cure the issue, I found out that the aspnet_wp.exe process had somehow become corrupted. Re-saves of the web.config file didn't help, so I opened Task Manager, killed the process and was back up and working again.
Labels:
ASP.NET,
Troubleshooting
Wednesday, 28 October 2009
Get a list of all Sitecore Items tagged with specific multilist items
If you wish to return all items in the content tree that have been tagged with a specific multilist item, you might be tempted to use Sitecore.Context.Database.SelectSingleItem(), passing it an XPath query. The problem with this is that performance degrades as the content tree grows. A far more efficient way is to use the GetReferrers method of the LinkDatabase class as shown below:
Database db = Sitecore.Context.ContentDatabase;
LinkDatabase linkDb = Globals.LinkDatabase;
// lookupItem is the multilist item
ItemLink[] links = linkDb.GetReferrers( lookupItem );
foreach( ItemLink link in links )
{
Item linkedItem = db.Items[link.SourceItemID];
// Process item...
}
Monday, 12 October 2009
Example Useful C# Extension Functions
Here are a few extension functions that I find useful:
The latter two functions call this method:
public static bool IsNullOrEmpty(
this string expression )
{
bool result = string.IsNullOrEmpty(
expression );
return result;
}
public static string ToFormat(
this string expression, params object[] args )
{
string result = String.Format(
expression, args );
return result;
}
public static bool IsValidEmailAddress(
this string expression )
{
bool result = BaseRegexHelper.IsValid(
expression, emailRegex );
return result;
}
public static bool IsValidGuid(
this string expression )
{
bool result = BaseRegexHelper.IsValid(
expression, guidRegex );
return result;
}
The latter two functions call this method:
public static bool IsValid(
string input, string pattern )
{
bool isValid = false;
if( input != null )
{
string trimmedExpression =
input.Trim();
if( trimmedExpression.Length > 0 )
{
Regex regexGuid = new Regex(
pattern, RegexOptions.IgnoreCase );
isValid = regexGuid.IsMatch(
trimmedExpression );
}
}
return isValid;
}
Labels:
C#
Subscribe to:
Posts (Atom)