Skip to content

Instantly share code, notes, and snippets.

Richard Schneeman schneems

Block or report user

Report or block schneems

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 0_respond_to.rb
# 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
View vagrant.txt
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>
View String#split with block.rb
# 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 ") {
View capybara.rb
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)
View 0-failure
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: !
View gist:9733af3c17549e1f39d7c82bb98882e3
$ rails new myapp -d=postgresql
$ cd myapp/
$ git add .
$ git commit -m first
$ heroku create
$ git push heroku master
remote: -----> Ruby app detected
remote:
remote: !
remote: ! You must use Bundler 2 or greater with this lockfile.
View stacktrace.sh
~ $ rails c
/app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:18: [BUG] Segmentation fault at 0x0000000000001994
ruby 2.6.0dev (2018-11-25 schneems/bundler 65963) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0030 p:---- s:0171 e:000170 CFUNC :load_from_binary
c:0029 p:0014 s:0166 e:000165 METHOD /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:18 [FINISH]
c:0028 p:---- s:0160 e:000159 CFUNC :fetch
c:0027 p:0069 s:0153 e:000152 METHOD /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:37 [FINISH]
c:0026 p:---- s:0147 e:000146 CFUNC :require
View minitest.rb
require 'minitest/mock'
class Foo
def foo
bar
end
def bar
end
View return-bench.rb
def early_return(val)
return val if val
"nope"
end
def compare_if(val)
if val
val
else
View master.bench.txt
10.791165 0.612941 11.447048 ( 12.321773)
10.392580 0.607349 11.042279 ( 11.851726)
10.735180 0.595994 11.372614 ( 12.300327)
10.429255 0.607993 11.079885 ( 11.984101)
10.636112 0.618988 11.289580 ( 12.239277)
10.350005 0.593711 10.986309 ( 11.958930)
10.278313 0.582329 10.912143 ( 12.399119)
10.326966 0.571871 10.933312 ( 11.845198)
10.623241 0.612042 11.281695 ( 12.252219)
10.419475 0.606360 11.061647 ( 12.021191)
You can’t perform that action at this time.