Skip to content

Instantly share code, notes, and snippets.

@roommen
roommen / Hybrid (Windows+Linux) Docker Swarm
Last active February 17, 2025 14:46
Hybrid (Windows+Linux) Docker Swarm
**********************
*** Pre-requisites ***
**********************
1. Set up Windows 2016 password:
gcloud beta compute --project <project_id> reset-windows-password <instance_name> --zone <zone_name>
ip_address: <ip_address>
password: <defult_password_generated>
username: <username>
3. Installing Docker:
@madskristensen
madskristensen / ETagMiddleware.cs
Last active October 8, 2025 20:16
ASP.NET Core ETAg middleware
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Net.Http.Headers;
using System.IO;
using System.Security.Cryptography;
using System.Threading.Tasks;
public class ETagMiddleware
{
@AndreiMarukovich
AndreiMarukovich / docker-compose.yaml
Last active November 8, 2023 07:11
Docker Compose configuration for running TeamCity, build agents and PostgreSQL in Docker containers
version: '2'
services:
postgres:
image: postgres:latest
volumes:
- /srv/postgresql/data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=<your-password>
- POSTGRES_USER=teamcity
@divega
divega / MyContext.cs
Last active May 18, 2020 04:35
Simple builder class for creating TVPs that work in .NET Core 1.0
using Microsoft.EntityFrameworkCore;
namespace TvpSampleApp
{
public class MyContext : DbContext
{
public DbSet<Person> People { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@stevenknox
stevenknox / UseTenantFilter.cs
Last active October 10, 2016 22:11
UseTenant TypeFilterAttribute for SaaSKit - https://github.com/saaskit/saaskit/
public class UseTenantAttribute : TypeFilterAttribute
{
public UseTenantAttribute() : base(typeof(UseTenantFilter))
{
}
private class UseTenantFilter : IActionFilter
{
readonly AppTenant _tenant;
public UseTenantFilter(ITenant<AppTenant> tenant)
@marcelsamyn
marcelsamyn / Creating Neat .NET Core Command Line Apps.md
Last active November 28, 2023 10:41
Creating Neat .NET Core Command Line Apps

Creating Neat .NET Core Command Line Apps

You can now read this on my (pretty) website! Check it out here.

Every reason to get more HackerPoints™ is a good one, so today we're going to write a neat command line app in .NET Core! The Common library has a really cool package Microsoft.Extensions.CommandlineUtils to help us parse command line arguments and structure our app, but sadly it's undocumented.

No more! In this guide, we'll explore the package and write a really neat

@rockfordlhotka
rockfordlhotka / Index.cshtml
Last active March 30, 2026 03:57
Simple edit list of items in ASP.NET MVC
@* Goes in Views\PersonList *@
@using EditableListMvc.Models
@model IEnumerable<Person>
@{
ViewBag.Title = "Person List";
}
<h2>Person List</h2>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using Newtonsoft.Json;
namespace ConsoleApp6
{
public class Program
@paambaati
paambaati / launch.js
Last active August 19, 2025 10:21
Debug mocha tests using Visual Studio Code
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
@burgalon
burgalon / AccountAuthenticator.java
Last active March 22, 2026 15:28
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);