14 Matching Annotations
- Sep 2023
-
stackoverflow.com stackoverflow.com
-
def self.make_lazy(*methods) methods.each do |method| define_method method do |*args, &block| lazy.public_send(method, *args, &block) end end end
-
- Sep 2022
-
blog.saeloun.com blog.saeloun.com
- Jan 2022
-
-
const originalUnhandledRejection = window.onunhandledrejection; window.onunhandledrejection = (e) => { console.log('we got exception, but the app has crashed', e); // or do Sentry.captureException(e); originalUnhandledRejection(e); }
Tags
Annotators
URL
-
- Oct 2021
-
-
const fetchWithJSONHeaders = applyDefaults(fetch, { headers: { "Content-Type": "application/json" } }); const fetchWithTextHeaders = applyDefaults(fetch, { headers: { "Content-Type": "application/text" } }); // Fetch JSON content const response = await fetchWithJSONHeaders("/users", { method: "GET" });
-
-
trackjs.com trackjs.com
-
But there is a lot of things we didn’t handle: How do we pass function arguments through? How do we maintain scope (the value of this)? How do we get the return value? What if an error happens?
-
-
stackoverflow.com stackoverflow.com
-
A wrapper function is a design concept where a very minimal function is using another function to do it's "work" for it, sometimes using a slightly different set of arguments.
-
- May 2021
-
github.com github.com
-
fetch: fetcher
Personally, I don't like how the local/custom/wrapper version of
fetch
is calledfetcher
. I feel like{prefix}_fetch
orfetch_{prefix}
would have been better.
-
-
kit.svelte.dev kit.svelte.dev
-
This function runs on every request, for both pages and endpoints, and determines the response. It receives the request object and a function called resolve, which invokes SvelteKit's router and generates a response accordingly.
-
- Feb 2021
-
github.com github.com
-
# Set the model name to change the field names generated by the Rails form helpers def self.model_name=(name) @_model_name = ActiveModel::Name.new(self, nil, name) end
-
-
github.com github.com
-
def self.attribute(name, type = ActiveModel::Type::Value.new, **options) super attribute_type = attribute_types[name.to_s] # Add the ? method for boolean attributes alias_boolean(name) if attribute_type.is_a?(ActiveModel::Type::Boolean) # store date attribute names so we can merge the params during # initialization date_attributes << name if attribute_type.class.in?(DATE_TYPES) end
-
- Nov 2020
-
stackoverflow.com stackoverflow.com
-
I have created a thin wrapper around fetch() with many improvements if you are using a purely json REST API:
-
-
github.com github.com
-
// Rewrite submit function form.submit = () => { const result = originalSubmit.call(form)
-
- Jun 2020
-
myronmars.to myronmars.to
-
return super(scope, &block) unless scope == :all
-