Skip to content

Instantly share code, notes, and snippets.

View dschinkel's full-sized avatar
💻

Dave Schinkel dschinkel

💻
View GitHub Profile
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: ''
};
@dschinkel
dschinkel / react-router-functional-component.ts
Created August 17, 2020 23:45
Cookebook - React/TypeScript - React Router via Functional Component (unverified)
//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 (
@dschinkel
dschinkel / examples.auth.github.container.registry.yml
Last active September 5, 2020 06:59
GitHub Actions - Authing into GitHub Container Repository
# 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 / App.js
Created September 25, 2020 01:08
Using React Router and Hooks Router in the Same App
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 / FeaturedCompanies.js
Last active October 5, 2020 03:27
Attempt #1 - Invert Business Logic
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 / FeaturedCompanies.js
Last active October 7, 2020 19:58
Shallow Render Hook with Async Side Effects
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 / MigrateDB.yml
Last active March 20, 2022 03:50
Example Github Action that Migrates DB Schema via Flyway
name: SQL-Migrations
on:
push:
branches:
- master
jobs:
migrate:
name: Migrate Database
@dschinkel
dschinkel / CompanyDetailNew.js
Last active February 24, 2021 03:36
Assert runs before hook done updating state
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 / create-and-insert-countries.sql
Last active April 24, 2022 05:39
Postgres Dialect | dr5hn / countries-states-cities-database
CREATE TABLE countries (
id integer NOT NULL,
name varchar(100) NOT NULL,
iso3 char(3) DEFAULT NULL,
numeric_code char(3) DEFAULT NULL,
iso2 char(2) DEFAULT NULL,
phonecode varchar(255) DEFAULT NULL,
capital varchar(255) DEFAULT NULL,
currency varchar(255) DEFAULT NULL,
currency_name varchar(255) DEFAULT NULL,
@dschinkel
dschinkel / list.featured.crafters.spec.tsx
Last active April 25, 2022 17:45
Example Integration Test using isolate-react library