Skip to content

Instantly share code, notes, and snippets.

bbuchalter / case_test.rb
Last active May 25, 2022
Ruby can only parse 2498 case statement branches
View case_test.rb
case_statements = 10000
program = <<-RUBY
#{ { |n| "when #{n+1} \n puts #{n+1}"}.join("\n")}
File.write('test.rb', program)
puts system('ruby test.rb')
bbuchalter / results.txt
Last active Oct 25, 2020
Are exceptions still slow in Ruby 2.7?
View results.txt
Warming up --------------------------------------
exception 74.658k i/100ms
break 588.320k i/100ms
return 551.993k i/100ms
Calculating -------------------------------------
exception 751.437k (±10.5%) i/s - 3.733M in 5.024957s
break 5.778M (± 1.2%) i/s - 29.416M in 5.091806s
return 5.444M (± 1.2%) i/s - 27.600M in 5.070550s
View check_oracle_tablespace.sql
SET pagesize 30
set linesize 300
column "Tablespace" format a13
column "Used MB" format 99,999,999
column "Free MB" format 99,999,999
column "Total MB" format 99,999,999
column "Tablespace path" format a50
ttitle center 'Application tablespace' skip 2
SELECT fs.tablespace_name "Tablespace",
(df.totalspace - fs.freespace) "Used MB",
bbuchalter / where_is.rb
Created Jan 26, 2020 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
View where_is.rb
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
def is_method(klass, method_name)


TILbot helps you reinforce what you learn. Get started by giving TILbot a question and answer, just like you were creating a flashcard. TILbot calls these TILcards. Congrats, this is your first act of learning reinforcement!

Your First TILcard

Let's say this is your first TILcard:

Question: What is the meaning of life, the universe and everything?

Answer: 42

bbuchalter / car.c
Created Mar 2, 2018
Infections, Hoare triples, and debugging by printouts
View car.c
public class Car {
Seat[] seats;
public int numEmptySeats() {
int count = 0;
int i;
// { count = 0 }
for(i = 0; i < this.seats.length; i++);
View meds.rb
# Given a file containing order line items in the form [User ID]: [Medications] where medications are separated by commas, determine the pairs of medications that appear most frequently together.
# For example:
# Given two line items
# Zestril, atorvastatin, Levoxine
# Zestril, atorvastatin, Orasone
# The function should output the pair Zestril, atorvastatin.
View string_calculator.rb
# Create a calculator that takes integers separated by the basic mathematical operators (+,-,*,/) and returns the result.
# You can use Ruby's mathamatical methods(+, -, *, /).
# The priority is on working code, not brevity.
# 7 + 2 - 3 / 4 * 5 = 5.25
#math_characters = '7 + 2 - 3 / 4 * 5'
# magic
View my_flatten.rb
require 'minitest/autorun'
class TestMyFlatten < Minitest::Test
def test_deeply_nested_arrays
assert_equal [1,2,3,4],[[1,2,[3]],4]).flatten
def test_argument_error
assert_raises ArgumentError do"not an array")
View bundleconfig
BUNDLE_GEM__COC: "false"
BUNDLE_PATH: "vendor/bundle"
BUNDLE_BUILD__EVENTMACHINE: "--with-cppflags=-I/usr/local/opt/openssl/include"
BUNDLE_GEM__MIT: "false"