Skip to content

Instantly share code, notes, and snippets.

View juristr's full-sized avatar

Juri Strumpflohner juristr

View GitHub Profile

In order to uninstall packages you need to go to

/Library/Receipts

where there should be a list of installed applications. By invoking

sbom -fls  some_app.pkg/Contents/some-path/somefile.bom

you get the list of installed files and their corresponding paths. As such, a command like

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace Juristr.Mvc
{
/// <summary>
@juristr
juristr / IngoreMemberAutoMapperExtension.cs
Last active December 12, 2015 07:38
Utility for more easily ignore certain members using AutoMapper
public static class MappingExpressionExtensions
{
public static IMappingExpression<TSource, TDest> IgnoreMember<TSource, TDest>(this IMappingExpression<TSource, TDest> expression, Expression<Func<TDest, object>> destinationMember)
{
expression.ForMember(destinationMember, opt => opt.Ignore());
return expression;
}
}
@juristr
juristr / ModelBinder.cs
Created February 19, 2013 10:07
Model Binder for properly handling null values. See this post here for more details: http://juristr.com/blog/2012/02/aspnet-mvc3-doesnt-deserialize-nullable
public class ModelBinder : IModelBinder
{
private IModelBinder fallbackModelBinder;
public ModelBinder(IModelBinder fallbackModelBinder)
{
this.fallbackModelBinder = fallbackModelBinder;
}
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
@juristr
juristr / gist:4986075
Created February 19, 2013 13:52
Copy one stream onto the other
private static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[32768];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
@juristr
juristr / HttpContextMock.cs
Created February 19, 2013 13:54
Mock HttpContext class
IIdentity identity = new GenericIdentity(AccoDAOTest.userADNamePresentInDB);
IPrincipal currentUser = new GenericPrincipal(identity, null);
TextWriter tw = new StringWriter();
HttpWorkerRequest wr = new SimpleWorkerRequest("/webapp", "c:\\inetpub\\wwwroot\\webapp\\", "default.aspx", "", tw);
HttpContext.Current = new HttpContext(wr);
@juristr
juristr / prettyprint_sunburst.css
Created March 2, 2013 23:24
CSS style for prettyprint sunburst style. More nice themes for prettyprint can be found here: http://demo.stanleyhlng.com/prettify-js/?id=tomorrow-night-dark
/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */
pre .str, code .str { color: #65B042; } /* string - green */
pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
pre .typ, code .typ { color: #89bdff; } /* type - light blue */
pre .lit, code .lit { color: #3387CC; } /* literal - blue */
pre .pun, code .pun { color: #fff; } /* punctuation - white */
pre .pln, code .pln { color: #fff; } /* plaintext - white */
@juristr
juristr / git-cheat-sheet.md
Last active July 17, 2023 20:33
My Git cheat sheet

Git Cheat Sheet

Committing and Undoing

Adding file for committing

$ git add <filename>
@juristr
juristr / Nuget Resync packages
Created September 16, 2013 06:49
Synchronize NuGet with VS project references
function Sync-References([string]$PackageId) {
get-project -all | %{
$proj = $_ ;
Write-Host $proj.name;
get-package -project $proj.name | ? { $_.id -match $PackageId } | % {
Write-Host $_.id;
uninstall-package -projectname $proj.name -id $_.id -version $_.version -RemoveDependencies -force ;
install-package -projectname $proj.name -id $_.id -version $_.version
}
}