Skip to content

Instantly share code, notes, and snippets.

@davidfowl
davidfowl / SolutionFolders.ps1
Created February 21, 2011 10:01
Adding a solution folder via DTE in NuGet
function Add-SolutionFolder {
param(
[string]$Name
)
$solution2 = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
$solution2.AddSolutionFolder($Name)
}
function Get-SolutionFolder {
param (
@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
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);
@paambaati
paambaati / launch.js
Last active May 5, 2022 05:35
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",
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using Newtonsoft.Json;
namespace ConsoleApp6
{
public class Program
@rockfordlhotka
rockfordlhotka / Index.cshtml
Last active January 23, 2023 09:54
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>
@iamarcel
iamarcel / 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

@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)
@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)
{
@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
@madskristensen
madskristensen / ETagMiddleware.cs
Last active September 11, 2024 18:38
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
{