Skip to content

Instantly share code, notes, and snippets.

View changhuixu's full-sized avatar
💭
Everyone has a happy ending. If you're not happy, it's not the end.

Changhui Xu changhuixu

💭
Everyone has a happy ending. If you're not happy, it's not the end.
View GitHub Profile
@changhuixu
changhuixu / git-prompt.sh
Created June 26, 2020 13:38
~/.config/git/git-prompt.sh
PS1='\[\033]0;$TITLEPREFIX:\W\007\]' # set window title
PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[32m\]' # change to green
PS1="$PS1"'git@local ' # user@host<space>
PS1="$PS1"'\[\033[35m\]' # change to purple
PS1="$PS1"'$MSYSTEM ' # show MSYSTEM
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1"'\W' # current working directory
if test -z "$WINELOADERNOEXEC"
then
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\e an ASCII escape character (033)
\h the hostname up to the first '.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion following the final slash)
@changhuixu
changhuixu / git-prompt.sh
Created June 26, 2020 13:08
cd /etc/profile.d/
if test -f /etc/profile.d/git-sdk.sh
then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
TITLEPREFIX=$MSYSTEM
fi
if test -f ~/.config/git/git-prompt.sh
then
. ~/.config/git/git-prompt.sh
public class SftpService
{
private readonly ILogger<SftpService> _logger;
private readonly SftpConfig _config;
public SftpService(ILogger<SftpService> logger, SftpConfig sftpConfig)
{
_logger = logger;
_config = sftpConfig;
}
var config = new SftpConfig
{
Host = "test.rebex.net",
Port = 22,
UserName = "demo",
Password = "password"
}; // can be retrieved from appsettings.json
using var client = new SftpClient(config.Host, config.Port, config.UserName, config.Password);
public class SftpConfig
{
public string Host { get; set; }
public int Port { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
version: '3.8'
services:
rabbitmq:
image: rabbitmq:3-management-alpine
hostname: my-rabbit
container_name: rabbitmq
volumes:
- ./rabbitmq/etc/definitions.json:/etc/rabbitmq/definitions.json
- ./rabbitmq/etc/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /app
COPY ./*.csproj ./
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /out --no-restore
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS runtime
WORKDIR /app
COPY --from=build /out ./
public class OrdersController : ControllerBase
{
private readonly ILogger<OrdersController> _logger;
private readonly IRabbitMQClient _rabbitMqClient;
public OrdersController(ILogger<OrdersController> logger, IRabbitMQClient rabbitMqClient)
{
_logger = logger;
_rabbitMqClient = rabbitMqClient;
}
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddSingleton(rabbitMqConnection);
services.AddSingleton<IRabbitMQClient, RabbitMQClient>();
// ...
}