This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SubstringExtensions { | |
/// <summary> | |
/// Gets the substring after the first occurence of the specified character. | |
/// </summary> | |
/// <param name="self">The string self.</param> | |
/// <param name="ch">The character.</param> | |
/// <returns>The substring after the first occurrence of the specified character. If | |
/// The character does not occur in the string, the empty string is returned.</returns> | |
public static string SubstringAfter(this string self, char ch) { | |
int index = self == null ? -1 : self.IndexOf(ch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringRegexExtensions{ | |
/// <summary> | |
/// Matches a string against a regular expression. | |
/// </summary> | |
/// <param name="self">The string self.</param> | |
/// <param name="pattern">The regular expression.</param> | |
/// <returns>True if it is match, otherwise false.</returns> | |
public static bool IsMatch(this string self, string pattern) { | |
return Regex.IsMatch(self, pattern); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProcessIndicator : IDisposable { | |
public ProcessIndicator(string message, int count, int step = 1, Func<string, int, int, int, string> getIndicator = null) { | |
_count = count; | |
_step = step; | |
_counter = 0; | |
_getIndicator = getIndicator ?? Bar; | |
Console.Write(message + " "); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
public static class Profiler { | |
public static ProfilerTimer Profile(string name) { | |
return new ProfilerTimer(name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string FriendlyFileSize( long size) { | |
const double @base = 1024d; | |
const string format = "{0:0.#} {1}"; | |
if (size == 0L) { | |
return "0 b"; | |
} | |
var magnitudes = new Dictionary<int, string> { | |
{0, "B" }, {1, "kB"}, {2, "MB"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch meta data from a web page | |
// Depends on CsQuery [https://github.com/jamietre/CsQuery] | |
// Nuget: install-package csquery | |
using CsQuery; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bumpVersion { | |
param ( $v, $part = 'patch' ) | |
$v -match '^(\d+)\.(\d+)\.(\d+)(.*)$' | out-null | |
$major, $minor, $patch, $rest = [int]$matches[1], [int]$matches[2], [int]$matches[3], $matches[4] | |
switch ($part) { | |
'major' { $major += 1; $minor = 0; $patch = 0 } | |
'minor' { $minor += 1; $patch = 0 } | |
'patch' { $patch += 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets | |
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>EPiServer class logger</Title> | |
<Description>Adds a static EPiServer Log logger field</Description> | |
<Shortcut>log</Shortcut> | |
</Header> | |
<Snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using EPiServer; | |
using EPiServer.Logging.Compatibility; | |
using EPiServer.PlugIn; | |
using EPiServer.Scheduler; | |
using EPiServer.ServiceLocation; | |
using System; | |
using System.Collections.Generic; | |
namespace <namespace> { | |
// The docs: http://world.episerver.com/documentation/developer-guides/CMS/scheduled-jobs/ |