Skip to content

Instantly share code, notes, and snippets.

View davidisnotnull's full-sized avatar
🛠️
On contract

David Johnson davidisnotnull

🛠️
On contract
View GitHub Profile
@davidisnotnull
davidisnotnull / docker-desktop-app-armour.txt
Created November 16, 2024 19:56
Workaround for Docker Desktop in Ubuntu 24.04
The AppArmor in Ubuntu 24.04 causes Docker Desktop to fail to run. The workaround for this is to create a new profile in App Armor once Docker Desktop has been installed.
Run this command to create a new App Armor profile:
sudo nano /etc/apparmor.d/opt.docker-desktop.bin.com.docker.backend
And enter this into the profile in nano
abi <abi/4.0>,
@davidisnotnull
davidisnotnull / threads-user-base-comparison.md
Created February 6, 2024 20:02
Comparison of Threads' User Base with Other Social Media Platforms
Platform Monthly Active Users (MAU) Daily Active Users (DAU) Average Age Dominant User Group Key Features Strengths Weaknesses
Threads 100M (peak, July 2023) 10.3M (Jan 2024) 18-25 Gen Z Ephemeral messaging, close friends focus Fast initial growth, Meta integration High user decline, limited features, privacy concerns
X (Formerly Twitter) 253M 166M 34-49 Diverse Microblogging, news, real-time updates Large user base, established platform Competition, toxicity concerns, recent user loss
Instagram 2 billion 1.4 billion 25-34 Diverse Photo & video sharing, Stories, Reels Large user base, diverse content, influencer marketing Algorithm-driven feed, privacy concerns, pressure to curate
Facebook 2.91 billion 1.9 billion 35-44 Diverse News, connecting with friends & family, groups Largest user base, mature platform Declining younger users, privacy concerns, information overload
TikTok 1.5 billion
@davidisnotnull
davidisnotnull / add-swap-space-in-ubuntu-2204.md
Created February 2, 2024 16:33
How To Add Swap Space on Ubuntu 22.04

How To Add Swap Space on Ubuntu 22.04

One way to guard against out-of-memory errors in applications is to add some swap space to your server. In this guide, we will cover how to add a swap file to an Ubuntu 22.04 server.

Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM. This lets you increase the amount of information that your server can keep in its working memory, with some caveats. The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data.

The information written to disk will be significantly slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a fallback for when your system’s RAM is depleted can be a good safety net against out-of-memory exceptions on systems with non-SSD storage available.

We can see

@davidisnotnull
davidisnotnull / docker-vhd-compression.txt
Created September 27, 2023 22:08
Compress docker vhdx using diskpart
wsl --shutdown
diskpart
//if you haven't moved the vhd, then it should be here by default
select vdisk file="C:\Users\[YourLocalUserName]\AppData\Local\Docker\wsl\data\ext4.vhdx"
attach vdisk readonly
compact vdisk //this might take a while
detach vdisk
exit
@davidisnotnull
davidisnotnull / create-admin-user-optimizely-12.md
Created September 5, 2023 14:32
Creating an admin user in Optimizely 12

Install the EpiServer.Templates package globally

dotnet new install EPiServer.Templates

Then install the optional EpiServer CLI tools

dotnet tool install Episerver.Net.CLI -g --add-source https://nuget.optimizely.com/feed/packages.svc/
@davidisnotnull
davidisnotnull / default
Created May 24, 2022 10:47
default Nginx config
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
@davidisnotnull
davidisnotnull / enable-migrations.md
Last active February 23, 2022 22:33
Enable EF Core migrations

Make sure you install Microsoft.EntityFrameworkCore.Design from nuget to allow migrations in the project. Then, open terminal and navigate to the root folder of the project in the solution that contains the EF implementation that you want to enable migrations on.

Create initial snapshot

dotnet ef migrations add InitialCreate

Run migration

dotnet ef database update
@davidisnotnull
davidisnotnull / checkbox-validation.js
Created February 2, 2022 22:21
Custom jquery-validation handling for check boxes must equal true
window.onload = () => {
/*
Custom jquery-validation handling for check boxes must equal true
Decorate C# model bool properties with
[Range(typeof(bool), 'true', 'true', ErrorMessage = 'Add your error message')]
to make their corresponding checkbox validate to 'must equal true'
*/
var defaultRangeValidator = $.validator.methods.range;
$.validator.methods.range = function (value, element, param) {
if (element.type === 'checkbox') {
@davidisnotnull
davidisnotnull / get-properties-using-interactive-window.md
Created December 14, 2021 14:35
Using C# Interactive window to get all properties of an object
> #r "C:/MyApp/bin/Debug/Foo.dll"
> using MyApp;
> var personType = typeof(Person);
> var personProperties = personType.GetProperties();
> foreach(var personProperty in personProperty) { Console.WriteLine($"{nameof(Person)}.{personProperty.Name}"); }

This will return a list of all of the properties to the Console

@davidisnotnull
davidisnotnull / port-in-use-fix.md
Created December 13, 2021 10:05
Fix for IIS Express error in Visual Studio being unable to start

Open CMD as an administrator and run the following commands in sequence:

net stop winnat

net start winnat