Skip to content

Instantly share code, notes, and snippets.

View johnw86's full-sized avatar

John Walker johnw86

View GitHub Profile
@johnw86
johnw86 / CSharpSnippets.cs
Created August 13, 2018 15:52
C# Snippets
var mimeMappingFromFileName = System.Web.MimeMapping.GetMimeMapping("Filename");
@johnw86
johnw86 / jquery.validate.remote.js
Created October 16, 2018 10:05
MVC Remote Validation Additionalfields Trigger
function getModelPrefix(fieldName) {
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
}
function appendModelPrefix(value, prefix) {
if (value.indexOf("*.") === 0) {
value = value.replace("*.", prefix);
}
return value;
}
@johnw86
johnw86 / launch.json
Last active August 10, 2021 11:38
Jest test runner config. VS code
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
@johnw86
johnw86 / gist:f71c6f0cca84a8f34e281ac8f657c77a
Created July 11, 2019 15:25
Unit tests with IConfiguration
var myConfiguration = new Dictionary<string, string>
{
{"Age", "18"},
{"Nested:Property", "1"},
};
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(myConfiguration)
.Build();
@johnw86
johnw86 / git.txt
Last active July 29, 2020 18:39
git Commands
Update gitignore and remove committed files that should no longer be in source control
git rm -r --cached .
git add .
git commit -m ".gitignore fix"
@johnw86
johnw86 / spflookup.cs
Created September 18, 2020 10:38
SFP Lookup
// Using DnsClient nuget package
var client = new LookupClient();
var textRecords = client.Query("google.com", QueryType.TXT).AllRecords.TxtRecords();
var spfRecords = textRecords.Where(x => x.EscapedText.Any(t => t.Contains("spf")));
foreach (var spfRecord in spfRecords)
{
foreach (var text in spfRecord.EscapedText)
@johnw86
johnw86 / InstaStory.jsx
Created May 10, 2022 12:56
Instagram Story CDN Handling
import logo from './logo.svg';
import './App.css';
import React from 'react';
function App() {
const [showVideo, setShowVideo] = React.useState(true);
const [showImage, setShowImage] = React.useState(true);
const cdnLink = "https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=18041239177335195&signature=AbyRRJJOrhzZVtk5I4R-Y68YJOtVRq0ee5bet-gMDsTwgsS2iWKM6qZakxyOUDnFbt8t1ehbsQo6-ZsrYGzl6g1pX3dc7SCX6BfxPz93Q22xINr2NLaMzhK6qMZ8-pi1Ev9V_8yyer3CQwEX0IbjFsA3qvcVKTL_W9LTf1YA7uILkb-k";
@johnw86
johnw86 / kusto.txt
Last active October 8, 2024 20:06
Kusto Queries
// Get top 5 storm types causing any damage in the state of Virginia during april
StormEvents
| where State == "VIRGINIA"
| where StartTime >= datetime(2007, 04, 01) and EndTime < datetime(2007, 05, 01)
| project EventType, Damage=DamageCrops+DamageProperty
| top 5 by Damage
// Count all records
StormEvents
| count
Issue stuck starting
Delete the settings.json file from %AppData%\Docker, restart machine.
@johnw86
johnw86 / ohmyposhv3-v2.json
Created August 22, 2023 08:35 — forked from shanselman/ohmyposhv3-v2.json
ohmyposhv3-v2
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,