Skip to content

Instantly share code, notes, and snippets.

{
"metadata": {
"publisherId": "nicoespeon.abracadabra",
"publisherDisplayName": "nicoespeon"
},
"name": "abracadabra",
"publisher": "nicoespeon",
"version": "4.13.1"
},
@sar
sar / docker-compose.yml
Last active April 24, 2021 22:27
Docker compose file for testing Caddy, emits default `index.html` unless volume attached to `/var/www/html`
# -----------------
# Caddy
# Docs: https://hub.docker.com/_/caddy/
# -----------------
version: "3.7"
services:
caddy:
image: caddy:latest
@sar
sar / 20-nvidia.conf
Created April 21, 2021 00:26
Base X11 nvidia config for NixOS
# -------------------------
# NVIDIA X11 Config
# path: /etc/X11/xorg.conf.d/10-nvidia.conf
# -------------------------
Section "OutputClass"
Identifier "nvidia"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
Option "AllowExternalGpus" "True"
public class IdentifierMasking
{
private static byte[] _key;
public IdentifierMasking(byte[] key = null)
{
_key = key ?? Sodium.SecretBox.GenerateKey();
}
public string RevealIdentifier(string hidden)
using System.IdentityModel.Tokens.Jwt;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Protocols;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
namespace authproxy
{
public class TokenValidator
/*---------------------------------------------------------------------------------------------
* Copyright (c) Dolittle. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text.Encodings.Web;
@sar
sar / startup.cs
Last active April 1, 2021 22:07
CookieAuthenticationScheme defaults
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}
.AddCookie();
}
@sar
sar / typescript-decorators.md
Created March 22, 2021 04:35
Quick guide on constructing TypeScript @decorators

TypeScript Decorators

Wrapping typeof React.Component || React.ComponentType

function UsefulDecorator<T extends new (...args) => any>(
    BaseClass: T,
): T {
    return class _usefulClass extends BaseClass {
 private _someStore: typeof SomeStore = SomeStore;
@sar
sar / xorg.conf.egpu
Last active March 18, 2021 17:58
cat /etc/X11/xorg.conf.egpu
# ----------
# EGPU as Default Config for X11
# Place under (ln -s) /etc/X11/xorg.conf -> /etc/X11/xorg.conf.egpu
# Replace busId using lspci -vvv | grep NVIDIA
# ----------
Section "Module"
Load "modesetting"
EndSection
@sar
sar / 10-nvidia.conf
Created March 18, 2021 17:54
cat /etc/X11/xorg.conf.d/10-nvidia.conf
# -------------------------
# NVIDIA X11 Config
# path: /etc/X11/xorg.conf.d/10-nvidia.conf
# -------------------------
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"