Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Workin'

Benjamin Wood benjaminwood

👨‍💻
Workin'
View GitHub Profile
@benjaminwood
benjaminwood / install-stripe.sh
Created Jun 9, 2021
Install latest stripe cli from github releases
View install-stripe.sh
# This assumes jq is installed already.
# The stripe binary will be installed at /bin/stripe
curl --silent "https://api.github.com/repos/stripe/stripe-cli/releases/latest" \
| jq -r '.assets[] | select(.name | endswith("linux_x86_64.tar.gz")).browser_download_url' \
| wget -qi - -O - \
| sudo tar -xzvf - -C /bin stripe > /dev/null
@benjaminwood
benjaminwood / command.sh
Created May 10, 2020
My On Zoom weekend project
View command.sh
#!/bin/bash
# Replace with your D1 IP (see it in serial monitor when the devboard starts up)
url=http://192.168.179.146/LED
while :
do
if xwininfo -tree -root | grep "Zoom Meeting" &> /dev/null
then
curl -d color=red $url
@benjaminwood
benjaminwood / rspec has_one build bug
Created Feb 10, 2019
Test case reproducing an issue that causes a record to be inserted without a require foreign key (foo_id)
View rspec has_one build bug
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "5.2.2"
gem "sqlite3", '~> 1.3.13'
gem "factory_bot", "4.11.1"
View EOFError-no-backtrace-uh-backtrace.log
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/protocol.rb:186:in `rbuf_fill'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/protocol.rb:154:in `readuntil'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/protocol.rb:164:in `readline'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/http/response.rb:40:in `read_status_line'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/http/response.rb:29:in `read_new'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/http.rb:1446:in `block in transport_request'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/http.rb:1443:in `catch'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/http.rb:1443:in `transport_request'",
"/home/deploy/.rbenv/versions/2.4.3/lib/ruby/2.4.0/net/http.rb:1416:in `request'",
"/gems/gems/webmock-2.3.1/lib/webmock/http_lib_adapters/net_http.rb:97:in `block in request'",
@benjaminwood
benjaminwood / active_record_objects_autosave.md
Created Jan 4, 2018 — forked from demisx/active_record_objects_autosave.md
When Active Record Child Objects are Autosaved in Rails
View active_record_objects_autosave.md

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
View codeshipCombineTestPipelineLogs.js
var logLocationInforation = [];
var logs = [];
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', URL.createObjectURL(new Blob([text], {type: "application/octet-stream"})));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
View serverless chrome ECONNREFUSED log
START RequestId: 62375f65-6814-11e7-9b71-5d7513cb8861 Version: $LATEST
2017-07-13 14:44:01.472 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda Spawning headless shell
2017-07-13 14:44:01.496 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda ChromeLauncher No debugging port found on port 9222, launching a new Chro
me.
2017-07-13 14:44:01.496 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda Chrome already running with pid 13.
2017-07-13 14:44:01.496 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda Waiting for Chrome 0
2017-07-13 14:44:02.013 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda Waiting for Chrome 1
2017-07-13 14:44:02.514 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda Waiting for Chrome 2
2017-07-13 14:44:03.015 (-07:00) 62375f65-6814-11e7-9b71-5d7513cb8861 @serverless-chrome/lambda Waiting fo
View .codeclimate.yml
---
engines:
rubocop:
enabled: true
ratings:
paths:
- lib/**
- "**.rb"
exclude_paths:
- spec/**/*
View keybase.md

Keybase proof

I hereby claim:

  • I am benjaminwood on github.
  • I am benjaminwood (https://keybase.io/benjaminwood) on keybase.
  • I have a public key whose fingerprint is F5F8 A6C7 5F99 E195 189F 60B8 0205 FF8F 4B67 5D5B

To claim this, I am signing this object:

View contemplative.rb
require 'action_view'
require 'ostruct'
require 'erb'
require 'flog'
require 'ruby_parser'
require 'sexp_processor'
ERBHandler = ActionView::Template::Handlers::ERB.new
def new_template(body, details={format: :html})