FetchRemote function to work with git in Powershell

I have a useful method to create a remote git alias, if not exists,  and fetch data. I used it in Powershell scripts to operate with git remote branches:

function FetchRemote( $remoteAlias, $remoteRepository, $remoteBranch)
$aliasFound= & git remote | out-string -stream | select-string $remoteAlias
git remote add -f -t $remoteBranch –no-tags $remoteAlias $remoteRepository
git fetch $remoteAlias

Suggestions to improve Pocket

I am using Pocket (previously named RIL -Read It Later) and sometimes wish to suggest some improvements for them. Unfortunately they don’t want to have a forum to have such suggestions public( They had it before, but closed it- probably because they are too slow with implementing requested features).

Anyway I will post my emails and feature requests (submit here) to Pocket to increase visibility of my suggestions.

Create User Voice forum

“We monitor Feature Request submissions regularly, so you can trust that yours will be reviewed by our Product Team. ”

To trust that it’s reviewed, user should see, what he/she and other users submitted in the past, have ability to vote and comment on existing suggestings, and see will the feature be implemented and when.

Pocket archive option – keep offline version.

In iPad Pocket when I click tick for article, it moves to Archive, and local copy is not available any more.Sometimes, I’ve read the article and want to put it to archive, but wish to keep local copy for the reference.

It will be good for archive button to have an option – keep offline version.

The option will be in particular useful in case if I clicked tick accidentally.

Pocket Ability to export page/article.

On iPad I want to send some old stored article to a friend. Sometimes the original URL is not available any more. It will be good if share command allow to send the actual file rather than link.
In particular, I am interesting in sending full content to email, to iPad Evernote, and some book reader, e.g uBooks, iBooks,Kindle,KyBooks

Pocket -ability to search by tag

Currently Pocket searches for a pattern within title and URL. It wil be good also search within tags and also to allow to search specifically by tag, e.g tag:myTag.

Pocket to support simple “add URL” functionality.

When I open Pocket on iPad and the last copied to clipboard string was URL, Pocket usually suggests to add it as article. It didn’t prompt me when I wanted to add a particular URL.

I tried to find Add menu to enter/paste URL, but didn’t find it either(I believe, previously it was available). I search for support and found help page telling

The notification bar that appears when Pocket detects a copied URL will only be shown once. Therefore, if you miss it, it will not be shown again

In my case,I think, prompt wasn’t shown because the URL was already added to my list previously.

I appreciate smart logic that try to show Add only when it’s convenient to user.

However Pocket should additionally have Add button to give user control when and what he wants to add.

  An ability to search within article

When reading the article , I often need an ability to search within article.

It is a common requirement for any text reader.

Could you please add it to iOS UI? 

I am normally using not article, but web mode( if it matters).

IOS: option to open link in Safari.

When I select a link in a pocket, 3 options appears-add to pocket, open and copy. Open actually open new page in pocket. As not all pages are opened correctly in Pocket, it will be good to add an option to open link in safari.

Report article menu should ask for details

Report article menu doesn’t allow to specify what the problem is, which makes it quite useless. It should open email form, which allow user to explain the problem.

iPad pocket on slow connection opens blank page

I’ve noticed if I have low wi-fi signal, and try to open some article, blank page is opened and, it seems, app tries to load the article from Internet, even if local cache exists.i have to close the article. 

If I open the same page when wi-fi is completely off, the cached article opens instantly.

Is it a known bug? Can Pocket app have timeout check, and if page is not loaded within e.g.5sec, consider Internet is not available and use local copy instead?

Reply from Pocket:To ensure that Web Views load correctly for you, Pocket will always load the “live” version, not downloaded version, when your device is on a cellular or Wi-Fi connection. I understand this might be inconvenience when you have a low Wi-Fi signal and it’s just coming up blank.  I’ll be happy to submit your suggestion of having a way for the app to have a timeout check and revert to the cache copy. That would certainly improve what’s happening right now!

Stored pages from github have “old version of Safari” warning

Stored pages from github have  warning: “Please note that GitHub no longer supports old versions of Safari. We recommend upgrading to the latest Safari, Google Chrome, or Firefox.” The Pocket viewer should simulate the latest version to avoid such message.

Related previous posts

Pocket Favorites are not available when you off-line 

Using MSBuild Conditional Constructs to run one or other target

I was doing modification of MSBuild target https://github.com/MNF/OctoPack.Precompile/blob/master/Source/OctoPack.Precompile.targets to have different behavior depending on parameter OutDir was specified or not for Msbuild.
Follow to MSDN “MSBuild Conditional Constructs”  I selected  Choose Element and  tried to put it   inside <Target> element
 <Target Name=”foo” />

