Skip to content

Instantly share code, notes, and snippets.

using System.DirectoryServices.AccountManagement;
public static bool UserExistsAndIsActive(string username)
{
PrincipalContext context = new PrincipalContext(ContextType.Domain, domain);
UserPrincipal usr = UserPrincipal.FindByIdentity(context, IdentityType.UserPrincipalName, username);
if (!object.ReferenceEquals(null, usr))
{
if (!(bool)(usr.Enabled))
@hfloyd
hfloyd / Error404Page.cs
Created May 3, 2024 15:04
Umbraco v13+ 404 Error IContentLastChanceFinder - Supporting multiple sites at root
namespace MYSITE.Web;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Web;
using Umbraco.Extensions;
@yermulnik
yermulnik / config.yml
Last active May 3, 2024 21:08
GH CLI multi-account switch
git_protocol: ssh
aliases:
personal: '!cp ~/.config/gh/hosts.yml.personal ~/.config/gh/hosts.yml && gh auth status'
work: '!cp ~/.config/gh/hosts.yml.work ~/.config/gh/hosts.yml && gh auth status'

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@iamevn
iamevn / cdromance-download-links.user.js
Last active May 3, 2024 21:02
simple userscript to insert download links back into cdromance (you might need to refresh the page if the links break) (click raw link near top right to install)
@pixeline
pixeline / readme.md
Created June 1, 2019 11:52
Deploy a "docker-composed" environment on DigitalOcean

Deploy docker-compose on digitalocean

  1. create Docker droplet via digitalocean one-click-app-docker
  2. log into it
  3. generate SSH key
ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa
  1. Copy it
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active May 3, 2024 21:04
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
@iam-hussain
iam-hussain / default HTTP
Last active May 3, 2024 20:56
Serve nextJS app from a port through NGINX reverse proxy HTTP and HTTPS
# Serve nextJS app from a port through NGINX reverse proxy (HTTP)
# Path: /etc/nginx/sites-available/default
# Default server configuration for HTTP
server {
server_name www.DOMAINNAME.com DOMAINNAME.com;
# Serve any static assets with NGINX
location /_next/static {
alias /home/ubuntu/PROJECT_FOLDER/.next/static;
@spoike
spoike / svg_paths_cheatsheet.md
Last active May 3, 2024 20:54
Cheatsheet for SVG paths

Cheatsheet for SVG Path Data

Straight line commands

+------------+-------------------+--------+
| *M* or *m* | moveto            | (x y)+ |
+------------+-------------------+--------+
| *Z* or *z* | close path        | (none) |
+------------+-------------------+--------+