Skip to content

Instantly share code, notes, and snippets.

View frankhale's full-sized avatar
🧩
Building a SaaS

Frank Hale frankhale

🧩
Building a SaaS
View GitHub Profile
@frankhale
frankhale / Foo.cs
Created May 14, 2020 20:01
Map single object to list of objects in AutoMapper
using AutoMapper;
using System.Collections.Generic;
namespace AutoMapperSandbox
{
public class SingleObjectToListConverter<T> : ITypeConverter<T, List<T>>
{
public List<T> Convert(T source, List<T> destination, ResolutionContext context)
{
return new List<T>() { source };
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Options With Dependencies</title>
</head>
<body>
<select id="select1" name="select1" title="Select 1">
<option value="">-- select an option --</option>
@frankhale
frankhale / StripHtml.cs
Created August 2, 2012 21:25
Strip HTML using HtmlAgilityPack
public static string StripHtml(this string value)
{
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(value);
if (htmlDoc == null)
return value;
StringBuilder sanitizedString = new StringBuilder();
# Credit for this: Nicholas Swift
# as found at https://medium.com/@nicholas.w.swift/easy-a-star-pathfinding-7e6689c7f7b2
from warnings import warn
import heapq
class Node:
"""
A node class for A* Pathfinding
"""
@frankhale
frankhale / gist:4ea7a98af9451a71943ecd77efc66d55
Last active March 16, 2021 14:05
MassTransit ASPNET Core Azure ServiceBus config fail
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
var queueTopic = "topic name here";
var sendQueueConnectionString = "Send EndPoint Connection String Here";
var receiveQueueConnectionString = "Receive EndPoint COnnection String Here";
// My intent is to have this ASPNET Core API publish and also be a consumer
#include "wren.h"
#include <stdio.h>
#include <string.h>
void writeFn(WrenVM* vm, const char* text) {
printf("%s", text);
}
void fooBar(WrenVM* vm) {
WrenType type = wrenGetSlotType(vm, 1);
@frankhale
frankhale / MassTransitAPIEndPointTest.cs
Last active May 20, 2020 00:21
Guessing this is not possible?
[Fact]
public async Task Get_GetDefaultEndPoint_ReturnsOk()
{
// Arrange
var harness = new InMemoryTestHarness();
var consumerHarness = harness.Consumer<MyMessageConsumer>();
await harness.Start();
try
{
@frankhale
frankhale / MassTransitConfig.cs
Created May 20, 2020 00:16
MassTransitConfig
services.AddMassTransit(x =>
{
x.AddConsumer<MyMessageConsumer>();
x.AddBus(provider => Bus.Factory.CreateUsingInMemory(cfg =>
{
cfg.UseHealthCheck(provider);
cfg.ReceiveEndpoint("mymessage-endpoint", ep =>
{
ep.ConfigureConsumer<MyMessageConsumer>(provider);
});
@frankhale
frankhale / mud-domain-model-ideas.md
Created December 2, 2018 02:58
A Psuedo-code modeling of a typical MUD domain

Domain Model

This is a work in progress but is an attemp to model the domain of a typical MUD in psuedo-code

direction

  • name (string)

currency

@frankhale
frankhale / youtube-search-with-video-duration.js
Created June 15, 2017 16:55
Example of using YouTube-Search to perform a video search and then integrate the video duration into the results
const util = require("util");
const search = require("youtube-search");
const _ = require("lodash");
var xhr = require("xhr");
if (!xhr.open) xhr = require("request");
var opts = {
maxResults: 1,
key: "<YOUR_KEY_HERE>"
};