Skip to content

Instantly share code, notes, and snippets.

View kierunb's full-sized avatar
💭
Any sufficiently advanced bug is indistinguishable from a feature.

Bartek kierunb

💭
Any sufficiently advanced bug is indistinguishable from a feature.
View GitHub Profile
@kierunb
kierunb / Test
Last active November 5, 2018 10:25
test
app.Use(async (context, next) =>
{
// Do work that doesn't write to the Response.
await next.Invoke();
// Do logging or other work that doesn't write to the Response.
});
namespace webapi1.Repositories
{
public interface IUserRepository
{
string GetByID(int id);
}
public class UserRepository: IUserRepository
{
public string GetByID(int id)
@kierunb
kierunb / swagger
Last active November 5, 2018 12:44
dotnet add package Swashbuckle.AspNetCore
//namespace:
using Swashbuckle.AspNetCore.Swagger;
// w metodzie ConfigureServices
// Register the Swagger generator, defining 1 or more Swagger documents
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
@kierunb
kierunb / nlog
Last active November 5, 2018 13:30
NLog
NLog.Web.AspNetCore
// w pliku .csproj
<ItemGroup>
<Content Update="nlog.config" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
// configuracja w pliku Porgram.cs
dotnet add package GlobalExceptionHandler
dotnet restore
using GlobalExceptionHandler.WebApi;
using Microsoft.AspNetCore.Http;
// do metody configure:
// to powinno isc do else
app.UseGlobalExceptionHandler(x =>
{
@kierunb
kierunb / EF Core
Last active November 5, 2018 14:52
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World')
})
console.log('go');
app.listen(3000)
@kierunb
kierunb / Angular
Last active November 6, 2018 10:32
//styles.css
@import url('https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css');
export function addNumbers (x: number, y: number): number {
return x + y;
}
export class User {
private name: string;
<!-- grid with two rows -->
<div class="container">
<!-- navs component from boostrap -->
<div class="row">
<div class="col-sm">
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" routerLink="/list" routerLinkActive="active" >Lista browarow</a>
</li>