Skip to content

Instantly share code, notes, and snippets.

View JeffCohen's full-sized avatar

Jeff Cohen JeffCohen

View GitHub Profile
@JeffCohen
JeffCohen / mkmf.log
Created October 4, 2022 15:11
openssl log
$ cat /tmp/ruby-build.20220923165340.2544.hqIt35/ruby-3.1.2/ext/openssl/mkmf.log
=== OpenSSL for Ruby configurator ===
have_func: checking for rb_io_maybe_wait()... -------------------- yes
LD_LIBRARY_PATH=.:../.. "gcc -o conftest -I../../.ext/include/x86_64-linux -I../.././include -I../.././ext/openssl -I/home/deploy/.rbenv/versions/3.1.2/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef -fPIC conftest.c -L. -L../.. -L. -L/home/deploy/.rbenv/versions/3.1.2/lib -fstack-protector
@JeffCohen
JeffCohen / env
Created September 24, 2022 21:36
Jeff's env vars on Ubuntu 22.04.1
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus
HOME=/home/deploy
HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar
HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew
INFOPATH=/home/linuxbrew/.linuxbrew/share/info:
LANG=C.UTF-8
LC_TERMINAL=iTerm2
LC_TERMINAL_VERSION=3.4.16
LESSCLOSE=/usr/bin/lesspipe %s %s
@JeffCohen
JeffCohen / ruby-build.20220923165340.2544.log
Created September 24, 2022 21:14
Ubuntu 22.04.1 rbenv failure log when installing 3.1.2
/tmp/ruby-build.20220923165340.2544.hqIt35 ~
/tmp/ruby-build.20220923165340.2544.hqIt35/ruby-3.1.2 /tmp/ruby-build.20220923165340.2544.hqIt35 ~
checking for ruby... /home/deploy/.rbenv/shims/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking for ld... ld
@JeffCohen
JeffCohen / pluck.rb
Created March 24, 2019 16:47
Pluck values from a Ruby array of hashes, like ActiveRecord#pluck
class Array
def pluck(*args)
self.map { |item| args.map { |arg| item[arg] || item[arg.to_sym] || item[arg.to_s]}.flatten }
end
end
# Example:
# data = [ { "name" => "Cookie Monster", "color" => "blue", "id" => "1" },
# { "name" => "Kermit the Frog", "color" => "green", "id" => "2" }
# { "name" => "Big Bird", "color" => "blue", "id" => "3" }
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<h1>Hello!</h1>
<p>
@JeffCohen
JeffCohen / rails_changes.rb
Last active November 7, 2024 12:25
Generates a unified CHANGELOG.md for Rails releases.
# This script generates unified CHANGELOG output in Markdown
# of all Rails changes between two versions of Rails.
#
# By default, it shows the latest changes in the specified version only.
#
# You can also pass the "since earlier" version you're interested in.
#
# Usage: ruby rails_changes.rb {latest_version} [since_version]
#
# Examples:
# This is pseudocode. Adapted from https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem
#
# Currrent design:
#
# A producer places items into a queue.
# A consumer removes items from the queue.
#
# 1. If the queue becomes empty, the consumer sleeps; until woken up later.
# 2. If the queue becomes one-more-than-empty, the producer wakes up the consumer.
# 3. If the queue becomes full, the producer sleeps; until woken up later.
@JeffCohen
JeffCohen / models.yml
Created May 14, 2018 02:00
Code for Quiz #3
Product
sku: text
title: text
price: integer
Review
product_id: integer
rating: integer
content: text
@JeffCohen
JeffCohen / routes.rb
Last active May 15, 2018 18:16
Code for Quiz #3
Rails.application.routes.draw do
get "/" => 'products#index'
get "/products" => 'products#index'
get "/products/:id" => 'products#show'
get "/products/create" => 'products#create'
get "/reviews" => 'reviews#index'
get "/reviews/create" => 'reviews#create'
@JeffCohen
JeffCohen / watch.rb
Created April 24, 2018 00:30
Simple directory watcher
# To use this script:
# gem install listen
# gem install colorize
#
# then
#
# ruby watch.rb [path]
#
# [path] defaults to ".git"
#