Skip to content

Instantly share code, notes, and snippets.

View dotnetchris's full-sized avatar

Chris Marisic dotnetchris

View GitHub Profile
@dotnetchris
dotnetchris / Base58.cs
Last active April 3, 2023 13:10
Base58 is case SENSITIVE alphanumeric ELIMINATING: 0 (zero), I (uppercase), O (uppercase), l (lowercase)
/// <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
/// </summary>
public class Base58
{
private static readonly BaseN base58 = new BaseN("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); //base58
public static string Encode(long @long) => base58.Encode(@long);
@dotnetchris
dotnetchris / HenriFormatter.cs
Created March 23, 2012 14:07 — forked from atifaziz/HenriFormatter.cs
Updated HenriFormatter from Named Formats Redux
// http://haacked.com/archive/2009/01/14/named-formats-redux.aspx#70485
using System;
using System.Text;
using System.Web;
using System.Web.UI;
namespace StringLib
{
public static class HenriFormatter
@dotnetchris
dotnetchris / GitForWindowsSetup.md
Last active December 22, 2022 22:23 — forked from dmangiarelli/GitForWindowsSetup.md
How to setup Git for Windows

How to setup Git for Windows

Improve developer's experience inside powershell, adding useful commands like Add-PathVariable. This is optional but recommended to minimize confirmation of every single action you invoke.

First let's update powershell itself (elevated):

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
@dotnetchris
dotnetchris / PageDown Headings that support H1-H4
Created September 30, 2014 16:05
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 */
@dotnetchris
dotnetchris / EnsureModelStateIsValid.cs
Last active June 27, 2019 09:09
AspNetCore.Mvc action filter for ensuring validation of both model state and all action parameters as a precondition to a MVC action
/// <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 / gist:3636052
Created September 5, 2012 12:47
Simple ravendb backup script
$dest = "F:\Backup\Runs\backup-"+(Get-Date).ToString("yyyy-MM-dd HHmm")
.\Raven.Backup.exe --url=http://localhost/ --dest=$dest
& 'C:\Program Files\7-Zip\7z.exe' a $dest $dest
Remove-Item -Recurse $dest
@dotnetchris
dotnetchris / 0_reuse_code.js
Created August 14, 2017 13:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dotnetchris
dotnetchris / jquery-observe.js
Created June 2, 2016 21:04
jquery-observe unminified ala http://unminify.com/
(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();
@dotnetchris
dotnetchris / OrdinalIgnoreCaseString.cs
Last active August 30, 2016 19:20
Allows you to treat strings as case insensitive
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);
}
[alias]
co = checkout
ci = commit
branches = branch
syncdev = "!git fetch origin; git merge origin/development"
up-c = checkout -f