Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace Sample.API.Services
{
public interface ISomeWorkService
{
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
public void ConfigureServices(IServiceCollection services)
{
// Add Hangfire services.
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(Configuration.GetConnectionString("Hangfire"), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
@sskset
sskset / UsersController.cs
Created September 3, 2019 13:03
FluentValidationController
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Users.API.Application.Commands;
using Users.API.Application.Queries;
@sskset
sskset / CreateUserCommandValidator.cs
Created September 3, 2019 13:01
FluentValidationValidatorSample
using FluentValidation;
using Users.API.Application.Commands;
namespace Users.API.Application.Validators
{
public class CreateUserCommandValidator : AbstractValidator<CreateUserCommand>
{
public CreateUserCommandValidator()
{
RuleFor(x => x.Email).NotNull().NotEmpty();
@sskset
sskset / startup.cs
Created September 3, 2019 12:59
FluentValidation in Startup.cs
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<Startup>());
}
@sskset
sskset / cr.cs
Last active August 8, 2019 03:55
fibo
using System;
using System.Collections.Generic;
namespace ConsoleApp4
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine(F(21));
@sskset
sskset / muttrc
Created July 8, 2019 05:19 — forked from yangxuan8282/muttrc
Hotmail template config for mutt, just insert your mail account and password to "imap_user" and "imap_pass", if 2-factor is enable, generate an app password.
set ssl_starttls=yes
set ssl_force_tls=yes
set imap_user = 'user_name@hotmail.com'
set imap_pass = 'password_here'
set from= $imap_user
set use_from=yes
set realname='Your_Name'
set folder = imaps://imap-mail.outlook.com:993
set spoolfile = "+INBOX"
USE [Unicorn Paddock]
GO
/****** Object: StoredProcedure [dbo].[sp_test] Script Date: 21/06/2019 11:57:08 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_test]
AS
@sskset
sskset / switchs.sql
Created June 21, 2019 01:55
enable sql server rpc and disable distributed transaction
-- Enable RPC calls
EXEC sp_serveroption Logging, 'RPC OUT', 'TRUE'
-- disable distributed transaction
EXEC sp_serveroption Logging, 'remote proc transaction promotion', 'FALSE'