Skip to content

Instantly share code, notes, and snippets.

View sskirby's full-sized avatar

Sean Kirby sskirby

  • Nulogy Corp.
  • Toronto, Ontario
View GitHub Profile
@sskirby
sskirby / useLocalStorageState.js
Created November 11, 2021 17:32
React hook for state persisted to local storage
import * as React from 'react'
/**
*
* @param {String} key The key to set in localStorage for this value
* @param {Object} defaultValue The value to use if it is not already in localStorage
* @param {{serialize: Function, deserialize: Function}} options The serialize and deserialize functions to use (defaults to JSON.stringify and JSON.parse respectively)
*/
function useLocalStorageState(
@sskirby
sskirby / repository.rb
Created September 26, 2015 02:19
Proposed API for Vorpal v0.0.7
require 'vorpal'
module TreeRepository
extend self
# The engine is basically the same as the old repository (some methods have been renamed, see below)
# but it is not intended to be used directly.
engine = Vorpal.define do
map Tree do
attributes :name

Keybase proof

I hereby claim:

  • I am sskirby on github.
  • I am seank (https://keybase.io/seank) on keybase.
  • I have a public key whose fingerprint is F417 A0AB 1343 4478 EC80 403D 6DA5 7F41 B7EE 34C0

To claim this, I am signing this object:

@sskirby
sskirby / gear.rb
Created June 13, 2013 03:37
Gear class from Sandi Metz's "The Magic Tricks of Testing"
class Gear
attr_reader :chainring, :cog, :wheel
def initialize(args)
# ...
end
def gear_inches
ratio * wheel.diameter
end
@sskirby
sskirby / gear_test.rb
Last active December 18, 2015 04:39
testing outbound query methods - stubbed
require "mocha/setup"
class GearTest < MiniTest::Unit:TestCase
def test_calculates_gear_inches
gear = Gear.new(
chainring: 52,
cog: 11,
wheel: stub(diameter: 29))
assert_in_delta(137.1,
gear.gear_inches,
@sskirby
sskirby / gear_test.rb
Last active December 18, 2015 04:39
testing outbound query methods - original
class GearTest < MiniTest::Unit:TestCase
def test_calculates_gear_inches
gear = Gear.new(
chainring: 52,
cog: 11,
wheel: Wheel.new(26, 1.5))
assert_in_delta(137.1,
gear.gear_inches,
0.01)
end
@sskirby
sskirby / .ctags
Created May 24, 2012 23:06
.ctags
--regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/
--regex-ruby=/(^|;)[ \t]*(has_many|belongs_to|has_one|has_and_belongs_to_many)\(? *:([[:alnum:]_]+)/\3/f,function,association/
--regex-ruby=/(^|;)[ \t]*(named_)?scope\(? *:([[:alnum:]_]+)/\3/f,function,named_scope/
--regex-ruby=/(^|;)[ \t]*expose\(? *:([[:alnum:]_]+)/\2/f,function,exposure/
--regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2/f,function,aasm_event/
--regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2!/f,function,aasm_event/
--regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2?/f,function,aasm_event/
--langdef=js
--langmap=js:.js
@sskirby
sskirby / .zshrc
Created May 7, 2012 20:47
.zshrc
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="bira"
# Set to this to use case-sensitive completion
@sskirby
sskirby / functions.vim
Created May 7, 2012 20:45
Useful vim functions
vnoremap <leader>re :call ExtractVariable()<cr>
function! ExtractVariable()
let name = input("Variable name: ")
if name == ''
return
endif
normal! gv
exec "normal c" . name
exec "normal! O" . name . " = "
normal! $p
@sskirby
sskirby / .vimrc
Created May 7, 2012 20:44
.vimrc
filetype off
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible
set hlsearch
set number
set tabstop=2
set shiftwidth=2