Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.
| # Adapted from http://json.schemastore.org/json-patch | |
| components: | |
| schemas: | |
| patchRequest: | |
| type: array | |
| items: | |
| oneOf: | |
| - additionalProperties: false | |
| required: |
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import { act } from 'react-dom/test-utils'; | |
| import App from './App'; | |
| jest.mock('@okta/okta-auth-js', () => { | |
| return { | |
| OktaAuth: jest.fn(() => { | |
| return { | |
| userAgent: 'okta/okta-auth-js', |
| # This snippet demonstrates Pythonic formatting and parsing of | |
| # ISO 8601 durations. | |
| # A little work is required to navigate between Python's | |
| # timedelta syntax and ISO 8601 duration syntax. | |
| import re | |
| from datetime import datetime | |
| from datetime import timedelta |
| import java.util.Arrays; | |
| import org.springframework.boot.web.client.RestTemplateBuilder; | |
| import org.springframework.cloud.client.loadbalancer.LoadBalanced; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.hateoas.MediaTypes; | |
| import org.springframework.hateoas.hal.Jackson2HalModule; | |
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |
| import org.springframework.web.client.RestTemplate; |
I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.
Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:
fetch("/api/foo")
.then( response => {
if (!response.ok) { throw response }
return response.json() //we only get here if there is no error
})
| import java.util.concurrent.atomic.AtomicReference | |
| import scala.util.{Failure, Success, Try} | |
| import com.typesafe.config.{Config, ConfigFactory} | |
| /** | |
| Use to tweak a Config without clearing and reloading a new config (for testing). | |
| @author dwalend | |
| */ | |
| class AtomicConfigSource(baseConfig:Config) { | |
| val atomicConfigRef = new AtomicReference[Config](ConfigFactory.empty()) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| /** | |
| * Scala hex / decimal binary calculator | |
| * (c) Mark Lister 2012 | |
| * Licence Apache 2. | |
| */ | |
| class BaseN(b: BigInt, val baseN: Int) extends BigInt(b.underlying) { | |
| def n(x: Int) = new BaseN(b, x) | |
| /** |
| <!doctype html> | |
| <!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]--> | |
| <!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]--> | |
| <!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]--> | |
| <!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#"> <!--<![endif]--> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| <meta name='description' content='{MetaDescription}'> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |