Skip to content

Instantly share code, notes, and snippets.

View benjaminwood's full-sized avatar
👨‍💻
Workin'

Benjamin Wood benjaminwood

👨‍💻
Workin'
View GitHub Profile
@benjaminwood
benjaminwood / install-stripe.sh
Created June 9, 2021 21:16
Install latest stripe cli from github releases
# 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 18:35
My On Zoom weekend project
#!/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 February 10, 2019 22:34
Test case reproducing an issue that causes a record to be inserted without a require foreign key (foo_id)
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"
"/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 January 4, 2018 20:18 — forked from demisx/active_record_objects_autosave.md
When Active Record Child Objects are Autosaved in Rails

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.
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');
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
@benjaminwood
benjaminwood / gist:8479144
Created January 17, 2014 18:47
Rdio crash report
Process: Rdio [32512]
Path: /Applications/Rdio.app/Contents/MacOS/Rdio
Identifier: com.rdio.desktop
Version: 2.25 (2.25)
Code Type: X86 (Native)
Parent Process: launchd [396]
Responsible: Rdio [32512]
User ID: 501
Date/Time: 2014-01-17 10:45:54.737 -0800
@benjaminwood
benjaminwood / pricing.html.haml
Last active December 25, 2015 21:59
Boostrap 3, three tier pricing table (with fourth column for general details or buttons. Not completely finished, but a good starting point.
#pricing
.arrow-down
.container
.fancy-heading
%h2.heading Pricing
.center-block
.row
.col-md-3.option.tier_1
.header
%span.title Single
@benjaminwood
benjaminwood / liquid_filters.rb
Created September 10, 2013 16:27
Simple Locomotive CMS image resizing/cashing using (free) proxy service http://images.weserv.nl. Drop this file in your engine's config/initializers directory, restart your rails server and use the filter like this: {{ image_path | scaled_image_url: 'widthxheight' }} Example: {{ post.image.url | scaled_image_url: '1096x616' }}
module Locomotive
module Liquid
module Filters
module Text
# Create a url that will result in the given image
# being scaled and compressed by the specified amount
#
# For more info see: http://images.weserv.nl/
#