Skip to content

Instantly share code, notes, and snippets.

View joebutler2's full-sized avatar
🎢
Fractional CTO and Coach

Joe joebutler2

🎢
Fractional CTO and Coach
View GitHub Profile
@joebutler2
joebutler2 / .vimrc
Created October 25, 2021 21:33
Vim configuration
set nocompatible " be iMproved, required
filetype off " required
set runtimepath^=~/.vim/plugged/vim-misc
" for python to work with autotag
let g:autotagStartMethod='fork'
" Use vim-plug to manage plugins
call plug#begin('~/.vim/plugged')
class Solution {
solve(points) {
const byX = {};
const byY = {};
const result = [];
// points.sort((a,b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
for(let [x, y] of points) {
byX[x] = byX[x] || [];
byX[x].push(y);
byY[y] = byY[y] || [];
@joebutler2
joebutler2 / complement.rb
Created April 10, 2020 01:47
How to implement the complement function from Clojure
# TIL in Clojure the complement function takes a predicate and
# returns a function that is like the original function but negates
# the results.
# E.g.
# def is_greater(a, b); a > b; end
# complement(:is_greater)[1, 2] # => true
def complement(method_name)
lambda do |*args|
!method(method_name).call(*args)
end
@joebutler2
joebutler2 / mysql2-mojave.md
Created September 26, 2019 15:14 — forked from fernandoaleman/mysql2-mojave.md
Install mysql2 on MacOS Mojave

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@joebutler2
joebutler2 / bundler.output
Last active September 25, 2019 21:51
Dependency conflicts for RefineryCMS (Rails 6 support). Note that this is using an updated version of refinerycms-i18n locally.
Bundler could not find compatible versions for gem "railties":
In Gemfile:
coffee-rails (~> 4.2) was resolved to 4.2.2, which depends on
railties (>= 4.0.0)
refinerycms was resolved to 4.0.2, which depends on
refinerycms-core (= 4.0.2) was resolved to 4.0.2, which depends on
decorators (>= 2.0.0, ~> 2.0) was resolved to 2.0.1, which depends on
railties (>= 4.0.0, < 5.0.0)
@joebutler2
joebutler2 / failing_tests.txt
Created September 20, 2019 16:15
Upgrading refinery CMS to support Rails 6, now using latest version of database_cleaner. The errors are more consistent now.
1) the Admin Images Tab When there are many images has behaviour: uploads images when the image type is acceptable the image is uploaded
Got 1 failure and 1 other error:
Shared Example Group: "uploads images" called from ./images/spec/features/refinery/admin/images_spec.rb:39
1.1) Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
expected `Refinery::Image.count` to have changed by 1, but was changed by 0
# ./images/spec/support/shared_examples/image_uploader.rb:24:in `block (3 levels) in <top (required)>'
# ./core/spec/support/database_cleaner.rb:18:in `block (2 levels) in <top (required)>'
1.2) Failure/Error: row = @stmt.step
@joebutler2
joebutler2 / failing_tests.txt
Last active September 20, 2019 15:05
Upgrade RefineryCMS to use Rails 6
Failures:
1) with multiple locales redirects should redirect to default locale slug
Failure/Error: visit "/#{ru_page_slug_encoded}"
ActionController::RoutingError:
No route matches [GET] "/%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8"
# /Users/jbutler/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/request_store-1.4.1/lib/request_store/middleware.rb:19:in `call'
# ./pages/spec/features/refinery/pages_spec.rb:402:in `block (3 levels) in <module:Refinery>'
@joebutler2
joebutler2 / 0_simple.rb
Last active January 20, 2018 03:45
Code samples for the "Private constants in Ruby" article
class CPUOpponent
def self.base_points
1000
end
private_class_method :base_points
end
puts CPUOpponent.base_points
# => NoMethodError: private method ‘base_points’ called for CPUOpponent:Class
@joebutler2
joebutler2 / .vimrc
Created October 9, 2017 00:09
Vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@joebutler2
joebutler2 / dcRpsSpec.js
Created June 14, 2017 18:35
First attempt at RPS kata
/**
* Created by pivotal on 6/14/17.
* new Rps().play(...)
*/
function Rps() {
this.p1WinConditions = {
scissors: "paper",
paper: "rock",
rock: "scissors"