Skip to content

Instantly share code, notes, and snippets.

View mikebridge's full-sized avatar
🤔
Thinking

Mike Bridge mikebridge

🤔
Thinking
  • M Bridge Canada Consulting Ltd.
  • Edmonton, Canada
  • 03:26 (UTC -06:00)
View GitHub Profile
@mikebridge
mikebridge / config.sh
Last active December 6, 2018 21:10
Configure dotnet/yarn/docker on an Ubuntu 18.04 machine
#!/bin/bash
$USERNAME="Staging"
$USERLOGIN="staging"
sudo apt-get install emacs-nox
# Add DotNet tools:
# https://dotnet.microsoft.com/download/linux-package-manager/ubuntu18-04/sdk-current
@mikebridge
mikebridge / GravatarHasher.cs
Last active March 9, 2018 17:02
Gravatar Hasher
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Common
{
public static class GravatarHasher
{
/// <summary>
@mikebridge
mikebridge / DemoTests.cs
Created February 20, 2018 20:28
Mock EF DbContext with SQLite for XUnit Test
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
// ...
public static MyDbContext InMemoryContext()
{
// SEE: https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/sqlite
var connection = new SqliteConnection("Data Source=:memory:");
var options = new DbContextOptionsBuilder<MyDbContext>()
.UseSqlite(connection)
@mikebridge
mikebridge / homepage.tsx
Created September 12, 2017 21:00
Sharing Typescript example....
import * as React from "react";
import * as ReactRedux from "react-redux";
interface ICity {
cityName: string;
img: string;
}
// Action Creator
export const getCityInformation = () => ({
@mikebridge
mikebridge / mouseOverComponent.tsx
Created June 26, 2017 03:42
listen to react mouseover events with rxjs
class MouseOverComponent extends React.Component {
componentDidMount() {
this.mouseMove$ = Rx.Observable.fromEvent(this.mouseDiv, "mousemove")
.throttleTime(1000)
.subscribe(() => console.log("throttled mouse move"));
}
componentWillUnmount() {
this.mouseMove$.unsubscribe();
@mikebridge
mikebridge / EventAggregatorTests.cs
Created June 7, 2017 19:39
xUnit tests for EventAggregator.cs
using System;
using System.Collections.Generic;
using Xunit;
// Tests for EventAggregator.cs (https://gist.github.com/mikebridge/f6799ebed20160f72a3daf62f584d2ff)
namespace Messaging.Tests.Unit
{
public class EventAggregatorTests : IDisposable
{
@mikebridge
mikebridge / EventAggregator.cs
Last active March 10, 2021 02:28
A simple Event Aggregator that allows multiple subscribers per message type.
using System;
using System.Reactive.Linq;
using System.Reactive.Subjects;
// inspired by https://github.com/shiftkey/Reactive.EventAggregator/blob/master/src/Reactive.EventAggregator/EventAggregator.cs
namespace Messaging
{
public interface IEventAggregator : IDisposable
{
@mikebridge
mikebridge / reduxTemplate.test.tsx
Last active May 17, 2017 21:15
An Intellij Live template to generate a Redux component test.
//
// A TypeScript template for generating a Redux Test in IntelliJ.
// (accompanies https://gist.github.com/mikebridge/c75835cda361c5967de301995894bf30)
//
// Create: Settings -> Editor => Live Templates -> Add.
// - give it an abbreviation (e.g. "reduxtest") and a Description, and
// - Make it available in JavaScript "JSX HTML", JavaScript "Statement" and TypeScript
//
// Usage: create a file, e.g. "myTemplate.test.tsx", then type "Ctrl-J", and the abbreviation, e.g. "reduxtest".
//
@mikebridge
mikebridge / reduxTemplate.tsx
Last active September 12, 2017 16:20
A redux component template for intellij
//
// A TypeScript template for generating a Redux Component in IntelliJ.
//
// Create: Settings -> Editor => Live Templates -> Add.
// - give it an abbreviation (e.g. "redux") and a Description, and
// - set FILENAME_PASCAL to capitalize(fileNameWithoutExtension()) in "Edit Variables"
// - Make it available in JavaScript "JSX HTML", JavaScript "Statement" and TypeScript
//
// Usage: create a file, e.g. "myTemplate.tsx", then type "Ctrl-J", and the abbreviation, e.g. "redux".
//
import * as React from "react";
import {shallow, mount} from "enzyme";
import withQueryString from "./withQueryString";
import {IQueryStringProps} from "./withQueryString";
import {MemoryRouter} from "react-router";
interface ITestComponentOwnProps {}
class TestComponent extends React.Component<IQueryStringProps & ITestComponentOwnProps, {}> {