Skip to content

Instantly share code, notes, and snippets.

View tgroshon's full-sized avatar

Tommy Groshong tgroshon

View GitHub Profile
@tgroshon
tgroshon / oop_code_smells.md
Last active November 24, 2021 09:19
OOP Code Smells by Martin Fowler and Kent Beck grouped by Mika Mantyla

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 March 24, 2023 23:24
Draft of "React Patterns in a Post-Hooks World"
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

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 August 29, 2019 19:40
Idea for more managed data lib
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 19:13
For all those stupid fibonnaci questions
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 14:24
Capture of Amplify build system "amplifyPush" helper script
#!/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 April 4, 2019 21:02
Example GraphQL Schema
# These are your main API Types
type User {
id: ID!
name: String!
email: AWSEmail
}
type Activity {
id: ID!
@tgroshon
tgroshon / search_list_of_dicts.py
Last active March 29, 2022 14:34
Because it can be done
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):
@tgroshon
tgroshon / .vimrc.vim
Last active February 10, 2022 16:15
Vim Settings (requires Vundle)
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " required
Plugin 'mileszs/ack.vim'
@tgroshon
tgroshon / .spacemacs.el
Last active December 4, 2021 18:58
Spacemacs Settings
;; -*- mode: emacs-lisp; lexical-binding: t -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Layer configuration:
This function should only modify configuration layer settings."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'