Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Wallace g33kChris

View GitHub Profile
@g33kChris
g33kChris / App.tsx
Created Dec 30, 2019
Example Tag related search code
View App.tsx
// Wrap the application in the InstantSearch provider so the search context is available within the application component tree
<InstantSearchProvider>
{element}
</InstantSearchProvider>
@g33kChris
g33kChris / ReactContextToManageGlobalState.md
Last active Dec 31, 2019
Using React Context to manage global state
View ReactContextToManageGlobalState.md

If you want to skip the blog post and go through the code for yourself here's the recommended reading order...

  • application-state.interface.ts and initial-state.ts (understand the state being used)
  • state-action.interface.ts
  • root.reducer.ts (the main integration point for all state reducers)
    • The other reducers show a more granualar breakdown of reducing state in the application, the state in each of the reducers are quite primitive.
  • state.provider.ts (creation of the react context and state object)
  • app.tsx (the main integration point bridging the context provider and the react component tree)
  • with-application-state.tsx (how to wrap state at any point in the component tree)
  • tags.component.ts (basic usage of the application state dispatcher within a component)
@g33kChris
g33kChris / gatsby-config.js
Created Dec 23, 2019
gatsby-transformer-remark-guide
View gatsby-config.js
plugins: [
...
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [{
resolve: "gatsby-remark-stackblitz",
options: {
height: 600
}
View new-library-in-app.cs
public async static Task NewLibraryInApp()
{
StorageFolder rootFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("GameDex", CreationCollisionOption.ReplaceExisting);
await rootFolder.CreateFolderAsync("Media");
if (await StorageHelper.WriteFileAsync("gdex.json", App.GameDexModel, rootFolder))
{
StorageHelper.SetSetting("GameDexLocation", "Local", StorageHelper.StorageStrategies.Roaming);
return true;
@g33kChris
g33kChris / Dockerfile
Created Sep 11, 2018
.net api dockerfile
View Dockerfile
FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
@g33kChris
g33kChris / BlogPostViewModelBuilder.ts
Last active Apr 29, 2018
Typescript Builder Pattern (Generic to Specific Implementation)
View BlogPostViewModelBuilder.ts
import { injectable } from 'inversify';
import BuilderBase from './BuilderBase';
import IBlogPostViewModelBuilder from './IBlogPostViewModelBuilder';
import IBlogPostViewModel from '@g33kchris/g33kchris.dto.ui/IBlogPostViewModel';
import IContentHeroViewModel from '@g33kchris/g33kchris.dto.ui/IContentHeroViewModel';
import IContentBodyViewModel from '@g33kchris/g33kchris.dto.ui/IContentBodyViewModel';
import IContentMetaViewModel from '@g33kchris/g33kchris.dto.ui/IContentMetaViewModel';
import IRelatedContentViewModel from '@g33kchris/g33kchris.dto.ui/IRelatedContentViewModel';
@g33kChris
g33kChris / bar.js
Created Sep 10, 2017
Inverting the dependencies
View bar.js
// Is depdendent on 'baz', and a dependency of foo!
// Note how it no longer passes down an api client!
export const bar = (myLogger, baz) => () => {
myLogger.debug('lets make a request!');
return baz("http://somehardcodedurl.com");
}
@g33kChris
g33kChris / bar.js
Last active Sep 10, 2017
"Pass the Parcel"
View bar.js
import baz from './baz';
export const bar = (myLogger, myApiClient) => {
myLogger.debug('lets make a request!');
return baz(myLogger, myApiClient, "http://somehardcodedurl.com");
}
You can’t perform that action at this time.