Skip to content

Instantly share code, notes, and snippets.

View xt0rted's full-sized avatar
πŸ›
Finding all the bugs

Brian Surowiec xt0rted

πŸ›
Finding all the bugs
View GitHub Profile
@ErikNoren
ErikNoren / Program.cs
Last active March 28, 2025 15:35
ASP.NET Core 6 configuration settings stored in a SQL database and acts just like appsettings.json
//Snippet from Program.cs which adds the provider and sets up a Settings class to map the settings
using ErikNoren.Configuration;
using TestMvcWebApplication;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddSqlDatabase(config =>
{
//We can get the connection string from previously added ConfigurationProviders to use in setting this up
config.ConnectionString = builder.Configuration.GetConnectionString("DemoDatabase");
@sindresorhus
sindresorhus / esm-package.md
Last active April 7, 2025 16:23
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@crazy-max
crazy-max / release.yml
Created December 2, 2019 09:11
Workflow to release a GitHub Action
name: release
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
jobs:
@hyrmn
hyrmn / capslockwarning.js
Created October 4, 2019 17:46
Show a little capslock warning if the user tries to log in while their capslock key is on.
<script>
(function() {
var capsLockEnabled = false;
document.onkeypress = function (e) {
e = e || window.event;
var s = String.fromCharCode(e.keyCode || e.which);
if (s.toLowerCase() === s.toUpperCase()) {
return;
}
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
@xavierfoucrier
xavierfoucrier / gpg-signing.md
Last active March 31, 2025 11:40
GPG signing with Git and Github Desktop

GPG signing – git github-desktop

Here is a short guide that will help you setup your environment to create signed commits or signed tags with Git locally. This has been extensively tested on Windows with Git and the Github Desktop application: I use it every day for my professional development projects.

I you face any issue, feel free to leave a comment below.

Summary

  1. Sign commits or tags
  2. Key passphrase
  3. Disable signatures
  4. Renew a GPG key
@NickCraver
NickCraver / DarkMode.js
Last active February 14, 2019 18:31
A quick and dirty re-purpose of UniFi dark elements to make them global.
// A JS example that shows they're well on their way to a dark theme:
document.body.classList.add("ubnt-mod-dark");
document.querySelectorAll(".appTable").forEach(i => i.classList.add("appTable--dark"));
document.querySelectorAll(".ubntPanelContent").forEach(i => i.classList.add("appForm--dark"));
document.querySelectorAll(".appMainButtonGroup").forEach(i => i.classList.add("appMainButtonGroup--dark"));
@NickCraver
NickCraver / OptInRelationalModelSource.cs
Last active August 22, 2018 19:31
OptInRelationalModelSource.cs - Making EF Core opt-in instead of opt-out for properties
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
@NickCraver
NickCraver / .editorconfig
Created September 26, 2017 21:31
Stack Overflow's .editorconfig
# editorconfig.org
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
[*.less]
charset = utf-8
end_of_line = lf