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
f = -> x { x + 2 } | |
g = -> x { x * 2 } | |
# h is the composition of f and g | |
h = f >> g | |
# h is the same as -> x { (x + 2) * 2 } | |
[1, 2, 3].map(&h) # => [6, 8, 10] | |
# This is exactly the same as | |
[1, 2, 3].map(&f).map(&g) # => [6, 8, 10] |
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
fetch_transactions = | |
ApiClient.new(api_token).method(:get) | |
>> JSON.method(:parse) | |
>> (-> response { response['data']['transactions'] }) | |
fetch_transaction.call('/api/current_user/transactions') |
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
f = -> x { x + 2 } | |
g = -> x { x * 2 } | |
# h is the composition of g and f | |
h = f << g | |
# h is the same as -> x { (x * 2) + 2 } | |
[1, 2, 3].map(&h) # => [4, 6, 8] | |
# This is exactly the same as | |
[1, 2, 3].map(&g).map(&f) # => [4, 6, 8] |
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
require 'net/http' | |
require 'uri' | |
require 'json' | |
fetch = | |
self.method(:URI) \ | |
>> Net::HTTP.method(:get) \ | |
>> JSON.method(:parse) \ | |
>> -> response { response.dig('bpi', 'EUR', 'rate') || '0' } \ | |
>> -> value { value.gsub(',', '') } \ |
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
# Copyright 2018 Stanko K.R. <[email protected]> | |
# | |
# Permission is hereby granted, free of charge, to any | |
# person obtaining a copy of this software and associated | |
# documentation files (the "Software"), to deal in the | |
# Software without restriction, including without limitation | |
# the rights to use, copy, modify, merge, publish, distribute, | |
# sublicense, and/or sell copies of the Software, and to permit | |
# persons to whom the Software is furnished to do so, subject | |
# to the following conditions: |
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 code is license under the MIT license | |
# Full text: https://opensource.org/licenses/MIT | |
# Author Stanko K.R. <[email protected]> | |
# Usage: | |
# ```ruby | |
# user.avatar = S3UrlToShrineObjectConverter.call( | |
# arguments[:input][:avatar][:url], | |
# name: arguments[:input][:avatar][:filename] | |
# ) |
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
mutation SetAvatar($url: String, $filename: String) { | |
updateUser( | |
id: "some_user_uuid" | |
input: { | |
avatar: { | |
filename: $filename | |
url: $url | |
} | |
} | |
) { |
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
mutation SetAvatar($data: String, $filename: String) { | |
updateUser( | |
id: "some_user_uuid" | |
input: { | |
avatar: { | |
filename: $filename | |
data: $data | |
} | |
} | |
) { |
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
user.avatar_data_uri = arguments[:input][:avatar][:data] | |
user.save |
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
mutation UploadGalleryImages { | |
uploadGalleryImages( | |
galleryID: "some_gallery_id" | |
images: [null, null] | |
) { | |
id | |
filename | |
url | |
} | |
} |