It didn’t work as for Choose Element allowed Parents are only Project, Otherwise, When.
I tried other way to include Target inside Choose/When element, but it is also not allowed, because Target also should be direct child of Project.
I found an implementation in http://stackoverflow.com/questions/30904741/msbuild-now-to-conditionally-use-one-of-two-targets-with-same-name when you set target depends on other targets and each child target has different conditions:
 <Target Name=”foo” DependsOnTargets=”_fooDebug;_fooRelease”/>
    <Target Name=”_fooDebug” Condition=”‘$(Configuration)’ == ‘Debug’ “
Later I found in  http://stackoverflow.com/questions/2284389/how-do-you-stop-msbuild-execution-without-raising-an-error/ that CallTaget elements with condition can be used as well:
 <CallTarget Targets="Exit"
Condition="Special Condition"/>
I beleive that MSDN “MSBuild Conditional Constructs” documentation should provide reference to all such options.

Gmail arbitrary rejects emails with big number of recipients

I was sending information letter to the club subscribers(total 225 emails) using Gmail account. I keep them in 3 mailing lists: 2 with 95 emails and 3rd with remaining(GMail limit recipients to 100 per email). The first list was rejected with the following (not very specific) message.
Delivery to the following recipient failed permanently: email address
Technical details of permanent failure:
Message rejected. See https://support.google.com/mail/answer/69585 for more information.
But the second list with the same size was successful.
Additional annoyance was that “delivery failed” notifications were received slowly within 5 minutes, and initially I didn’t understand which group  (or emails from both groups)  were rejected.
 The simple workaround to split big list in 3 smaller mailing lists one was successful.

TestContext.WriteLine doesn’t accept curly brackets

In test class I was using TestContext.WriteLine trying to output JSON string, I’ve got
System.FormatException : Input string was not in a correct format.
at System.Text.StringBuilder. AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestContextImplementation.WriteLine(String format, Object[] args)

Example of code that works for Debug.WriteLine, but not for TestContext.WriteLine is the following:

var msg = “{curly braces}”;

I found, that TestContext.WriteLine expects first parameter as a format string, that consider { and } as placeholder delimiters.

UPDATE: Simple workaround,  suggested in a comment by Steve Gilham


I had to write EscapeCurlyBraces extension

public static string EscapeCurlyBraces( this string message)
string ret = message.Replace( “{“, “{{” ).Replace(“}”, “}}”);
return ret;

and call
TestContext.WriteLine(msg.EscapeCurlyBraces() );
I’ve wrote a suggestion to MS Connect that it will be good to have separate overload TestContext.WriteLine(string msg); that doesn’t consider the parameter as format and doesn’t expect any additional parameters.

The file  https://github.com/MNF/CommonDotNetHelpers/blob/master/src/Strings/StringFormatExtensions.cs and corresponding unit tests https://github.com/MNF/CommonDotNetHelpers/blob/master/Tests/Strings/StringFormatExtensionsTests.cs are located on GitHub.

FromToRange generic class

