This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.development? | |
require 'langchain' | |
LLM_CLIENT ||= Langchain::LLM::OpenAI.new( | |
api_key: ENV.fetch('CHATGPT_API_KEY'), | |
default_options: { | |
temperature: 0.2, # Lower temperature for deterministic output | |
chat_model: 'gpt-4o' | |
} | |
) | |
Langchain.logger.level = Logger::DEBUG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# rubocop:disable all | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'numo-linalg' | |
gem 'rover-df' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clock = Data.define :hours, :minutes do | |
def initialize(hours:, minutes:) | |
super hours: (hours + minutes / 60) % 24, minutes: minutes % 60 | |
end | |
def add_minutes(minutes) = self.class.new(hours, self.minutes + minutes) | |
def to_s = '%02d:%02d' % [hours, minutes] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"stay": { | |
"check_in": "2014-07-08", | |
"check_out": "2014-07-09", | |
"participants": { | |
"0": { | |
"variant_id": "2", | |
"count": "2" | |
}, | |
"1": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Time.new(2022,11,6) + 3.hours | |
=> 2022-11-06 02:00:00 -0500 | |
> Time.new(2022,11,6) + 3.hours.in_days.days | |
=> 2022-11-06 02:00:00 -0500 | |
> Time.new(2022,11,6) + 24.hours.in_days.days | |
=> 2022-11-07 00:00:00 -0500 | |
> Time.zone.local(2022,11,6) + 3.hours | |
=> Sun, 06 Nov 2022 02:00:00 EST -05:00 | |
> Time.zone.local(2022,11,6) + 3.hours.in_days.days | |
=> Sun, 06 Nov 2022 03:00:00 EST -05:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* move middle part of top nav on the side */ | |
div[role="banner"] > div:nth-child(3) { | |
right: auto; | |
top: 70px; | |
} | |
/* remove extra padding from main nav */ | |
div[role="banner"] > div:nth-child(3) ul { | |
padding: 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://github.com/rails/rails/pull/31442 | |
require 'weakref' | |
module ActiveSupport | |
# This module provides an internal implementation to track descendants | |
# which is faster than iterating through ObjectSpace. | |
module DescendantsTracker | |
@@direct_descendants = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script is taken from https://github.com/rails/rails/issues/32892#issuecomment-423376552 | |
require 'ap' | |
require 'json' | |
require 'set' | |
require 'cgi' | |
require 'byebug' | |
class Slot | |
attr_reader :info, :address_to_slot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enumerable.module_eval do | |
def frequency | |
Hash.new(0).tap do |h| | |
each { |v| h[v] += 1 } | |
h.define_singleton_method(:highest) { sort_by(&:last).last.first } | |
h.define_singleton_method(:lowest) { sort_by(&:last).first.first } | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.class_eval do | |
def hierarch(n = 1) | |
klass_and_ancestry = self.class.ancestors[(n - 1)..-1] | |
klass, *ancestry = klass_and_ancestry | |
to_klass_methods = methods - ancestry.flat_map(&:instance_methods) | |
"#{klass}: #{to_klass_methods}" | |
end | |
end |
NewerOlder