Skip to content

Instantly share code, notes, and snippets.

@iamvery
iamvery / jsonapi-deprecations.markdown
Last active November 15, 2019 07:43
Proposal for JSON API deprecation support

Proposal for http://jsonapi.org/ Deprecations

Purpose

One of the benefits of a hypermedia API is the ability to make changes to the response without breaking existing clients. Some types of change are handled for easily than others, e.g. renaming a resource and returning 301 Moved Permanently. However, if you were to rename an attribute or relationship your clients would not know where to find the new names. A common solution to this problem to adopt a policy of only adding attributes and relationships. Such a policy would prevent clients of loosing track of these values, but it comes at a price:

  1. more noise in your responses
.ipynb_checkpoints/
node_modules/
defmodule Power do
use Bitwise
def find(i) when i > 0 do
find(i, 1)
end
def find(i, p) when p < i do
find(i, p <<< 2)
end
module ServiceOne
def helper_one
puts "one"
end
end
module ServiceTwo
def helper_two
puts "two"
end
diff --git a/lib/money/money/arithmetic.rb b/lib/money/money/arithmetic.rb
index 38bc94e..19d6b79 100644
--- a/lib/money/money/arithmetic.rb
+++ b/lib/money/money/arithmetic.rb
@@ -125,10 +125,10 @@ class Money
[:+, :-].each do |op|
define_method(op) do |other|
unless other.is_a?(Money)
- if other.zero?
+ if other && other.zero?
@iamvery
iamvery / lambda-calculus.ipynb
Last active August 1, 2018 01:18
A little Jupyter notebook illustrating some basic lambda calculus with JavaScript :)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
defmodule PantsWeb.ChangesetView do
use PantsWeb, :view
@doc """
Traverses and translates changeset errors.
See `Ecto.Changeset.traverse_errors/2` and
`PantsWeb.ErrorHelpers.translate_error/1` for more details.
"""
def translate_errors(changeset) do
diff --git a/lib/pants_web/endpoint.ex b/lib/pants_web/endpoint.ex
index c24852a..a8ae2cf 100644
--- a/lib/pants_web/endpoint.ex
+++ b/lib/pants_web/endpoint.ex
@@ -45,7 +45,19 @@ defmodule PantsWeb.Endpoint do
signing_salt: "HqMY6W5G"
)
- plug(PantsWeb.Router)
+ def version(conn, []) do
quote do: {:a, :b, :c}
value = {:a, :b, :c}
Macro.escape(value)
quote do: value
value = {:a, :b, :c}
quote do: unquote(value)
{
"name": "frontier",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "~19.0.0",
"react-dom": "16.0.0-alpha.12",
"react-native-dotenv": "^0.1.0",
"react-native-scripts": "1.1.0",
"react-test-renderer": "16.0.0-alpha.12"