Skip to content

Instantly share code, notes, and snippets.

View SeedyROM's full-sized avatar
🚂
Coding Time

Zack Kollar SeedyROM

🚂
Coding Time
View GitHub Profile
@SeedyROM
SeedyROM / dir-grep.sh
Created March 9, 2020 17:55
Grep Multiple Files and List Their Names
# The /dev/null forces grep to have multiple file names so it tricks the output into listing the files their names
grep ${REPLACE-ME} /dev/null *
@SeedyROM
SeedyROM / injector.cr
Created December 16, 2019 19:20
Crystal Dependency Injector
# A simple DSL for createing dependency injected modules/classes.
module Opaque::Injector
# Full DSL setup, this creates a module for dependencies dynamically.
#
# ```
# include Injector
#
# dependencies do
# dependency :logger, Logger.new(STDOUT, Logger::INFO)
# end
byte incomingBytes[32];
byte powerOn[] = {0x6, 0x01, 0x00, 0x19, 0x02, 0x1C};
byte powerOff[] = {0x6, 0x01, 0x00, 0x19, 0x01, 0x1F};
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
}
@SeedyROM
SeedyROM / useDidUpdate.ts
Created September 29, 2019 09:31
React hook to handle if an effect updated.
const useDidUpdate = () => {
const isNotMounted = useRef(true);
useEffect(() => {
if (isNotMounted.current) {
isNotMounted.current = false;
}
});
return !isNotMounted.current;
};
@SeedyROM
SeedyROM / store.js
Created September 27, 2019 08:35
A simple recreation of a SUPER basic redux store.
class Store {
constructor(reducer) {
const [state, dispatch] = reducer;
this.state = Object.freeze(state);
this._dispatch = dispatch;
this._effectFunc = null;
}
dispatch(action) {
const prevState = Object.freeze({ ...this.state });
@SeedyROM
SeedyROM / .shortcutsrc
Created August 10, 2019 03:05
Shortcuts for my Linux Box
# General Shortcuts
alias wifi="wicd-curses"
alias connections="sudo iftop -i wlp4s0"
alias restart-network="sudo service network-manager restart"
alias work="cd ~/Workspace"
alias dc="docker-compose"
# Mistake Shortcuts
alias gti="git"
@SeedyROM
SeedyROM / .shortcutsrc
Created August 10, 2019 03:05
Shortcuts for my Linux Box
# General Shortcuts
alias wifi="wicd-curses"
alias connections="sudo iftop -i wlp4s0"
alias restart-network="sudo service network-manager restart"
alias work="cd ~/Workspace"
alias dc="docker-compose"
# Mistake Shortcuts
alias gti="git"
@SeedyROM
SeedyROM / ExampleContext.tsx
Last active February 20, 2021 23:53
TypeScript/React Context Store
import isEqual from "lodash/isEqual";
// Types for testing
import { ICartItem } from "../types/Cart";
import createStore from '../helpers/createStore';
type State = ICartItem[];
type Action =
| { type: "add" | "remove", item: ICartItem }
| { type: "clear" };
@SeedyROM
SeedyROM / query-params.js
Last active May 13, 2019 08:37
Functional helper to build query parameters for GET requests.
const buildQueryParams = (params) => (
Object
.keys(params)
.reduce((q, k) => q + `${k}=${params[k]}&`, '?')
.slice(0, -1)
);
// Usage:
const queryParams = buildQueryParams({
hello: 'world',
@SeedyROM
SeedyROM / styled-wrapper.tsx
Last active January 11, 2019 13:44
A simple helper to create functional Vue components with CSS modules and Typescript.
import { componentFactory } from 'vue-tsx-support';
import { VNode } from 'vue';
type Styles = string | Array<string>;
interface WrapperProps {
as?: string;
}
export default (