Skip to content

Instantly share code, notes, and snippets.

View schneems's full-sized avatar

Richard Schneeman schneems

View GitHub Profile
class Add
attr_reader :result, :is_negative
def initialize(a, b)
@result = a + b
@is_negative = @result < 0
end
end
def add(a,b)
class PriorityQueue
attr_reader :elements
def initialize
@elements = []
end
def <<(element)
~ $ gem install mysql2
Fetching mysql2-0.5.3.gem
Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    current directory: /app/vendor/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2
/app/vendor/ruby-2.6.5/bin/ruby -I /app/vendor/ruby-2.6.5/lib/ruby/2.6.0 -r ./siteconf20200417-12-1lo3zcx.rb extconf.rb
checking for rb_absint_size()... yes
$ time curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 -I https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.4.0.tgz
# => real 0m0.117s
$ cat <<EOF | ruby
  require 'net/http'
  require 'benchmark'
$ docker run -it --rm ruby:2.6 bash
root@22e145f8dfa6:/# gem install rails
Fetching concurrent-ruby-1.1.5.gem
Fetching thread_safe-0.3.6.gem
Fetching activesupport-5.2.3.gem
Fetching crass-1.0.4.gem
Fetching i18n-1.6.0.gem
Fetching tzinfo-1.2.5.gem
Fetching rack-2.0.7.gem
Fetching rack-test-1.1.0.gem
# frozen_string_literal: true
require "active_record"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name, :email, :username, :password, :birthday, :foo, :bar, :baz, :dog_name
t.timestamps null: false
default: Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages
default: Downloading/unpacking pandas
default: Running setup.py (path:/tmp/pip_build_root/pandas/setup.py) egg_info for package pandas
default: /tmp/easy_install-y78IR5/numpy-1.16.1/setup.py:390: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
default: run_build = parse_setuppy_commands()
default: /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
default: warnings.warn(msg)
default: Traceback (most recent call last):
default: File "<string>", line 17, in <module>
default: File "/tmp/pip_build_root/pandas/setup.py", line 743, in <module>
# Ruby 2.6 introduced String#split that allows it to take a block instead of just returning an array
# https://twitter.com/schneems/status/1078848803694882817
require 'benchmark/ips'
STRANG = "hello/there/hi/how/are/you/today".freeze
Benchmark.ips do |x|
x.report("normal") { first_strang = STRANG.split("/".freeze).first }
x.report("new ") {
require 'capybara'
Capybara.register_driver :selenium_chrome_headless_no_scroll do |app|
Capybara::Selenium::Driver.load_selenium
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--disable-gpu' if Gem.win_platform?
browser_options.args << '--hide-scrollbars'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
remote: ! Could not find bundler (>= 0.a) amongst [actionmailer-3.2.11, actionpack-3.2.11, activemodel-3.2.11, activerecord-3.2.11, activeresource-3.2.11, activesupport-3.2.11, arel-3.0.2, builder-3.0.4, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.4.0, erubis-2.7.0, execjs-1.4.0, hike-1.2.1, i18n-0.6.1, journey-1.0.4, jquery-rails-2.2.0, json-1.7.6, mail-2.4.4, mime-types-1.19, multi_json-1.5.0, pg-0.14.1, polyglot-0.3.3, rack-1.4.4, rack-cache-1.2, rack-ssl-1.3.2, rack-test-0.6.2, rails-3.2.11, railties-3.2.11, rake-10.0.3, rdoc-3.12, sass-3.2.5, sass-rails-3.2.6, sprockets-2.2.2, thor-0.16.0, tilt-1.3.3, treetop-1.4.12, tzinfo-0.3.35, uglifier-1.3.0]
remote: !