Skip to content

Instantly share code, notes, and snippets.

View chestercharles's full-sized avatar
🤠
howdy!

chestercharles chestercharles

🤠
howdy!
View GitHub Profile
@chestercharles
chestercharles / order1.ts
Created March 1, 2023 19:33
Dependency Injection Example
let GraphClient: any;
type Order = any;
const graphClient = GraphClient();
const dynamoDbClient = null as any;
// Resolver
export const createOrderResolver = async (_, args, context) => {
const propertyResult: any = await graphClient.request({
variables: { id: args.propertyId },
@chestercharles
chestercharles / te-map-and-chain.ts
Last active July 19, 2023 09:43
Chain vs. Map with TaskEither
import * as TE from 'fp-ts/lib/TaskEither';
import * as E from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/function';
// Let's start with a value of 4 wrapped up in a TaskEither
const teFour = TE.right(4);
// The type of teFour is TE.TaskEither<never, number> because TE.right knows there will _never_ be a left value (as of yet)
// We can use TE.map to create a function that will accept a TE and operate on it's value
@chestercharles
chestercharles / useThrottledCallback.js
Created September 20, 2019 18:34
Hook to throttle a callback function
export function useThrottledCallback(cb, ms) {
const [callable, setCallable] = useState(true);
return () => {
if (callable) {
cb();
setCallable(false);
setTimeout(() => setCallable(true), ms);
}
};
}
import React from 'react';
import { View, StyleSheet } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import posed from 'react-native-pose';
import { linear } from '@popmotion/easing';
import appTheme from '../../../../appTheme';
export default function SkeletonLoadingIndicator() {
const PosedShimmerView = posed.View({
+
/ \
* -
/ \ / \
+ 5 4 -
/ \ / \
9 4 6 3
/**
* Dijkstra's Algorithmn
* Finds shortest distance between nodes in a grap
*/
import { Vertex, Edge, Graph } from './Graph.js'
var graph = new Graph();
graph.addVertex('1');
graph.addVertex('2');
/**
* http://blog.benoitvallon.com/data-structures-in-javascript/the-graph-data-structure/
*/
export interface Vertex {
vertex: string,
edges: Edge[]
}
export interface Edge {