Skip to content

Instantly share code, notes, and snippets.

Avatar

Tommy Groshong tgroshon

View GitHub Profile
@tgroshon
tgroshon / Components.jsx
Last active Jul 16, 2020
Interesting Framework Idea
View Components.jsx
import ReactDOM from "react-dom";
import React from "react";
/*
================
React Components
================
*/
export class ReactClassComponent extends React.Component {
View Symmetric Encryption in the Old West.md

Symmetric Encryption in the Old West

Setup

Roles

You will need 3 teams with 1 or more people on each team (minimum 3 total people).

  • Bankers A: Dodge City
  • Bankers B: Tombstone
@tgroshon
tgroshon / oop_code_smells.md
Last active Dec 9, 2019
OOP Code Smells by Martin Fowler and Kent Beck grouped by Mika Mantyla
View oop_code_smells.md

OOP Code smells

Things that might indicate a problem. RailsConf talk "Get a Whiff of This" by Sandi Metz

  • Couplers: binds objects together
    • feature envy (send more messages to object than to self)
    • inappropriate intimacy (access private methods/data)
    • message chains (law of demeter; too many dots)
    • middle man (sole purpose to forward on calls)
@tgroshon
tgroshon / react-patterns-post-draft.md
Last active Oct 24, 2019
Draft of "React Patterns in a Post-Hooks World"
View react-patterns-post-draft.md
title author
React Patterns in a Post-Hooks World
name url
Tommy Groshong

Introduction

React is an amazing library and over the last 5 years has transformed the

View reducer_vs_state_example.js
import axios from "axios";
// Using `useState()` to manage individual pieces
function ComponentWithPlainState({ coursenum }) {
let [loading, setLoading] = useState(false);
let [data, setData] = useState();
let [errors, setErrors] = useState();
useEffect(() => {
setLoading(true);
@tgroshon
tgroshon / artemis.js
Last active Aug 29, 2019
Idea for more managed data lib
View artemis.js
import React from 'react';
import axios from 'axios';
import { createStore } from 'redux';
// GOAL:
// let { useCustomers, ArtemisProvider } = makeDataLayer(schema, axios)
// let { customers, signup } = useCustomers('fetch');
const schema = {
Customers: {
@tgroshon
tgroshon / fib.py
Last active May 22, 2019
For all those stupid fibonnaci questions
View fib.py
def fib_n_recur(n):
''' Recursive fibonnaci
Pro: Matches mathematical definition
Con: O(2^n) runtime; n > 40 crazy slow; will blow the stack on large n
'''
if n == 0:
return 0
elif n == 1:
@tgroshon
tgroshon / amplifyPush.sh
Created May 1, 2019
Capture of Amplify build system "amplifyPush" helper script
View amplifyPush.sh
#!/usr/bin/env bash
set -e
IFS='|'
help_output () {
echo "usage: amplify-push <--environment|-e <name>> <--simple|-s>"
echo " --environment The name of the Amplify environment to use"
echo " --simple Optional simple flag auto-includes stack info from env cache"
exit 1
}
@tgroshon
tgroshon / example-schema.graphql
Last active Apr 4, 2019
Example GraphQL Schema
View example-schema.graphql
# These are your main API Types
type User {
id: ID!
name: String!
email: AWSEmail
}
type Activity {
id: ID!
View search_list_of_dicts.py
from operator import itemgetter, eq
from functools import partial
"""
Find dictionary with ID = 2 in a functional way
"""
records = [{'id': 1}, {'id': 2}, {'id': 3}, {'id': 4}]
def compose(*funcs):
def h(*args, **kwargs):
You can’t perform that action at this time.