Skip to content

Instantly share code, notes, and snippets.

View codeocelot's full-sized avatar

Joey Gracey codeocelot

View GitHub Profile
import ReactDOM from 'react-dom';
import Post from './Post';
ReactDOM.render(
<Post postId="1" /> ,
document.getElementById('root')
)
@codeocelot
codeocelot / git.sh
Last active November 9, 2017 12:08
Git monsters
# What the fuck just happened to this file?
git reflog -p --since=yesterday -- $file
# I forgot my branch name. What am I working on?
git for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)'|column -ts'|'
import { compose } from 'redux';
const ToUpper = (Component) => ({ text }) => <Component text={text.toUpper()} \>
const WithUnderscores = (Component) => ({ text }) => <Component text={text.split(' ').join('_')} />
export default compose(ToUpper, WithUnderscores);
// use like this
@codeocelot
codeocelot / useWhy.js
Created June 3, 2019 23:35
useWhy hook
import { useState } from 'react';
function useWhy(deps, id = null, logger = console.log) {
const [prevDeps, setPrevDeps] = useState(deps);
let changed = false;
deps.forEach((d, i) => {
if (d !== prevDeps[i]) {
changed = true;
logger(`Why ${id}: dep ${i} has changed from ${prevDeps[i]} to ${d}`);
}
@codeocelot
codeocelot / init.lua
Last active June 2, 2023 17:16
Switch keyboard lang based on active application
-- Add the following to your init.lua (or create it if it doesn't exist)
local Keyboard = require "keyboard"
Keyboard:init()