This file contains 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
import { Controller } from "stimulus"; | |
export default class extends Controller { | |
static targets = ["field"]; | |
fetchOpportunities(query) { | |
const url = `/admin/salesforce.json?query=${query}`; | |
let csrf = document | |
.querySelector("meta[name='csrf-token']") | |
.getAttribute("content"); |
This file contains 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
import { Controller } from "@hotwired/stimulus"; | |
export default class extends Controller { | |
static values = { | |
maxallowed: Number, | |
}; | |
currencyFormatter(e) { | |
let value = e.target.value; |
This file contains 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
import { Controller } from "@hotwired/stimulus"; | |
export default class extends Controller { | |
static values = { | |
maxallowed: Number, | |
}; | |
currencyFormatter(e) { | |
let value = e.target.value; |
This file contains 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
<%# _inline_edit.html.erb %> | |
<% frame_id = dom_id(model, "#{attribute}_turbo_frame") %> | |
<%= form_with model: model, class: "contents", data: { turbo_frame: frame_id } do %> | |
<turbo-frame id="<%= frame_id %>" class="group inline-edit flex items-center"> | |
<%= link_to edit_polymorphic_path(model), class: "text-main mr-3" do %> | |
<i class="fa-solid fa-pen-to-square text-main text-xl"></i> | |
<% end %> | |
<%= yield %> | |
</turbo-frame> | |
<% end %> |
This file contains 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
# frozen_string_literal: true | |
# Plain Old Ruby Object | |
# Not backed by ActiveRecord | |
class RequestsClient | |
# client class | |
attr_reader :options, :adapter, :base_url | |
def initialize(base_url, options: {}, adapter: Faraday.default_adapter) |
This file contains 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
# frozen_string_literal: true | |
# Plain Old Ruby Object | |
# Not backed by ActiveRecord | |
class RequestsClient | |
# client class | |
attr_reader :options, :adapter, :base_url | |
def initialize(base_url, options: {}, adapter: Faraday.default_adapter) |
This file contains 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
# frozen_string_literal: true | |
# Monkey Patch string class | |
class String | |
def black | |
"\033[30m#{self}\033[0m" | |
end | |
def red | |
"\033[31m#{self}\033[0m" |
This file contains 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
AllCops: | |
TargetRubyVersion: 3.1.1 | |
require: standard | |
inherit_gem: | |
standard: config/base.yml |
This file contains 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
def binary_search(ordered_array, search_value) | |
lower_bound = 0 | |
upper_bound = ordered_array.length - 1 | |
while lower_bound <= upper_bound do | |
midpoint = (lower_bound + upper_bound) / 2 | |
value_at_midpoint = ordered_array[midpoint] |
This file contains 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
def linear_search(sorted_array, search_value) | |
sorted_array.each_with_index do |element, index| | |
if element == search_value | |
return index | |
elsif element > search_value | |
break | |
end | |
end | |
nil | |
end |