Skip to content

Instantly share code, notes, and snippets.

Avatar
💻

Dave Schinkel dschinkel

💻
View GitHub Profile
@dschinkel
dschinkel / CompanyDetailNew.js
Last active Feb 24, 2021
Assert runs before hook done updating state
View CompanyDetailNew.js
import React, { useEffect, useState } from 'react';
import { CompanyNew } from '../../../Interfaces/Interfaces';
import Main from '../Main';
import MainLayout from '../MainLayout';
interface CompanyDetailNewProps {
fetchCompanyNew: (apiFindCompanyNew: any, companyName: string) => Promise<CompanyNew>,
apiFindCompanyNew: (companyName: string) => Promise<CompanyNew>,
companyName: string
}
@dschinkel
dschinkel / MigrateDB.yml
Last active Dec 31, 2020
Example Github Action that Migrates DB Schema via Flyway
View MigrateDB.yml
name: SQL-Migrations
on:
push:
branches:
- master
jobs:
migrate:
name: Migrate Database
@dschinkel
dschinkel / FeaturedCompanies.js
Last active Oct 7, 2020
Shallow Render Hook with Async Side Effects
View FeaturedCompanies.js
import React, { useEffect, useState } from 'react';
import { Company } from '../../Interfaces/Interfaces.company';
interface FeaturedCompaniesProps {
findFeaturedCompanies: () => Promise<Array<Company>>
}
const FeaturedCompanies = (props: FeaturedCompaniesProps) => {
const [featuredCompanies, setData] = useState([]);
useEffect(() => {
@dschinkel
dschinkel / FeaturedCompanies.js
Last active Oct 5, 2020
Attempt #1 - Invert Business Logic
View FeaturedCompanies.js
import React, { useEffect, useState } from 'react';
import { Company } from '../../Interfaces/Interfaces.Company';
// this doesn't work with brackes for some reason:
// const FeaturedCompanies = ({findFeaturedCompanies: () => Promise<Array<Company>>}) => {
const FeaturedCompanies = (findFeaturedCompanies: () => Promise<Array<Company>>) => {
const [featuredCompanies, setData] = useState([]);
useEffect(() => {
@dschinkel
dschinkel / App.js
Created Sep 25, 2020
Using React Router and Hooks Router in the Same App
View App.js
import React, { Component } from 'react';
import { Route, Switch } from 'react-router-dom';
...
import { useRoutes } from 'hookrouter';
export const routes = {
'/login': () => <Login />
};
const RenderRoutes = () => {
@dschinkel
dschinkel / examples.auth.github.container.registry.yml
Last active Sep 5, 2020
GitHub Actions - Authing into GitHub Container Repository
View examples.auth.github.container.registry.yml
# stdout a github secret (environment variable) to stdin with docker login command
- run: echo ${{ secrets.GHCP_ACCESS_TOKEN }} | docker login ghcr.io -u USERNAME --password-stdin
@dschinkel
dschinkel / react-router-functional-component.ts
Created Aug 17, 2020
Cookebook - React/TypeScript - React Router via Functional Component (unverified)
View react-router-functional-component.ts
//source: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17355
import { RouteComponentProps } from 'react-router-dom';
type MyProps = RouteComponentProps<{ id?: string }>
const CoolThing: React.FC<MyProps> = ({ match }) => {
const id = match.params.id;
return (
View user-onboarding-welcome-message.spec.js
it('only sends one welcome message', async () => {
mockPost('/chat.postMessage', { called: true });
const channel = '';
const user: SlackUser = {
token: '',
trigger_id: '',
view: undefined,
id: '',
team_id: ''
};
View gist:b6a319d730e4651f73d42079317ad33c
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define NUMBER_OF_DAYS 3
// Put your code below:
int main(void)
{
int k, highEntry, lowEntry;
printf("-- -= == IPC Temperature Analyzer == = --\n");
for (int i = 1; i < NUMBER_OF_DAYS; i++)
@dschinkel
dschinkel / MakeCallTest.java
Last active Aug 16, 2019
Roboelectric - Example of Finding a Child Fragment from a test
View MakeCallTest.java
/*
Dave Schinkel's Notes after he wrote this test:
This is a test I wrote headlessly with Roboelectric around an existing Legacy codebase that's a mess.
We want to get some sort of confidence with an integration test which is what this test gave us for a
certain part of this codebase.
This test indirectly tests behavior further down by
checking what I ultimately expected to be rendered