Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexsandro Souza Pereira alexsandro-xpt

View GitHub Profile
@alexsandro-xpt
alexsandro-xpt / server.cs
Created May 15, 2021 — forked from davidfowl/server.cs
Simplified ASP.NET Core app exploration
View server.cs
#!/usr/bin/env dotnet run
var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
var connString = config["connectionString"] ?? "Data Source=todos.db";
builder.AddDbContext<TodoDb>(options => options.UseSqlite(connString));
builder.AddSqlite<Todo>(connString) // Higher level API perhaps?
var app = builder.Build();
View Multitenancy.cs
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
/*
- Don't need to support different services per tenant.
- Tenant services lifetime outlasts the request.
View gist:bc4d4afbbbd09f19e6b8266523d599a7
hostname elliot-01
echo elliot-01 > /etc/hostname
bash
curl -fsSL https://get.docker.com | bash
docker version
docker ps
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
apt-get update
apt-get install kubelet kubectl kubeadm
View ReadPostData.cs
using System;
using System.Buffers;
using System.IO.Pipelines;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
View docker-compose.yml
version: '3'
services:
sqlserver2019:
image: mcr.microsoft.com/mssql/server:2019-CTP3.1-ubuntu
environment:
ACCEPT_EULA: Y
SA_PASSWORD: SqlServer2019!
ports:
- "41434:1433"
@alexsandro-xpt
alexsandro-xpt / Dockerfile
Created Jul 16, 2019 — forked from kevnord/Dockerfile
Debugging .NET Core in Docker Container with Visual Studio Code. Based on https://github.com/Microsoft/generator-docker/issues/130#issuecomment-287222915
View Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 80
# DEBUG
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS debug
WORKDIR /app
@alexsandro-xpt
alexsandro-xpt / Program.cs
Created Jul 1, 2019 — forked from davidfowl/Program.cs
A minimal fully asynchronous C# ASP.NET Core 3.0 application with routing (learn more about ASP.NET Core here https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcore-3.0)
View Program.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
public class Program
{
public static void Main(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
@alexsandro-xpt
alexsandro-xpt / setup.sh
Created May 6, 2019 — forked from jjvillavicencio/setup.sh
Install Android SDK on Windows Bash (WSL)
View setup.sh
cd /home/<user>/
sudo apt-get install unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d Android
rm sdk-tools-linux-4333796.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/tools/bin
@alexsandro-xpt
alexsandro-xpt / 1.cs
Created Mar 10, 2019 — forked from vkhorikov/1.cs
Value Object
View 1.cs
public abstract class ValueObject<T>
where T : ValueObject<T>
{
public override bool Equals(object obj)
{
var valueObject = obj as T;
if (ReferenceEquals(valueObject, null))
return false;