Quite often you need to return from method 2 values that describe the range, e.g. From/To or Min/Max. You could use standard MS classes Pair or Tuple https://msdn.microsoft.com/en-us/library/system.tuple.aspx. However the names of properties are not describe the meaning of the values.
So I am using own class FromToRange. It is done similar to Pair(from http://blog.o-x-t.com/2007/07/16/generic-pair-net-class/)

/// similar to Pair(from http://blog.o-x-t.com/2007/07/16/generic-pair-net-class/"
///See also  DateTimeRange ( https://github.com/MNF/CommonDotNetHelpers/blob/master/src/Dates/DateTimeRange.cs)

public class FromToRange
public T From { get; set; }
public T To { get; set; }

public FromToRange()

public FromToRange(T from, T to)
this.From = from;
this.To = to;
public override string ToString()
string sRet = String.Format("From {0} to {1}", From, To);
return sRet;
public override bool Equals(object obj)
if (this == obj) return true;
FromToRange pair = obj as FromToRange;
if (pair == null) return false;
return Equals(From, pair.From) && Equals(To, pair.To);

public override int GetHashCode()
return (From != null ? From.GetHashCode() : 0) + 29 * (To != null ? To.GetHashCode() : 0);


Is it possible to determine Visual Studio edition during c# compile time

To use MS Fakes shims, I had to conditionally exclude related tests  to allow easily bypass them on Community and Professional Editions of the Visual Studio.
[ TestMethod()]
Fakes related code
I tried to find does edition automatically pre-defined by compiler, but it’s not included in Conditional Compilation Constants

Furthermore,  these constants seems defined in VB only, and not in c# and not updated since VS2008.

The reasons are discussed in “Pre-defined Constants, preprocessor directives, etc… “

The “C# Language Designers” decided to not include constants in the fashion in which C/C++ allows them.  To allow some, or even one, would open a Pandora’s Box of voices suggesting new constants to be added.

But I disagree,  because if the limitation coming from VS , it should provide a way to  determine it in pre-condition.
The related article shows how to check installed Visual Studio on run-time
Unfortunately I didn’t find, is it possible to determine Visual Studio edition  during c# compile time?

#compile-time, #constants, #visual-studio

Prevent closing PowerShell scripts running from File Explore

For PowerShell scripts to be run from File Explorer it’s important that they not closed automatically.
I am adding to those scripts
if ($host.name -eq ‘ConsoleHost’)
  Read-Host -Prompt “Press_Enter_to_continue”
Alternately, we can modify the “(Default)” values for our Command keys to include the “-NoExit” parameter.
First I decided,that it is a good idea,and added


Set-ItemProperty  HKCR:\Microsoft.PowerShellScript.1\Shell\Command ‘(Default)’  ‘”C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” “-NoExit” “-ExecutionPolicy” “RemoteSigned” “-file” “%1″‘


But then I realized, that  if PowerShell script should be shared with other users, it’s better to explicitly implement pause in a script rather then rely on registry setting on other machines.

Notes about CORS implementation in Web API. 

We’ve created CORS interface using the article
A few points,t hat I want to highlight:
  1. DisableCors doesn’t stop server to send response, it just sends response without Access-Control-Allow-Origin header.
It’s browser responsibility to check response and generate an error.
It’s important to understand that same-origin policy does not prevent the browser from sending the request. Instead, it prevents the application from seeing the response
  1. When cookies allowed to be shared between sub domains of the same domain, “same origin policy” consider sub domains as different origins.
There is no partial wild cards supported in origins, such as all sub domains *.example.com.
If the server allows the request, it sets the Access-Control-Allow-Origin header. The value of this header either matches the Origin header, or is the wildcard value “*”, meaning that any origin is allowed.
I’ve submitted enhancement suggestion to MS at https://connect.microsoft.com/VisualStudio/feedback/details/2703507/web-api-support-partial-wild-cards-in-cors-origins-field, but it can be done as custom policy implementation as it was answered at http://forums.asp.net/post/6050160.aspx
     3.  Out of the box implementation in attributes use hard coded Origins, with note in documentation:
For example, a custom CORS policy provider could read the settings from a configuration file.
MS should  supply input from configuration out of the box. One of examples provided  in MSDN blog https://blogs.msdn.microsoft.com/webdev/2013/07/02/manage-cors-policy-dynamically/.
Better implementation posted at http://jnye.co/Posts/2032/dynamic-cors-origins-from-appsettings-using-web-api-2-2-cross-origin-support
  1. If you want to share cookies, you need to enable Credentials on both client and server.
Credentials include cookies as well as HTTP authentication schemes. To send credentials with a cross-origin request, the client must set XMLHttpRequest.withCredentials to true.
    type: 'get',
    url: 'http://www.example.com/api/test',
    xhrFields: {
        withCredentials: true
[EnableCors(origins: “http://myclient.azurewebsites.net”, headers: “*”, methods: “*”, SupportsCredentials = true)]
Further reading:

How I moved my blog from GeeksWithBlogs to WordPress.

When I decided to move my blog, I didn’t expect that it will require such effort. I found a post http://geekswithblogs.net/jakob/archive/2015/12/07/this-blog-is-moving.aspx that refer to tools stored on codePlex http://gwbtowp.codeplex.com/  (now it’s moved to https://github.com/MrHinsh/gwb-to-wordpress)
I downloaded the code  and had to fix a few errors, related to my data. Also I wanted to move my articles that in GeeksWithBlogs are stored separately from normal posts.The final code changes I’ve published at github fork https://github.com/MNF/gwb-to-wordpress.
I expected that import to WordPress will be straightforward.I found a few articles about  import plugins, e.g. http://nixmash.com/on-wordpress/importing-a-big-honkin-blogml-xml-file-into-wordpress/, but then realized that custom plugins not supported in Wordpress.com.
blogmigrator has less steps to do, and I tried it first. Also I have to do some changes to improve error handling(the changes are incorporated in https://github.com/Dillie-O/blogmigrator) and finally I’ve got my blog imported. But comments were not included. I checked the code and found that comments were not supported in interface that the tool is using.
BlogML.Helper supported comments, but due to bug only one comment per post. I fixed the bug as well as insufficient error logging and finally was able to import my blog to WordPress.
Thanks to the developers who shared their code to help me to finish this work.
By the way import to WordPress also has a few problems, that I had to report to support forum, but they were either resolved or had some workarounds.