Skip to content

Instantly share code, notes, and snippets.

@bbuchalter
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
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)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
View README.md

TILbot

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
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], MyFlatten.new([[1,2,[3]],4]).flatten
end
def test_argument_error
assert_raises ArgumentError do
MyFlatten.new("not an array")
View bundleconfig
---
BUNDLE_GEM__COC: "false"
BUNDLE_GEM__TEST: "rspec"
BUNDLE_CONSOLE: "pry"
BUNDLE_JOBS: "4"
BUNDLE_DISABLE_LOCAL_BRANCH_CHECK: "true"
BUNDLE_PATH: "vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_BUILD__EVENTMACHINE: "--with-cppflags=-I/usr/local/opt/openssl/include"
BUNDLE_GEM__MIT: "false"
@bbuchalter
bbuchalter / bundle exec rake
Created Nov 15, 2016
solidus v1.2.2 bundle exec rake
View bundle exec rake
brian@Brians-MacBook-Pro:~/workspace/solidus(v1.2.2)% bundle exec rake
Generating dummy Rails application...
Setting up dummy database...
bundle exec rake db:drop db:create db:migrate
Skipping installation no generator to run...
Generating dummy Rails application...
Setting up dummy database...
bundle exec rake db:drop db:create db:migrate
Skipping installation no generator to run...
Generating dummy Rails application...