Skip to content

Instantly share code, notes, and snippets.

View miguelangelgonzalez's full-sized avatar

Miguel Angel Gonzalez miguelangelgonzalez

View GitHub Profile
@miguelangelgonzalez
miguelangelgonzalez / Elasticsearch.md
Last active May 3, 2017 02:53
How to run a elasticsearch cluster with docker swarm

How to run a elasticsearch cluster with docker swarm

docker-machine env node-1 | Invoke-Expression

docker run -d --name portainer -p 9000:9000 -v "/var/run/docker.sock:/var/run/docker.sock" portainer/portainer

docker network create --driver overlay elk

docker service create --name util --network elk --mode global alpine sleep 1000000000 docker service ps util

@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)
@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
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 / 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
@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 / 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
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));
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.Globalization;
namespace Common.Extensions
{
public static class DateExtensions
{
public static DateTime January(this int year, int day)
{
return new DateTime(year, 1, day);