Skip to content

Instantly share code, notes, and snippets.

@idlehands
idlehands / field_name_translations.ex
Created March 8, 2024 20:24
RFC: key for adding
assert_values_for(
expected: quote_request,
actual: quote,
fields: fields_for(OmniWeb.Schema.QuoteRequest),
field_name_translations: [
# explicit
origin_postal_code: [actual: :origin_zip],
destination_postal_code: [expected: :destination_zip, actual: :destination_zipcode],
# implicit
pieces: :freight_pieces, # assumes field is from expected and that this is on actual?
@idlehands
idlehands / assert_list_api_ideation.ex
Last active March 8, 2024 20:27
RFC: Ideation for using assert values to compare items in a list
# option 1 - new function
assert_values_for_in_list(
expected_list: {[thing_1, thing_1], :string_keys},
actual_list: return_value, # is list in all the examples
ordered: true,
fields: fields_for(Thing)
)
assert_values_for_in_list(
expected_list: [thing_2, thing_1],
@idlehands
idlehands / validate_schema_fields_and_types.ex
Created December 13, 2023 05:15
macro for validating ecto schema fields
defmacro validate_schema_fields_and_types(schema, expected_schemas_and_types) do
quote do
test "#{unquote(schema)}: it has the correct fields and types" do
schema = unquote(schema)
expected_schemas_and_types = unquote(expected_schemas_and_types)
actual_fields_with_types =
for field <- schema.__schema__(:fields) do
type = field_type(schema, field)
@idlehands
idlehands / 00_info.md
Last active May 20, 2023 11:44
Gig City Elixir - Test Data Generation
crowd sources replacements
voting
some form of accountability
can you see other things that person has suggested, what they've voted on?
some way to protect people from seeing offensive words (maybe some sort of first letter and then a blur or redaction)
in the future maybe allow people to identify minority groups they belong to
word
- reason it should go away
- replacement words
@idlehands
idlehands / 00_info.md
Last active May 20, 2023 11:28
-info and links
@idlehands
idlehands / my_info_and_links.md
Last active November 16, 2021 21:20
Effective Test Coverage - code and links
@idlehands
idlehands / stuff.sh
Last active October 25, 2018 17:29
Bash functions for happy life
# a log of these assume the exsistence of a branch called `utility`
# the code in `utility` doesn't have to be up to date
function reset_develop {
git checkout utility
git branch -D develop
git fetch
git checkout -b develop origin/develop
}

Keybase proof

I hereby claim:

  • I am idlehands on github.
  • I am idlehands303 (https://keybase.io/idlehands303) on keybase.
  • I have a public key whose fingerprint is 7E87 12E1 A24D A99F 9EB7 0B4E 482E 0B55 4C73 0F2E

To claim this, I am signing this object:

#!/usr/bin/env ruby
# by Andronik Ordian
# updated by Jeffrey Matthias
Segment = Struct.new("Segment", :start, :end)
def optimal_points(segments)
points = []
return points if segments.empty?
#write your code here