Skip to content

Instantly share code, notes, and snippets.

View jarroda's full-sized avatar

Jarrod Alexander jarroda

View GitHub Profile
@jarroda
jarroda / Program.cs
Created March 28, 2024 15:15
Hash Email Address
using System.Security.Cryptography;
using System.Text;
internal class Program
{
private static void Main(string[] args)
{
var email = "[email protected]";
var hashed = Hash(email);
@jarroda
jarroda / Projections.cs
Last active June 24, 2016 19:06
Example of a projection based on aggregate relation
public class MartenProjectionEx<T> : IProjection where T : class, new()
{
private readonly IAggregationFinder<T> _finder;
private readonly IAggregator<T> _aggregator;
private readonly Dictionary<Type, Func<object, Guid>> _relatedEvents = new Dictionary<Type, Func<object, Guid>>();
private readonly ProjectionOptions _options;
public MartenProjectionEx(IAggregationFinder<T> finder, IAggregator<T> aggregator, ProjectionOptions options)
{
@jarroda
jarroda / docker.cmd
Last active January 30, 2016 03:33
Docker cert fix
# Regenerate certs
docker-machine -D regenerate-certs default
# Attach to running container
docker exec -it container_name bash
@jarroda
jarroda / bindinghandler.js
Created January 4, 2016 18:42
Knockout + bootstrap-tagsinput
ko.bindingHandlers.tagsinput = {
init: function(element, valueAccessor, allBindings) {
var options = allBindings().tagsinputOptions || {};
var value = valueAccessor();
var valueUnwrapped = ko.unwrap(value);
var el = $(element);
el.tagsinput(options);
@jarroda
jarroda / SnakeCasePropertyNamesContractResolver.cs
Last active July 1, 2018 08:37
Snake Case (lowercase, underscore delimited, ruby-style) property name formatting for JSON.net
using Newtonsoft.Json.Serialization;
public class SnakeCasePropertyNamesContractResolver : DefaultContractResolver
{
protected override string ResolvePropertyName(string propertyName)
{
for (int i = propertyName.Length - 1; i > 1; i--)
{
if (char.IsUpper(propertyName[i]))
{
@jarroda
jarroda / git_config_file_with_ninja_aliases.sh
Created June 1, 2015 13:26
git_config_file_with_ninja_aliases
[user]
name = First Last
email = [email protected]
[core]
symlinks = false
autocrlf = true
[color]
diff = auto
status = auto
branch = auto
description "nginx http daemon"
start on runlevel [2]
stop on runlevel [016]
console owner
exec /opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf -g "daemon off;"
respawn