Skip to content

Instantly share code, notes, and snippets.

Chris Marisic dotnetchris

Block or report user

Report or block dotnetchris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dotnetchris
dotnetchris / GitForWindowsSetup.md
Last active May 8, 2019 — forked from dmangiarelli/GitForWindowsSetup.md
How to setup Git for Windows
View GitForWindowsSetup.md

How to setup Git for Windows

I know this document seems long, but it shouldn't be too difficult to follow. This guide is based on Windows, but every program here have Linux/Mac equivalents, and in most cases they're built-in. So, take a deep breath and go step by step.

The steps below are for GitHub, but the steps are almost idential for Bitbucket, Heroku, etc.

You'll probably want to make sure Chocolatey is installed, since it streamlines installing this stuff later. If you install via Chocolatey, you don't need to run the installers from the products' respective sites.

Make powershell more friendly, add additonal useful commands like Add-PathVariable. Optional but recommended, otherwise lots more nag prompts throughout.

@dotnetchris
dotnetchris / 0_reuse_code.js
Created Aug 14, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dotnetchris
dotnetchris / EnsureModelStateIsValid.cs
Last active Jun 27, 2019
AspNetCore.Mvc action filter for ensuring validation of both model state and all action parameters as a precondition to a MVC action
View EnsureModelStateIsValid.cs
/// <summary>
/// This action filter ensures ModelState.IsValid is true as a precondition to entry into the MVC action
/// </summary>
/// <remarks>
/// This class also validates all action parameters unlike the default behavior of ModelState.IsValid
/// </remarks>
/// <see cref="https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/" />
public class EnsureModelStateIsValid : ActionFilterAttribute
{
private static readonly ConcurrentDictionary<MethodInfo, ParameterInfo[]> MethodCache
@dotnetchris
dotnetchris / Base58.cs
Last active Feb 15, 2017
Base58 is case SENSITIVE alphanumeric ELIMINATING: 0 (zero), I (uppercase), O (uppercase), l (lowercase)
View Base58.cs
/// <summary>
/// Base58 is case SENSITIVE alphanumeric ELIMINATING: 0 (zero) I (uppercase), O (upppercase), l (lowercase)
/// This reduction of characters eliminates the majority of human typoposition errors
///
/// https://gist.github.com/CodesInChaos/3175971
/// </summary>
public class Base58
{
private const string Base58Digits = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
private static readonly char[] Base58Chars = Base58Digits.ToCharArray();
@dotnetchris
dotnetchris / OrdinalIgnoreCaseString.cs
Last active Aug 30, 2016
Allows you to treat strings as case insensitive
View OrdinalIgnoreCaseString.cs
struct OrdinalIgnoreCaseString : IEquatable<OrdinalIgnoreCaseString>, IEquatable<string> {
string _str;
public OrdinalIgnoreCaseString(string str) {
_str = str;
}
public static implicit operator OrdinalIgnoreCaseString(string str) {
return new OrdinalIgnoreCaseString(str);
}
View jquery-observe.js
(function(d) {
d.Observe = {}
})(jQuery);
(function(d, q) {
var r = function(e, f) {
f || (f = e, e = window.document);
var m = [];
d(f).each(function() {
for (var l = [], g = d(this), h = g.parent(); h.length && !g.is(e); h = h.parent()) {
var f = g.get(0).tagName.toLowerCase();
View My Git aliases
[alias]
co = checkout
ci = commit
branches = branch
syncdev = "!git fetch origin; git merge origin/development"
up-c = checkout -f
View 1 - Map Arguments to Properties.cs
// Runnable from Linqpad 5
// Must install the Sigil nuget package and include the Sigil namespace
void Main()
{
var createSample = GetMapperDelegate();
// try it out
createSample(23, "Hello").Dump();
}
@dotnetchris
dotnetchris / PageDown Headings that support H1-H4
Created Sep 30, 2014
PageDown Headings that support H1-H4
View PageDown Headings that support H1-H4
//replace this method
commandProto.doHeading = function (chunk, postProcessing) {
// Remove leading/trailing whitespace and reduce internal spaces to single spaces.
chunk.selection = chunk.selection.replace(/\s+/g, " ");
chunk.selection = chunk.selection.replace(/(^\s+|\s+$)/g, "");
// If we clicked the button with no selected text, we just
// make a level 2 hash header around some default text.
if (!chunk.selection) {
chunk.startTag = "#### "; /* rewrite to start at H4 instead */
View StyleRelativePathTransform
public class StyleRelativePathTransform : IBundleTransform
{
private const string UrlPattern = @"url\s*\(\s*([""']?)([^:)]+)\1\s*\)";
private static readonly Regex UrlRegex = new Regex(UrlPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
public void Process(BundleContext context, BundleResponse response)
{
var mergedCss = new StringBuilder();
You can’t perform that action at this time.