Skip to content

Instantly share code, notes, and snippets.

View drewhamlett's full-sized avatar
Verified

Drew Hamlett drewhamlett

Verified
  • Untappd
  • Wilmington, NC
View GitHub Profile
name code-refactor-review
description Reviews code changes for reuse, composition, codebase consistency, and slop. Use when asked to review PRs/diffs, check code reuse, composition, cleanliness, or whether code fits the codebase.

Code Refactor Review

Review code changes the way Sahaj usually asks for review: go deep on reuse, composition, codebase consistency, and anything that reads like slop.

First Pass

@dabit3
dabit3 / devin-expo.md
Created April 1, 2026 23:42
Running Expo on Devin

Devin can build, test, and iterate on Expo and React Native apps. This guide walks through how to configure Devin's environment so it's ready to work on your Expo project from the first session.

Why Expo works well with Devin

Expo provides a managed workflow that simplifies React Native development. For Devin, the key advantage is Expo's web preview — Devin can run your app in its built-in browser without needing a physical device or emulator. This means Devin can visually verify UI changes, test navigation flows, and debug layout issues during a session.


Setting up your Expo repo

@robzolkos
robzolkos / stories.rb
Last active September 8, 2023 21:37
story.rb refactor
# Original code https://twitter.com/robinbortlik/status/1699524286568964440?s=20
# app/controllers/stories.rb
class StoriesController < ApplicationController
before_action :check_authorizationa # this should check and return a 401
def create
story = Story.new(story_params)
if story.save
@peterc
peterc / embedding_store.rb
Last active December 5, 2025 17:06
Using SQLite to store OpenAI vector embeddings from Ruby
# Example of using SQLite VSS with OpenAI's text embedding API
# from Ruby.
# Note: Install/bundle the sqlite3, sqlite_vss, and ruby-openai gems first
# OPENAI_API_KEY must also be set in the environment
# Other embeddings can be used, but this is the easiest for a quick demo
# More on the topic at
# https://observablehq.com/@asg017/introducing-sqlite-vss
# https://observablehq.com/@asg017/making-sqlite-extension-gem-installable
@xenobrain
xenobrain / gjk.rb
Last active October 17, 2024 14:18
Physics stuff
DEG2RAD = Math::PI / 180.0
def tick args
b = args.state.box_a ||= { x: 540, y: 360, w: 200, h: 200, angle: 45, path: 'sprites/square/blue.png' }
a = args.state.box_b ||= { x: 340, y: 360, w: 100, h: 100, angle: 45, path: 'sprites/square/green.png' }
$a = a
a.y += 1 if args.inputs.up
a.y -= 1 if args.inputs.down
a.x -= 1 if args.inputs.left
@andymatuschak
andymatuschak / gist:c5f2b8b68821a95e5b339bfcd4bfcee1
Last active July 21, 2020 16:59
late-bound React hook callbacks, avoiding subtree re-renders when event callback deps change
function useWeakRef<T>(value: T): React.MutableRefObject<T> {
const ref = useRef(value);
useEffect(() => {
ref.current = value;
}, [value]);
return ref;
}
function useByrefCallback<Args extends unknown[], Result>(
callback: (...args: Args) => Result,
@Robert-96
Robert-96 / README.md
Last active March 27, 2025 03:22
Ember.Js: Installing Tailwind CSS

Ember.Js: Installing Tailwind CSS

TL;DR

$ ember install ember-cli-postcss                   # Install ember-cli-postcss
$ npm install --save-dev tailwindcss                # Install tailwindcss

$ npx tailwind init app/styles/tailwind.config.js   # Optional: Generate a Tailwind config file for your project  
$ npm install -save-dev postcss-import # Optional: If you want to use the @import statement
@kitze
kitze / mst-utils.ts
Created March 20, 2020 09:19
mst-utils
import { types, IAnyModelType, Instance, cast } from "mobx-state-tree";
import React, { useMemo } from "react";
export const createModel = <T extends IAnyModelType>(
model: T,
value?: Record<string, any>
) => types.optional(model, () => model.create(value));
export function castSelf<IStoreInstance, IParentModel>(
store: IStoreInstance,
@ianmstew
ianmstew / Avatar.tsx
Last active November 25, 2019 03:44
asyncComputed example
// Parallel implementation to Avatar example from
// https://github.com/conorhastings/use-reducer-with-side-effects/blob/19d097e95302068d8368b0a10b379b0a6bab9f93/README.md
import { useObserver, useLocalStore } from 'mobx-react';
// WIP library inspired by `import { promisedComputed } from 'async-computed-mobx'`
import asyncComputed from 'utils/mobx/asyncComputed';
const DEFAULT_AVATAR = '/assets/img/default-avatar.png';
function Avatar(props: { userName: string }) {
@kitze
kitze / store.js
Created January 24, 2018 13:14
simplified redux
import produce from 'immer';
import {createStore} from 'redux';
const handleActions = (actionsMap, defaultState) => (
state = defaultState,
{type, payload}
) =>
produce(state, draft => {
const action = actionsMap[type];
action && action(draft, payload);