Skip to content

Instantly share code, notes, and snippets.

View solrevdev's full-sized avatar
💭
🤓

John Smith solrevdev

💭
🤓
View GitHub Profile
@solrevdev
solrevdev / dont-fuck-with-paste.js
Created November 14, 2023 13:07
When sites try to block you from pasting data into fields. Stop them. allow paste!
View dont-fuck-with-paste.js
var allowPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('paste', allowPaste, true);
// see
// https://www.cyberciti.biz/linux-news/google-chrome-extension-to-removes-password-paste-blocking-on-website/
// also see
@solrevdev
solrevdev / subl-error-fix.md
Last active October 17, 2023 13:16
sublime on MacBook air issue
View subl-error-fix.md

Thanks to the following GitHub comment for this fix:

Package Control will be uppraded next time package update is triggered, either by automatic updates at ST startup or by manually calling "Package Control: Upgrade All Packages/Overwrite All" via Command Palette.

In case PC3.x is not working, you can

- download https://github.com/wbond/package_control/releases/download/4.0.0-beta2/Package.Control.sublime-package
- call Main Menu > Preferences > Browse Packages...
- navigate to to ../Installed Packages
@solrevdev
solrevdev / empty-git-commit.sh
Last active August 21, 2023 12:00
A blank empty git commit - generally used for testing ci etc.
View empty-git-commit.sh
# macos single chars are fine
git commit --allow-empty -m 'ci: empty commit for pr [skip ci]'
# windows needs double chars
git commit --allow-empty -m "ci: empty commit for pr [skip ci]"
@solrevdev
solrevdev / HttpContextExtensions.cs
Last active August 16, 2023 10:46
Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET (via By Rick Strahl)
View HttpContextExtensions.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System;
using System.IO;
/// <summary>
/// Provides extension methods for the HttpContext class.
/// </summary>
public static class HttpContextExtensions
@solrevdev
solrevdev / DotnetAndProductVersion.cs
Created July 21, 2023 11:04
How to get the running .NET version and also the current Product version via <Version> element in csproj
View DotnetAndProductVersion.cs
using System;
using System.Reflection;
var dotnetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
Console.WriteLine($"🌄 .NET Version: {dotnetVersion}");
var productVersion = Assembly.GetEntryAssembly().GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>().InformationalVersion;
Console.WriteLine($"🌄 Product Version : {productVersion}");
@solrevdev
solrevdev / DotnetVersion.cs
Created July 20, 2023 09:14
Gets the version of .net version running this code
View DotnetVersion.cs
using System;
var dotnetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
Console.WriteLine($"🌄 .NET Version: {dotnetVersion}");
@solrevdev
solrevdev / DateOnly.HowOldIsPerson.cs
Created July 20, 2023 09:06
Using DateOnly and Record's is C# to work out how old someone is
View DateOnly.HowOldIsPerson.cs
using System;
Console.WriteLine("No static void main");
var p = new Person(Guid.NewGuid(), "John", new DateOnly(1975, 1, 1));
Console.WriteLine(p.ToString());
public record Person(Guid Id, string Name, DateOnly DateOfBirth)
{
public override string ToString()
@solrevdev
solrevdev / slugify.js
Created July 7, 2023 14:00
vanilla javascript method to slugify a string
View slugify.js
function slugify(input) {
if (!input)
return '';
// make lower case and trim
var slug = input.toLowerCase().trim();
// remove accents from charaters
slug = slug.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
@solrevdev
solrevdev / omnisharp.json
Last active July 4, 2023 08:59
An updated omnisharp.json to try out see #omnisharp tag in raindrop.io for more info
View omnisharp.json
{
"RoslynExtensionsOptions": {
"EnableAnalyzersSupport": true,
"EnableDecompilationSupport": true,
"EnableImportCompletion": true
},
"FormattingOptions": {
"EnableEditorConfigSupport": true,
"OrganizeImports": true
},
@solrevdev
solrevdev / download-all-images.js
Last active June 29, 2023 11:09
A browser devtools snippet to download all images on a webpage.
View download-all-images.js
$$('img').forEach(async (img) => {
try {
const src = img.src;
// Fetch the image as a blob.
const fetchResponse = await fetch(src);
const blob = await fetchResponse.blob();
const mimeType = blob.type;
// Figure out a name for it from the src and the mime-type.
const start = src.lastIndexOf('/') + 1;
const end = src.indexOf('.', start);