Skip to content

Instantly share code, notes, and snippets.

View alejofv's full-sized avatar

Alejandro Figueroa alejofv

View GitHub Profile
public class QueueHealthCheck : IHealthCheck
{
private bool _isHealthy;
private string _message = "Trying to connect";
public void SetAsHealthy()
{
_isHealthy = true;
_message = string.Empty;
}
// _queueHealthCheck is injected as a singleton
private async Task<IConnection> EnsureRabbitMqConnection()
{
while (true)
{
try
{
var connection = _connectionFactory();
connection.ConnectionBlocked += (_, args) =>
@alejofv
alejofv / JS-LINQ.js
Created January 20, 2020 17:01 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@alejofv
alejofv / dotnetcore-windows-functionapp-on-azure
Last active January 31, 2020 17:44
GitHub Actions workflow file to deploy a Windows Function App on Azure
name: .NET Core
on:
push:
branches:
- master
jobs:
build:
@alejofv
alejofv / .editorconfig
Last active October 10, 2019 20:47
My .editorconfig for C# files (copied from the Roslyn repo: https://github.com/dotnet/roslyn/blob/master/.editorconfig)
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var style = 'html * { background: rgba(255, 0, 0, .1); box-shadow: 0 0 0 1px red; }'
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf(style) != -1) {
items.push(elements[i]);
}
@alejofv
alejofv / azure-pipelines.yml
Last active September 19, 2019 18:38
Azure pipelines config file to build an Azure Functions project
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
@alejofv
alejofv / profile.ps1
Last active August 14, 2019 04:07
Powershell profile using Powerline prompt
Import-Module Powerline
function Get-PushedLocationCount {
if ($pushed = (Get-Location -Stack).Count) { New-PromptText " &raquo;$pushed " -BackgroundColor "#00af87" -ForegroundColor "#000000" }
}
function Get-GitBranchName {
if (Get-Command git -ErrorAction SilentlyContinue) {
if ($(git rev-parse --is-inside-work-tree 2>$null)) {
$branch = $(git symbolic-ref HEAD 2>$null).ToString().Substring(11)
@alejofv
alejofv / Csharp-FizzBuzz-with-some-linq-love
Last active May 6, 2019 19:49
A C# FizzBuzz solution with some linq love and extensibility support
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FizzBuzz
{
static class Program
{
static void Main(string[] args)
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<useRequestHeadersForMetadataAddress/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>