Today I Learned: SharpRepository

I absolutely forgot about the blog. My bad. Let’s add something interesting about C#. SharpRepository SharpRepository is a generic repository written in C# which includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits. ...

December 17, 2015 · 2 min · 228 words · Pavel Nasovich

Today I Learned: Sanitize File Name in C#

A short update about safe file names in C#. Sanitize File Name in C# To clean up a file name you could do this private static string MakeValidFileName(string name) { string invalidChars = new string(Path.GetInvalidFileNameChars()) string escapedInvalidChars = Regex.Escape(); string invalidRegex = string.Format(@"([{0}]*\.+$)|([{0}]+)", escapedInvalidChars); return Regex.Replace(name, invalidRegex, "_"); } Working example you can find on dotnetfiddle

November 17, 2015 · 1 min · 56 words · Pavel Nasovich

Today I Learned: Git Submodules

A short update about submodules in git. Git submodules Let’s start by adding an existing Git repository as a submodule of the repository that we’re working on. To add a new submodule you use the git submodule add command with the absolute or relative URL of the project you would like to start tracking. git submodule add https://github.com/forcewake/CommandPipeline By default, submodules will add the subproject into a directory named the same as the repository. ...

November 13, 2015 · 1 min · 85 words · Pavel Nasovich

Today I Learned: Protobuf and replace switch in JS

A short update about several interesting issues that i faced in today How-to use Protobuf You should install protobuf-net from nuget and then: // Explicit proto contract [ProtoContract] public class MappedEntity { [ProtoMember(1)] public int Id { get; set; } [ProtoMember(2)] public string Name { get; set; } } var entity = new MappedEntity { Id = 1, Name = "123" }; // Serialize/deserialize using protobuf-net byte[] serialized; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, entity); serialized = ms.ToArray(); } MappedEntity deserialized; using (var ms = new MemoryStream(serialized)) { deserialized = Serializer.Deserialize<MappedEntity>(ms); } More information about usage, issues and problems in Protobuf you can get from this article in Russian ...

November 10, 2015 · 4 min · 670 words · Pavel Nasovich

Today I Learned: Homebrew, Jekyll and Liquid

I’ve decide to start writing in my blog.. And I faced with several issues and strange things in the tools and frameworks. How-to install Sublime Text 3 with Homebrew It’s pretty easy to install it but for man who is moving from Windows to Mac OS it is rather hard to change mind. I did not have brew cask installed so I had to install it first, so these were the steps I followed: ...

November 8, 2015 · 2 min · 416 words · Pavel Nasovich