Skip to content

Instantly share code, notes, and snippets.

View miguelangelgonzalez's full-sized avatar

Miguel Angel Gonzalez miguelangelgonzalez

View GitHub Profile
@miguelangelgonzalez
miguelangelgonzalez / NumberExtensions.cs
Last active August 29, 2015 14:21
NumberExtensions
using System;
using System.Collections.Generic;
namespace Common.Extensions
{
public static class NumberExtensions
{
public static void Times(this int i, Action<int> action)
{
for (var n = 0; n < i; n++) action(n);
using System;
using System.Globalization;
namespace Common.Extensions
{
public static class DateExtensions
{
public static DateTime January(this int year, int day)
{
return new DateTime(year, 1, day);
using System;
namespace Common.Extensions
{
public static class StringExtensions
{
public static T AsEnum<T>(this string enumName)
{
return (T)Enum.Parse(typeof(T), enumName, true);
}
using System;
using System.Linq;
namespace Common.Extensions
{
public static class ObjectExtensions
{
public static TProperty GetOrDefault<TObject, TProperty>(this TObject entity, Func<TObject, TProperty> property)
{
return entity.GetOrDefault(property, default(TProperty));
@miguelangelgonzalez
miguelangelgonzalez / ShortGuid
Last active August 29, 2015 14:24
Represents a globally unique identifier (GUID) with a shorter string value. Sguid
/// <summary>
/// Represents a globally unique identifier (GUID) with a
/// shorter string value. Sguid
/// </summary>
public struct ShortGuid
{
#region Static
/// <summary>
/// A read-only instance of the ShortGuid class whose value
@miguelangelgonzalez
miguelangelgonzalez / PatternMatch
Created July 12, 2015 17:26
Pattern Matching es el concepto asociado al chequeo estructural de un dato respecto de una estructura esperada. El uso de pattern matching tiene la ventaja de simplificar mucho la codificación, ya que sólo escribimos la forma de lo que esperamos y podemos desglosar los componentes de estructuras complejas.
//-----------------------------------------------------------------------
// <copyright file="PatternMatch.cs" company="Akka.NET Project">
// Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
// Copyright (C) 2013-2015 Akka.NET project <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------
using System;
namespace Akka
@miguelangelgonzalez
miguelangelgonzalez / mingle.groovy
Last active January 21, 2016 15:24 — forked from miguelgonzalezLF/mingle.groovy
Mingle integration for Gitblit using a groovy script
/*
* Copyright 2011 gitblit.com.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
using System;
using System.Net.Mail;
using Gurock.SmartInspect;
public class MailProtocol: Gurock.SmartInspect.Protocol
{
private string fHost;
private int fPort;
private string fTo;
private string fFrom;
@miguelangelgonzalez
miguelangelgonzalez / SafeDeleteService.bat
Created February 11, 2016 20:38
Script to safe start, stop and delete windows services
@echo off
:: Script authored by Hrusikesh Panda (inspired from safeServiceStop script by Erik Falksen)
IF [%1]==[] GOTO usage
IF NOT "%2"=="" SET server=%2
SC %server% query %1 >NUL
IF errorlevel 1060 GOTO ServiceNotFound
IF errorlevel 1722 GOTO SystemOffline
IF errorlevel 1001 GOTO DeletingServiceDelay
@miguelangelgonzalez
miguelangelgonzalez / Create_docker_machine.ps1
Created May 2, 2017 14:22
Create docker machine for elasticsearch
For ($i=1; $i -le 3; $i++) {
$node = "node-" + $i
docker-machine create -d hyperv --hyperv-virtual-switch "docker" --hyperv-memory 1024 $node
docker-machine ssh $node "echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"
}
docker-machine env node-1 | Invoke-Expression
docker swarm init --advertise-addr $(docker-machine ip node-1)