Skip to content

Instantly share code, notes, and snippets.

View woahdae's full-sized avatar

Woody Peterson woahdae

  • Seattle, WA, United States
View GitHub Profile
@woahdae
woahdae / init.vim
Created February 20, 2021 01:06
Current vim config (via neovim & vim-plug)
" Specify a directory for plugins
call plug#begin('~/.config/nvim/plugged')
" What I consider essential essentials - these make vim vim-ier (IMHO)
Plug 'mhinz/vim-grepper' " Makes grepping feel like other editors
Plug 'svermeulen/vim-yoink' " Adds a 'kill ring' to vim, i.e. yank history
Plug 'mbbill/undotree' " visualize Vim's built-in undo branches
Plug 'PeterRincker/vim-searchlight' " highlights the current search result
Plug 'tpope/vim-repeat' " makes repeating (.) work in more cases
Plug 'ludovicchabant/vim-gutentags' " Auto ctag managemnet that 'just works'
@woahdae
woahdae / flickity-scrollfix.js
Last active March 6, 2020 13:05
Addresses Flickity bug #740 while someone figures out the next real solve
;(function() {
var touchingCarousel = false
, touchStartCoords
document.body.addEventListener('touchstart', function(e) {
if (e.target.closest('.carousel-cell')) {
touchingCarousel = true
} else {
touchingCarousel = false
return
# frozen_string_literal: true
class CategoryTree < Struct.new(:json)
def inspect
end
end
@woahdae
woahdae / Gemfile
Last active August 22, 2019 23:16
Removing things to get `bundle update rails` to work
source 'https://rubygems.org'
ruby '2.6.3'
gem 'rails', '5.0.7'
group :development do
# Mail gem used to send email from rake tasks
gem 'mail'
@woahdae
woahdae / Gemfile
Last active February 13, 2018 21:35
source 'https://rubygems.org'
gem 'activerecord'
gem 'globalize'
gem 'sqlite3'
@woahdae
woahdae / better_polymorphic.md
Last active December 12, 2015 00:49
Polymorphic relationships supporting referential integrity.

Usage:

  polymorphic :commentable do
    belongs_to :post
    belongs_to :comment
    belongs_to :product
  end

Adds validations that only one is set, and an accessor ('commentable' from above) that gets and sets the polymorphic relation.

@woahdae
woahdae / indexes.rb
Created January 19, 2012 02:11
alternate indexes implementation
# leaves around a pointer to the root mapping after use
def indexes(name, options = {}, &block)
@_mapping_pointer ||= @mapping
@_mapping_pointer[name] = options
if block_given?
previous = @_mapping_pointer
@_mapping_pointer[name][:type] ||= 'object'
@_mapping_pointer = @_mapping_pointer[name][:properties] = {}
yield
@woahdae
woahdae / tire_ext.rb
Created January 18, 2012 17:36
On-the-fly index rotation
module Tire
def self.inverted_aliases
aliases.inject({}) do |acc, (index, aliases)|
aliases.each do |als|
acc[als] ||= SortedSet.new
acc[als] << index
end
acc
end
end
@woahdae
woahdae / gist:1365900
Created November 15, 2011 02:04
Mysql2 error
Process: ruby [80361]
Path: /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: ruby [80349]
Date/Time: 2011-11-14 16:42:57.491 -0800
OS Version: Mac OS X Server 10.7 (11A2061)
Report Version: 9
# Relevant for http://local.seomoz.org:3000/campaigns/1/rankings
Keyword.all.each do |keyword|
[ Week.current.previous,
Week.current.previous.previous,
Week.current.previous.previous.previous ].each do |week|
GA::KeywordMetric.create({
"google_analytics_connection_id"=>2,
"google_analytics_engine_id"=> 96,