and Bank of England warns of sharpest recession on record By www.bbc.co.uk Published On :: Thu, 07 May 2020 15:19:06 GMT Bank head Andrew Bailey tells the BBC there will be no quick return to normality after the hit to jobs and income. Full Article
and Coronavirus: 'Up to 2,000' UK seafarers stranded By www.bbc.co.uk Published On :: Sat, 09 May 2020 00:01:09 GMT Mental health problems are growing and ship workers see "no end" to their ordeal, a union warns. Full Article
and Coronavirus: Six money-saving ideas for lockdown and beyond By www.bbc.co.uk Published On :: Fri, 08 May 2020 21:28:36 GMT Millions of people are facing pay cuts or less work, so how can you make your money go further? Full Article
and Coronavirus: Compulsory vaccines in the UK and other rumours fact-checked By www.bbc.co.uk Published On :: Fri, 08 May 2020 23:37:28 GMT A round-up of what's been debunked includes rumours about mandatory coronavirus vaccines and patents. Full Article
and 'I feel fresher and healthier' - Hamilton enjoying parts of F1 break By www.bbc.co.uk Published On :: Sat, 09 May 2020 13:17:54 GMT Mercedes driver Lewis Hamilton says he feels certain benefits from his enforced time away from Formula 1. Full Article
and How Florian Schneider and Kraftwerk influenced five decades of music By www.bbc.co.uk Published On :: Wed, 06 May 2020 17:39:52 GMT The band's influence can be heard in everything from art-rock and hip-hop to trance and house. Full Article
and Dateci Voce: Italian women demand voice in Covid-19 fight By www.bbc.co.uk Published On :: Fri, 08 May 2020 12:04:59 GMT Women post selfies demanding more representation in official bodies dealing with Covid-19. Full Article
and Coronavirus: Belarus WW2 parade defies pandemic and upstages Putin By www.bbc.co.uk Published On :: Sat, 09 May 2020 11:04:00 GMT Belarus goes ahead with a Victory Day parade but in Russia coronavirus forced its cancellation. Full Article
and Coronavirus: How they tried to curb Spanish flu pandemic in 1918 By www.bbc.co.uk Published On :: Thu, 07 May 2020 23:24:18 GMT Face masks, fresh air and porridge - how people tried to curb a deadly flu pandemic in 1918. Full Article
and The flamboyant life of 'King and Queen of rock 'n' roll' By www.bbc.co.uk Published On :: Sat, 09 May 2020 14:40:57 GMT The self-styled "king and queen of rock 'n' roll" - who inspired Elvis and The Beatles - dies at 87. Full Article
and Coronavirus: Andy Serkis reads entire Hobbit live online for charity By www.bbc.co.uk Published On :: Sat, 09 May 2020 13:35:59 GMT More than 650,000 watch the Gollum actor narrate Tolkien's fantasy classic in one 11-hour sitting. Full Article
and Coronavirus: China offers to help North Korea fight pandemic By www.bbc.co.uk Published On :: Sat, 09 May 2020 09:55:51 GMT President Xi Jinping expresses concern about the threat to its neighbour, and offers to help. Full Article
and Coronavirus: How does contact tracing work and is my data safe? By www.bbc.co.uk Published On :: Wed, 06 May 2020 14:59:55 GMT Millions in the UK will soon be asked to download an app that helps to limit coronavirus spreading. Full Article
and Robot offers help to human co-workers and other tech stories By www.bbc.co.uk Published On :: Fri, 08 May 2020 05:55:57 GMT BBC Click's Jen Copestake looks at some of the best of the week's technology stories. Full Article
and Facebook update crashes TikTok and other rivals By www.bbc.co.uk Published On :: Thu, 07 May 2020 11:10:53 GMT The social network apologised after a software update affects several popular apps on iPhones. Full Article
and Coronavirus: Scam sites selling masks and fake cures taken down By www.bbc.co.uk Published On :: Thu, 07 May 2020 18:19:56 GMT More than 160,000 suspicious emails have been reported to a new scam-busting service in two weeks. Full Article
and Facebook and Google extend working from home to end of year By www.bbc.co.uk Published On :: Fri, 08 May 2020 04:25:52 GMT The tech giants plan to re-open offices soon but will allow staff to work remotely throughout 2020. Full Article
and Coronavirus: 'Plandemic' virus conspiracy video spreads across social media By www.bbc.co.uk Published On :: Fri, 08 May 2020 11:26:57 GMT A slickly-produced "documentary" has exploded across social media, peddling medical misinformation. Full Article
and TileDB 2.0, Scylla 4.0, and CockroachDB raises extra funds By dbweekly.com Published On :: Fri, 8 May 2020 00:00:00 +0000 #303 — May 8, 2020 Read on the Web Database Weekly Introducing Scylla Open Source 4.0 — Scylla (a Cassandra-compatible NoSQL data store aiming to be the “world’s fastest column-store database”) now provides production-ready lightweight Transactions (LWT), a DynamoDB-compatible API (Alternator), and operator for Kubernetes, and more. Dor Laor The Best Medium-Hard Data Analyst SQL Interview Questions — This article begins with a quote: “The first 70% of SQL is pretty straightforward but the remaining 30% can be pretty tricky.” True! This article focuses on the tricky ‘medium-hard’ area that few tutorials venture into. Zachary Thomas ????Live Coding: Guide to Grafana 101 - Getting Started with Alerts — Join us on May 20th to see how to use Grafana’s alerting functionality to get notified about anomalies in your data, dig into root causes, and respond to critical issues. Step-by-step demos + tips = cheaper, more flexible monitoring ✅. Timescale sponsor TileDB 2.0 and the Future of Data Science — TileDB is an embeddable storage engine focused on working with dense and sparse multi-dimensional arrays. It’s a C++ library with official Python, R, Java and Go integrations, but it can integrate with other database systems too. 2.0 introduces dataframe support, a new API for R, and support for Google Cloud Storage and Azure Blob Storage. Stavros Papadopoulos Time-Series Compression Algorithms, Explained — Delta-delta encoding, Simple-8b, XOR-based compression, and more - these algorithms aren’t magic, but combined they can save over 90% of storage costs and speed up queries. Here’s how they work. Joshua Lockerman and Ajay Kulkarni CockroachDB Creators Raise $87 Million of New Investment — Quite a raise and quite a valuation in these times for the creators of CockroachDB, a popular distributed SQL database. Cockroach Labs The Big Cloud Data Boom Gets Even Bigger, Thanks to COVID-19? — It’s not like the cloud was doing badly beforehand, but the pandemic is apparently encouraging companies to virtualize as much of their operations as possible. Datanami MongoDB Is Easy. Now Make It Powerful. Free Download for 30 Days. — Using MongoDB Atlas? Studio 3T is the professional GUI and IDE that unlocks the power you need. Studio 3T sponsor Speeding Up count(*): Why Not Use max(id) - min(id)? — A warning tale in case you decide to take this shortcut. While you might be able to estimate or fudge a number that’s close, you can’t guarantee sequences will give you an exact, correct answer here. Hans-Jürgen Schönig Using AWS API Gateway to Run Database Queries — API Gateway is commonly used to hook up HTTP endpoints to AWS Lambda functions but did you know it can directly connect to DynamoDB? (Or any AWS service that lets you query over the AWS API, so not RDS.) Renato Byrro How to Remain Agile with DynamoDB — Amazon DynamoDB delivers performance at scale but at a cost to flexibility (particularly early on in the development cycle when your eventual access patterns aren’t always known) – there are some mitigations, however. Rob Cronin Jobs DevOps Engineer at X-Team (Remote) — Join X-Team and work on projects for companies like Riot Games, FOX, Coinbase, and more. Work from anywhere. X-Team Tooling pgModeler: A Postgres Database Modeler — An easy way to create and edit database models in a visual way. It’s packaged up as a paid product but is also open source so you can build your own. Raphael Araújo e Silva AvionDB: A Decentralised Database with MongoDB-like Developer Interface — An admittedloy ‘alpha stage’ database system built on top of OrbitDB, a serverless, peer-to-peer database that uses IFPS for storage and implements the core decentralized database logic/protocol. Dappkit mssql-cli, a CLI Tool to Manage SQL Server, Now on macOS and Linux — mssql-cli is a tool for working with SQL Server from the command line, complete with Intellisense, syntax highlighting, and paging. Alan Yu (Microsoft) Full Article
and Coronavirus and climate change a ‘double crisis’ By www.bbc.co.uk Published On :: Tue, 05 May 2020 23:09:38 GMT Many activists have had to stop their usual work due to the pandemic. Here's how they're responding. Full Article
and How the Covid-19 pandemic is threatening Africa’s wildlife By www.bbc.co.uk Published On :: Wed, 06 May 2020 23:24:20 GMT Park rangers in Africa say the closure of safari tourism is leading to an increase in poaching. Full Article
and ICYMI: Penguin chicks and new dining ideas By www.bbc.co.uk Published On :: Sat, 09 May 2020 10:43:24 GMT Some of the stories from around the world that you may have missed this week. Full Article
and Norfolk Island morepork owls: Major breakthrough for rare species By www.bbc.co.uk Published On :: Fri, 08 May 2020 16:06:21 GMT Two fledglings may have safeguarded the future of the Norfolk Island morepork owl. Full Article
and A panel on accessibility, design inclusion and ethics, hiring and retaining diverse talent, and landing a job in UX. By www.zeldman.com Published On :: Thu, 05 Dec 2019 15:00:29 +0000 It’s one thing to seek diverse talent to add to your team, another to retain the people you’ve hired. Why do so many folks we bring in to add depth and breadth of experience to our design and business decision-making process end up leaving? Hear thoughtful, useful answers to this question and other mysteries of […] The post A panel on accessibility, design inclusion and ethics, hiring and retaining diverse talent, and landing a job in UX. appeared first on Zeldman on Web & Interaction Design. Full Article Accessibility Diversity video
and React v16.9.0 and the Roadmap Update By reactjs.org Published On :: Thu, 08 Aug 2019 00:00:00 GMT Today we are releasing React 16.9. It contains several new features, bugfixes, and new deprecation warnings to help prepare for a future major release. New Deprecations Renaming Unsafe Lifecycle Methods Over a year ago, we announced that unsafe lifecycle methods are getting renamed: componentWillMount → UNSAFE_componentWillMount componentWillReceiveProps → UNSAFE_componentWillReceiveProps componentWillUpdate → UNSAFE_componentWillUpdate React 16.9 does not contain breaking changes, and the old names continue to work in this release. But you will now see a warning when using any of the old names: As the warning suggests, there are usually better approaches for each of the unsafe methods. However, maybe you don’t have the time to migrate or test these components. In that case, we recommend running a “codemod” script that renames them automatically: cd your_project npx react-codemod rename-unsafe-lifecycles (Note that it says npx, not npm. npx is a utility that comes with Node 6+ by default.) Running this codemod will replace the old names like componentWillMount with the new names like UNSAFE_componentWillMount: The new names like UNSAFE_componentWillMount will keep working in both React 16.9 and in React 17.x. However, the new UNSAFE_ prefix will help components with problematic patterns stand out during the code review and debugging sessions. (If you’d like, you can further discourage their use inside your app with the opt-in Strict Mode.) Note Learn more about our versioning policy and commitment to stability. Deprecating javascript: URLs URLs starting with javascript: are a dangerous attack surface because it’s easy to accidentally include unsanitized output in a tag like <a href> and create a security hole: const userProfile = { website: "javascript: alert('you got hacked')", }; // This will now warn: <a href={userProfile.website}>Profile</a> In React 16.9, this pattern continues to work, but it will log a warning. If you use javascript: URLs for logic, try to use React event handlers instead. (As a last resort, you can circumvent the protection with dangerouslySetInnerHTML, but it is highly discouraged and often leads to security holes.) In a future major release, React will throw an error if it encounters a javascript: URL. Deprecating “Factory” Components Before compiling JavaScript classes with Babel became popular, React had support for a “factory” component that returns an object with a render method: function FactoryComponent() { return { render() { return <div />; } } } This pattern is confusing because it looks too much like a function component — but it isn’t one. (A function component would just return the <div /> in the above example.) This pattern was almost never used in the wild, and supporting it causes React to be slightly larger and slower than necessary. So we are deprecating this pattern in 16.9 and logging a warning if it’s encountered. If you rely on it, adding FactoryComponent.prototype = React.Component.prototype can serve as a workaround. Alternatively, you can convert it to either a class or a function component. We don’t expect most codebases to be affected by this. New Features Async act() for Testing React 16.8 introduced a new testing utility called act() to help you write tests that better match the browser behavior. For example, multiple state updates inside a single act() get batched. This matches how React already works when handling real browser events, and helps prepare your components for the future in which React will batch updates more often. However, in 16.8 act() only supported synchronous functions. Sometimes, you might have seen a warning like this in a test but could not easily fix it: An update to SomeComponent inside a test was not wrapped in act(...). In React 16.9, act() also accepts asynchronous functions, and you can await its call: await act(async () => { // ... }); This solves the remaining cases where you couldn’t use act() before, such as when the state update was inside an asynchronous function. As a result, you should be able to fix all the remaining act() warnings in your tests now. We’ve heard there wasn’t enough information about how to write tests with act(). The new Testing Recipes guide describes common scenarios, and how act() can help you write good tests. These examples use vanilla DOM APIs, but you can also use React Testing Library to reduce the boilerplate code. Many of its methods already use act() internally. Please let us know on the issue tracker if you bump into any other scenarios where act() doesn’t work well for you, and we’ll try to help. Performance Measurements with <React.Profiler> In React 16.5, we introduced a new React Profiler for DevTools that helps find performance bottlenecks in your application. In React 16.9, we are also adding a programmatic way to gather measurements called <React.Profiler>. We expect that most smaller apps won’t use it, but it can be handy to track performance regressions over time in larger apps. The <Profiler> measures how often a React application renders and what the “cost” of rendering is. Its purpose is to help identify parts of an application that are slow and may benefit from optimizations such as memoization. A <Profiler> can be added anywhere in a React tree to measure the cost of rendering that part of the tree. It requires two props: an id (string) and an onRender callback (function) which React calls any time a component within the tree “commits” an update. render( <Profiler id="application" onRender={onRenderCallback}> <App> <Navigation {...props} /> <Main {...props} /> </App> </Profiler>); To learn more about the Profiler and the parameters passed to the onRender callback, check out the Profiler docs. Note: Profiling adds some additional overhead, so it is disabled in the production build. To opt into production profiling, React provides a special production build with profiling enabled. Read more about how to use this build at fb.me/react-profiling. Notable Bugfixes This release contains a few other notable improvements: A crash when calling findDOMNode() inside a <Suspense> tree has been fixed. A memory leak caused by retaining deleted subtrees has been fixed too. An infinite loop caused by setState in useEffect now logs an error. (This is similar to the error you see when you call setState in componentDidUpdate in a class.) We’re thankful to all the contributors who helped surface and fix these and other issues. You can find the full changelog below. An Update to the Roadmap In November 2018, we have posted this roadmap for the 16.x releases: A minor 16.x release with React Hooks (past estimate: Q1 2019) A minor 16.x release with Concurrent Mode (past estimate: Q2 2019) A minor 16.x release with Suspense for Data Fetching (past estimate: mid 2019) These estimates were too optimistic, and we’ve needed to adjust them. tldr: We shipped Hooks on time, but we’re regrouping Concurrent Mode and Suspense for Data Fetching into a single release that we intend to release later this year. In February, we shipped a stable 16.8 release including React Hooks, with React Native support coming a month later. However, we underestimated the follow-up work for this release, including the lint rules, developer tools, examples, and more documentation. This shifted the timeline by a few months. Now that React Hooks are rolled out, the work on Concurrent Mode and Suspense for Data Fetching is in full swing. The new Facebook website that’s currently in active development is built on top of these features. Testing them with real code helped discover and address many issues before they can affect the open source users. Some of these fixes involved an internal redesign of these features, which has also caused the timeline to slip. With this new understanding, here’s what we plan to do next. One Release Instead of Two Concurrent Mode and Suspense power the new Facebook website that’s in active development, so we are confident that they’re close to a stable state technically. We also now better understand the concrete steps before they are ready for open source adoption. Originally we thought we would split Concurrent Mode and Suspense for Data Fetching into two releases. We’ve found that this sequencing is confusing to explain because these features are more related than we thought at first. So we plan to release support for both Concurrent Mode and Suspense for Data Fetching in a single combined release instead. We don’t want to overpromise the release date again. Given that we rely on both of them in production code, we expect to provide a 16.x release with opt-in support for them this year. An Update on Data Fetching While React is not opinionated about how you fetch data, the first release of Suspense for Data Fetching will likely focus on integrating with opinionated data fetching libraries. For example, at Facebook we are using upcoming Relay APIs that integrate with Suspense. We will document how other opinionated libraries like Apollo can support a similar integration. In the first release, we don’t intend to focus on the ad-hoc “fire an HTTP request” solution we used in earlier demos (also known as “React Cache”). However, we expect that both we and the React community will be exploring that space in the months after the initial release. An Update on Server Rendering We have started the work on the new Suspense-capable server renderer, but we don’t expect it to be ready for the initial release of Concurrent Mode. This release will, however, provide a temporary solution that lets the existing server renderer emit HTML for Suspense fallbacks immediately, and then render their real content on the client. This is the solution we are currently using at Facebook ourselves until the streaming renderer is ready. Why Is It Taking So Long? We’ve shipped the individual pieces leading up to Concurrent Mode as they became stable, including new context API, lazy loading with Suspense, and Hooks. We are also eager to release the other missing parts, but trying them at scale is an important part of the process. The honest answer is that it just took more work than we expected when we started. As always, we appreciate your questions and feedback on Twitter and in our issue tracker. Installation React React v16.9.0 is available on the npm registry. To install React 16 with Yarn, run: yarn add react@^16.9.0 react-dom@^16.9.0 To install React 16 with npm, run: npm install --save react@^16.9.0 react-dom@^16.9.0 We also provide UMD builds of React via a CDN: <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> Refer to the documentation for detailed installation instructions. Changelog React Add <React.Profiler> API for gathering performance measurements programmatically. (@bvaughn in #15172) Remove unstable_ConcurrentMode in favor of unstable_createRoot. (@acdlite in #15532) React DOM Deprecate old names for the UNSAFE_* lifecycle methods. (@bvaughn in #15186 and @threepointone in #16103) Deprecate javascript: URLs as a common attack surface. (@sebmarkbage in #15047) Deprecate uncommon “module pattern” (factory) components. (@sebmarkbage in #15145) Add support for the disablePictureInPicture attribute on <video>. (@eek in #15334) Add support for onLoad event for <embed>. (@cherniavskii in #15614) Add support for editing useState state from DevTools. (@bvaughn in #14906) Add support for toggling Suspense from DevTools. (@gaearon in #15232) Warn when setState is called from useEffect, creating a loop. (@gaearon in #15180) Fix a memory leak. (@paulshen in #16115) Fix a crash inside findDOMNode for components wrapped in <Suspense>. (@acdlite in #15312) Fix pending effects from being flushed too late. (@acdlite in #15650) Fix incorrect argument order in a warning message. (@brickspert in #15345) Fix hiding Suspense fallback nodes when there is an !important style. (@acdlite in #15861 and #15882) Slightly improve hydration performance. (@bmeurer in #15998) React DOM Server Fix incorrect output for camelCase custom CSS property names. (@bedakb in #16167) React Test Utilities and Test Renderer Add act(async () => ...) for testing asynchronous state updates. (@threepointone in #14853) Add support for nesting act from different renderers. (@threepointone in #16039 and #16042) Warn in Strict Mode if effects are scheduled outside an act() call. (@threepointone in #15763 and #16041) Warn when using act from the wrong renderer. (@threepointone in #15756) Full Article
and Building Great User Experiences with Concurrent Mode and Suspense By reactjs.org Published On :: Wed, 06 Nov 2019 00:00:00 GMT At React Conf 2019 we announced an experimental release of React that supports Concurrent Mode and Suspense. In this post we’ll introduce best practices for using them that we’ve identified through the process of building the new facebook.com. This post will be most relevant to people working on data fetching libraries for React. It shows how to best integrate them with Concurrent Mode and Suspense. The patterns introduced here are based on Relay — our library for building data-driven UIs with GraphQL. However, the ideas in this post apply to other GraphQL clients as well as libraries using REST or other approaches. This post is aimed at library authors. If you’re primarily an application developer, you might still find some interesting ideas here, but don’t feel like you have to read it in its entirety. Talk Videos If you prefer to watch videos, some of the ideas from this blog post have been referenced in several React Conf 2019 presentations: Data Fetching with Suspense in Relay by Joe Savona Building the New Facebook with React and Relay by Ashley Watkins React Conf Keynote by Yuzhi Zheng This post presents a deeper dive on implementing a data fetching library with Suspense. Putting User Experience First The React team and community has long placed a deserved emphasis on developer experience: ensuring that React has good error messages, focusing on components as a way to reason locally about app behavior, crafting APIs that are predictable and encourage correct usage by design, etc. But we haven’t provided enough guidance on the best ways to achieve a great user experience in large apps. For example, the React team has focused on framework performance and providing tools for developers to debug and tune application performance (e.g. React.memo). But we haven’t been as opinionated about the high-level patterns that make the difference between fast, fluid apps and slow, janky ones. We always want to ensure that React remains approachable to new users and supports a variety of use-cases — not every app has to be “blazing” fast. But as a community we can and should aim high. We should make it as easy as possible to build apps that start fast and stay fast, even as they grow in complexity, for users on varying devices and networks around the world. Concurrent Mode and Suspense are experimental features that can help developers achieve this goal. We first introduced them at JSConf Iceland in 2018, intentionally sharing details very early to give the community time to digest the new concepts and to set the stage for subsequent changes. Since then we’ve completed related work, such as the new Context API and the introduction of Hooks, which are designed in part to help developers naturally write code that is more compatible with Concurrent Mode. But we didn’t want to implement these features and release them without validating that they work. So over the past year, the React, Relay, web infrastructure, and product teams at Facebook have all collaborated closely to build a new version of facebook.com that deeply integrates Concurrent Mode and Suspense to create an experience with a more fluid and app-like feel. Thanks to this project, we’re more confident than ever that Concurrent Mode and Suspense can make it easier to deliver great, fast user experiences. But doing so requires rethinking how we approach loading code and data for our apps. Effectively all of the data-fetching on the new facebook.com is powered by Relay Hooks — new Hooks-based Relay APIs that integrate with Concurrent Mode and Suspense out of the box. Relay Hooks — and GraphQL — won’t be for everyone, and that’s ok! Through our work on these APIs we’ve identified a set of more general patterns for using Suspense. Even if Relay isn’t the right fit for you, we think the key patterns we’ve introduced with Relay Hooks can be adapted to other frameworks. Best Practices for Suspense It’s tempting to focus only on the total startup time for an app — but it turns out that users’ perception of performance is determined by more than the absolute loading time. For example, when comparing two apps with the same absolute startup time, our research shows that users will generally perceive the one with fewer intermediate loading states and fewer layout changes as having loaded faster. Suspense is a powerful tool for carefully orchestrating an elegant loading sequence with a few, well-defined states that progressively reveal content. But improving perceived performance only goes so far — our apps still shouldn’t take forever to fetch all of their code, data, images, and other assets. The traditional approach to loading data in React apps involves what we refer to as “fetch-on-render”. First we render a component with a spinner, then fetch data on mount (componentDidMount or useEffect), and finally update to render the resulting data. It’s certainly possible to use this pattern with Suspense: instead of initially rendering a placeholder itself, a component can “suspend” — indicate to React that it isn’t ready yet. This will tell React to find the nearest ancestor <Suspense fallback={<Placeholder/>}>, and render its fallback instead. If you watched earlier Suspense demos this example may feel familiar — it’s how we originally imagined using Suspense for data-fetching. It turns out that this approach has some limitations. Consider a page that shows a social media post by a user, along with comments on that post. That might be structured as a <Post> component that renders both the post body and a <CommentList> to show the comments. Using the fetch-on-render approach described above to implement this could cause sequential round trips (sometimes referred to as a “waterfall”). First the data for the <Post> component would be fetched and then the data for <CommentList> would be fetched, increasing the time it takes to show the full page. There’s also another often-overlooked downside to this approach. If <Post> eagerly requires (or imports) the <CommentList> component, our app will have to wait to show the post body while the code for the comments is downloading. We could lazily load <CommentList>, but then that would delay fetching comments data and increase the time to show the full page. How do we resolve this problem without compromising on the user experience? Render As You Fetch The fetch-on-render approach is widely used by React apps today and can certainly be used to create great apps. But can we do even better? Let’s step back and consider our goal. In the above <Post> example, we’d ideally show the more important content — the post body — as early as possible, without negatively impacting the time to show the full page (including comments). Let’s consider the key constraints on any solution and look at how we can achieve them: Showing the more important content (the post body) as early as possible means that we need to load the code and data for the view incrementally. We don’t want to block showing the post body on the code for <CommentList> being downloaded, for example. At the same time we don’t want to increase the time to show the full page including comments. So we need to start loading the code and data for the comments as soon as possible, ideally in parallel with loading the post body. This might sound difficult to achieve — but these constraints are actually incredibly helpful. They rule out a large number of approaches and spell out a solution for us. This brings us to the key patterns we’ve implemented in Relay Hooks, and that can be adapted to other data-fetching libraries. We’ll look at each one in turn and then see how they add up to achieve our goal of fast, delightful loading experiences: Parallel data and view trees Fetch in event handlers Load data incrementally Treat code like data Parallel Data and View Trees One of the most appealing things about the fetch-on-render pattern is that it colocates what data a component needs with how to render that data. This colocation is great — an example of how it makes sense to group code by concerns and not by technologies. All the issues we saw above were due to when we fetch data in this approach: upon rendering. We need to be able to fetch data before we’ve rendered the component. The only way to achieve that is by extracting the data dependencies into parallel data and view trees. Here’s how that works in Relay Hooks. Continuing our example of a social media post with body and comments, here’s how we might define it with Relay Hooks: // Post.js function Post(props) { // Given a reference to some post - `props.post` - *what* data // do we need about that post? const postData = useFragment(graphql` fragment PostData on Post @refetchable(queryName: "PostQuery") { author title # ... more fields ... } `, props.post); // Now that we have the data, how do we render it? return ( <div> <h1>{postData.title}</h1> <h2>by {postData.author}</h2> {/* more fields */} </div> ); } Although the GraphQL is written within the component, Relay has a build step (Relay Compiler) that extracts these data-dependencies into separate files and aggregates the GraphQL for each view into a single query. So we get the benefit of colocating concerns, while at runtime having parallel data and view trees. Other frameworks could achieve a similar effect by allowing developers to define data-fetching logic in a sibling file (maybe Post.data.js), or perhaps integrate with a bundler to allow defining data dependencies with UI code and automatically extracting it, similar to Relay Compiler. The key is that regardless of the technology we’re using to load our data — GraphQL, REST, etc — we can separate what data to load from how and when to actually load it. But once we do that, how and when do we fetch our data? Fetch in Event Handlers Imagine that we’re about to navigate from a list of a user’s posts to the page for a specific post. We’ll need to download the code for that page — Post.js — and also fetch its data. Waiting until we render the component has problems as we saw above. The key is to start fetching code and data for a new view in the same event handler that triggers showing that view. We can either fetch the data within our router — if our router supports preloading data for routes — or in the click event on the link that triggered the navigation. It turns out that the React Router folks are already hard at work on building APIs to support preloading data for routes. But other routing frameworks can implement this idea too. Conceptually, we want every route definition to include two things: what component to render and what data to preload, as a function of the route/url params. Here’s what such a route definition might look like. This example is loosely inspired by React Router’s route definitions and is primarily intended to demonstrate the concept, not a specific API: // PostRoute.js (GraphQL version) // Relay generated query for loading Post data import PostQuery from './__generated__/PostQuery.graphql'; const PostRoute = { // a matching expression for which paths to handle path: '/post/:id', // what component to render for this route component: React.lazy(() => import('./Post')), // data to load for this route, as function of the route // parameters prepare: routeParams => { // Relay extracts queries from components, allowing us to reference // the data dependencies -- data tree -- from outside. const postData = preloadQuery(PostQuery, { postId: routeParams.id, }); return { postData }; }, }; export default PostRoute; Given such a definition, a router can: Match a URL to a route definition. Call the prepare() function to start loading that route’s data. Note that prepare() is synchronous — we don’t wait for the data to be ready, since we want to start rendering more important parts of the view (like the post body) as quickly as possible. Pass the preloaded data to the component. If the component is ready — the React.lazy dynamic import has completed — the component will render and try to access its data. If not, React.lazy will suspend until the code is ready. This approach can be generalized to other data-fetching solutions. An app that uses REST might define a route like this: // PostRoute.js (REST version) // Manually written logic for loading the data for the component import PostData from './Post.data'; const PostRoute = { // a matching expression for which paths to handle path: '/post/:id', // what component to render for this route component: React.lazy(() => import('./Post')), // data to load for this route, as function of the route // parameters prepare: routeParams => { const postData = preloadRestEndpoint( PostData.endpointUrl, { postId: routeParams.id, }, ); return { postData }; }, }; export default PostRoute; This same approach can be employed not just for routing, but in other places where we show content lazily or based on user interaction. For example, a tab component could eagerly load the first tab’s code and data, and then use the same pattern as above to load the code and data for other tabs in the tab-change event handler. A component that displays a modal could preload the code and data for the modal in the click handler that triggers opening the modal, and so on. Once we’ve implemented the ability to start loading code and data for a view independently, we have the option to go one step further. Consider a <Link to={path} /> component that links to a route. If the user hovers over that link, there’s a reasonable chance they’ll click it. And if they press the mouse down, there’s an even better chance that they’ll complete the click. If we can load code and data for a view after the user clicks, we can also start that work before they click, getting a head start on preparing the view. Best of all, we can centralize that logic in a few key places — a router or core UI components — and get any performance benefits automatically throughout our app. Of course preloading isn’t always beneficial. It’s something an application would tune based on the user’s device or network speed to avoid eating up user’s data plans. But the pattern here makes it easier to centralize the implementation of preloading and the decision of whether to enable it or not. Load Data Incrementally The above patterns — parallel data/view trees and fetching in event handlers — let us start loading all the data for a view earlier. But we still want to be able to show more important parts of the view without waiting for all of our data. At Facebook we’ve implemented support for this in GraphQL and Relay in the form of some new GraphQL directives (annotations that affect how/when data is delivered, but not what data). These new directives, called @defer and @stream, allow us to retrieve data incrementally. For example, consider our <Post> component from above. We want to show the body without waiting for the comments to be ready. We can achieve this with @defer and <Suspense>: // Post.js function Post(props) { const postData = useFragment(graphql` fragment PostData on Post { author title # fetch data for the comments, but don't block on it being ready ...CommentList @defer } `, props.post); return ( <div> <h1>{postData.title}</h1> <h2>by {postData.author}</h2> {/* @defer pairs naturally with <Suspense> to make the UI non-blocking too */} <Suspense fallback={<Spinner/>}> <CommentList post={postData} /> </Suspense> </div> ); } Here, our GraphQL server will stream back the results, first returning the author and title fields and then returning the comment data when it’s ready. We wrap <CommentList> in a <Suspense> boundary so that we can render the post body before <CommentList> and its data are ready. This same pattern can be applied to other frameworks as well. For example, apps that call a REST API might make parallel requests to fetch the body and comments data for a post to avoid blocking on all the data being ready. Treat Code Like Data But there’s one thing that’s still missing. We’ve shown how to preload data for a route — but what about code? The example above cheated a bit and used React.lazy. However, React.lazy is, as the name implies, lazy. It won’t start downloading code until the lazy component is actually rendered — it’s “fetch-on-render” for code! To solve this, the React team is considering APIs that would allow bundle splitting and eager preloading for code as well. That would allow a user to pass some form of lazy component to a router, and for the router to trigger loading the code alongside its data as early as possible. Putting It All Together To recap, achieving a great loading experience means that we need to start loading code and data as early as possible, but without waiting for all of it to be ready. Parallel data and view trees allow us to load the data for a view in parallel with loading the view (code) itself. Fetching in an event handler means we can start loading data as early as possible, and even optimistically preload a view when we have enough confidence that a user will navigate to it. Loading data incrementally allows us to load important data earlier without delaying the fetching of less important data. And treating code as data — and preloading it with similar APIs — allows us to load it earlier too. Using These Patterns These patterns aren’t just ideas — we’ve implemented them in Relay Hooks and are using them in production throughout the new facebook.com (which is currently in beta testing). If you’re interested in using or learning more about these patterns, here are some resources: The React Concurrent docs explore how to use Concurrent Mode and Suspense and go into more detail about many of these patterns. It’s a great resource to learn more about the APIs and use-cases they support. The experimental release of Relay Hooks implements the patterns described here. We’ve implemented two similar example apps that demonstrate these concepts: The Relay Hooks example app uses GitHub’s public GraphQL API to implement a simple issue tracker app. It includes nested route support with code and data preloading. The code is fully commented — we encourage cloning the repo, running the app locally, and exploring how it works. We also have a non-GraphQL version of the app that demonstrates how these concepts can be applied to other data-fetching libraries. While the APIs around Concurrent Mode and Suspense are still experimental, we’re confident that the ideas in this post are proven by practice. However, we understand that Relay and GraphQL aren’t the right fit for everyone. That’s ok! We’re actively exploring how to generalize these patterns to approaches such as REST, and are exploring ideas for a more generic (ie non-GraphQL) API for composing a tree of data dependencies. In the meantime, we’re excited to see what new libraries will emerge that implement the patterns described in this post to make it easier to build great, fast user experiences. Full Article
and Workloads, acceleration, and making Postgres better By postgresweekly.com Published On :: Wed, 29 Apr 2020 00:00:00 +0000 #353 — April 29, 2020 Read on the Web Postgres Weekly 7 Things That Could Be Improved in Postgres — As 1990s dance pop group D:Ream sang in 1994, Things Can Only Get Better.. including Postgres ???? Luckily these are all ‘nice to have’s but I dare say we’ll see some of them (such as automatic tuning and auto-vacuuming improvements) appear over time. Kaarel Moppel How The Citus Distributed Query Executor Adapts to a Postgres Workload — Citus is the popular extension for horizontally scaling Postgres and its query executor has seen some huge updates lately. Citus Data (Microsoft) eBook: The Most Important Events to Monitor in Your Postgres Logs — In this pganalyze eBook, we are looking at the Top 6 Postgres log events for monitoring query performance and preventing downtime. pganalyze sponsor Swarm64 DA 4.0: A Database Acceleration Extension for Postgres — Swarm64 started life as a FPGA-driven way to accelerate Postgres performance, but can now work without FPGAs too. This is not a free product but if you want to give it a run, there’s a trial or it can be spun up from the AWS Marketplace. Yana Krasteva Postgres Performance Goalposts — An interesting heuristic from Bruce here on what to do if you expect your connections, queries, or write queries to be above/below certain levels. Bruce Momjian A Tale of Password Authentication Methods in Postgres — “Let’s say you want to implement a password authentication method in a client/server protocol..” Here’s the story of how Postgres came up with its approaches. Peter Eisentraut How to Set application_name When Using psql — As Craig says: “Setting your application name in Postgres is SO USEFUL. It will help a lot for debugging when you’ve got multiple different apps/services connecting to the same database.” Denish Patel How to Upgrade Postgres from v11 to v12 on Ubuntu 20.04 — Now that Ubuntu 20.04 is out, this might be on your mind! Paolo Melchiorre Working with Amazon Aurora PostgreSQL: What Happened to the Stats? — Apparently there’s a bug with numerous versions of Aurora PostgreSQL that causes certain stats to be lost on restart. Michael Vitale Postgres Vision 2020 - Free Online Conference (June 23-24) — Learn how today’s IT leaders are using Postgres. Join from anywhere in the world and listen from 30+ Postgres experts. EnterpriseDB sponsor A Deep Dive into PostGIS Nearest Neighbor Search — Take a deep dive into the Postgres and PostGIS internals to find out how K-nearest neighbor accelerates local search. Martin Davis My Favorite Postgres Extensions: Part One — A basic high level look at pg_partman and postgres_fdw. Nawaz Ahmed Kanel: Generate TypeScript Types from Postgres Kristian Dupont Postgres.app: The Easiest Way to Get Started with Postgres on the Mac — I’ve used this for years, it’s super popular, but if there’s just a handful of developers out there who’d benefit from it and don’t know about it, this reminder will be worth it :-) It continues to get very frequent updates. Jakob Egger, Chris Pastl, and Mattt Thompson ???? Upcoming Events All in-person events we had listed are cancelled or postponed due to the COVID outbreak, so we're now linking to webinars, livestreams, and similar online events. If you have any, just hit reply and if it's Postgres related (and either free or not too expensive) we'll include it in a future issue. Just one this week: ???? Postgres Vision 2020 on June 23-24. A full attempt at an online Postgres conference across multiple days with multiple tracks. ???? – requires e-mail address or registration???? – costs money to participate Full Article
and Stimulus Reflex, and sending thanks to Matz By rubyweekly.com Published On :: Thu, 23 Apr 2020 00:00:00 +0000 #498 — April 23, 2020 Read on the Web Ruby Weekly Credit: Divina Epiphania / Shutterstock.com Mining for Malicious Ruby Gems: 700+ Gems Affected — Breathe easy as this was all resolved a month ago (and was too obscure to pay off for the hackers anyway) but a security research team recently found over 700 malicious Ruby gems that were subtle typos/adjustments of more popular gems (e.g. atlas-client vs atlas_client – could you tell which one is real?) Tomislav Maljic You Can Now Sponsor Matz on GitHub — I appreciate these are challenging times, but if you’ve ever wanted to give a big thank you to Matz, the creator of Ruby, here’s one way to do it. We’re sponsoring Matz now as without him, this newsletter wouldn’t exist! ???? Alternatively, if you have little to spare, maybe send him a thanks on Twitter? GitHub Sponsors Ruby Performance Tips — Here’s a collection of practical tips for improving Ruby performance for better user experiences, brought to you by Raygun. Read the tips here. Raygun sponsor Full Text Search in Milliseconds with Rails and Postgres — If you’ve never played with full text search with Postgres and Rails, this is a fine place to start. It covers LIKE/ILIKE, trigrams, and ‘proper’ full text searching. We also get to see how Leigh took a query from taking 130ms down to 7ms. Leigh Halliday ▶ Introduction to Stimulus Reflex — Stimiulus Reflex makes SPA-type interactions very simple by using ActionCable to render pages and then diffing them on the client. GoRails Rails Performance: When is Caching the Right Choice? — Before you say “always”, understand that caching is not free and, if done incorrectly, can even make things worse. Jonathan Miles ???? Jobs Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started. Vettery Ruby Backend Developer (Austria) — We’re seeking mid-level and senior devs to join us and build top-class backend infrastructure for our adidas apps, used by millions. Our stack includes: jRuby, Sinatra, Sidekiq, MySQL, & MongoDB. Runtastic ℹ️ Interested in running a job listing in Ruby Weekly? There's more info here. ???? Articles & Tutorials How to Customize Webpack in Rails Apps — How to go about configuring webpack when tweaking webpacker.yml just isn’t enough. Ross Kaffenberger RSpec Given/When/Then with Symbols — An interesting, alternative way to structure a BDD feature in RSpec. I think I prefer the underscores but YMMV. Caius Durling Looking Inside a Ruby Gem — Piotr decomposes a .gem file which turns out to just be a collection of gzipped and tarred files, only some of which are the code. Piotr Murach eBook: The Most Important Events to Monitor in Your Postgres Logs — In this eBook, you will learn about the Top 6 Postgres log events for monitoring query performance and preventing downtime. pganalyze sponsor Passing Rails Controller Params to Sidekiq — ActionController::Parameters can give Sidekiq issues. Prathamesh Sonpatki Catchup Subscriptions with Rails Event Store Miroslaw Praglowski Logic-less Ruby Templates with Mustache David Santangelo ▶ Discussing Ruby for Good with Sean Marcia — Sean talks about founding Ruby For Good (an event about philanthropic Ruby development) and some of the projects it has been responsible for creating. Ruby Rogues podcast ???? Code and Tools Impressionist 2.0: A Plugin to Log Impressions in Rails Apps — Impressionist tracks page views and impressions. v2.0 has just dropped but they’re also are looking for new maintainers, so contact them if you want to get involved. Charlotte Ruby Group acli 0.3: A Command Line Client for Action Cable — Interesting on two fronts.. first, because it’s an mruby app, and we don’t see many of those, and second, because it lets you play with Action Cable channels in any easier way. Vladimir Dementyev Undercover: A Tool to Stop You Shipping Untested Code — It’s like RuboCop but for code coverage rather than code style. Jan Grodowski How to Monitor Your Host Metrics Automatically AppSignal sponsor Bridgetown: A Modern Ruby (JAMstack) Web Framework — Bridgetown is a new Ruby-based static-site generator based on a fork of Jekyll. It supports plugins and Webpack, so you can use your front-end framework of choice. Bridgetown net-ssh 6.0: A Pure Ruby Implementation of the SSH2 Client Protocol — Yes, you can write programs that invoke and interact with processes on remote servers, via SSH2, all in Ruby. Buck, Fazekas, et al. Full Article
and A transpiler for futuristic Ruby, and the RailsConf 2020 videos By rubyweekly.com Published On :: Thu, 7 May 2020 00:00:00 +0000 #500 — May 7, 2020 Read on the Web ???? Welcome to issue 500! A bit of an arbitrary milestone but thanks to you all :-) Ruby Weekly Ruby Next: Make All Rubies Quack Alike — Ruby Next is a Ruby-to-Ruby transpiler that allows you to use the latest features of Ruby in previous versions without monkey patching or refinements. Could this be how experimental features are released going forward? Vladimir Dementyev Ruby 3 'Guilds' Proposal Now Called Ractor — This documentation is in Japanese (though the source code examples are easy to follow) but the news is that the new, proposed concurrency mechanism for Ruby 3 called Guilds (explained here) has been renamed to Ractor (as in ‘Ruby actors’, Ruby’s take on the actor model). Koichi Sasada Don’t Do Auth From Scratch. Focus On Your App — Spend less time on authentication and authorization and more time developing your awesome app. Auth built for <devs>. Download our community edition for free. FusionAuth sponsor Take the 2020 Ruby on Rails Survey — This is the sixth outing for Planet Argon’s survey which began in 2009. We try and support it each time as the results always make for interesting reading (see 2018’s results). Participate and become data ???? Planet Argon Team ???? RailsConf 2020 Videos If you recall, RailsConf 2020 was cancelled in its in-person form to be replaced by a 'couch edition'. This has been taking place and the videos have been released! Here are some of the highlights: DHH's keynote which takes the form of a chat between him and Evan Phoenix. Eileen Uchitelle digs deep on Rails' multi database support. (We interviewed her a few months ago too.) Building a Rails Controller From Scratch by Alex Kitchens digs into the interesting world of reimplementing ActionController with something of your own creation. Krystan HuffMenne takes us on a journey into the lifecycle of a response in Rails. It's worth understanding this stuff. Learn about using Sorbet to do static type checking in Rails with Hung Harry Doan. Aaron 'tenderlove' Patterson (who has just moved to Shopify) has a talk on, well, lots of bits and pieces in his usual style. If you want the full collection, here's the YouTube playlist. Alt::BrightonRuby: A Slightly Odd, Quasi-Conference for Strange Times — Alt::BrightonRuby is not happening in-person this year. Instead, you can buy the recorded talks, get a _why book, and get some podcasts with the speakers. Alt::BrightonRuby ???? Jobs Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started. Vettery Security Engineer (Remote) — Are you an engineer with experience in Rails and/or Go? Join our team and help secure our apps and cloud infrastructure. Shogun ℹ️ Interested in running a job listing in Ruby Weekly? There's more info here. ???? Articles & Tutorials ▶ How To Begin Contributing to a Gem — If you’ve been using a library for a while and you want to contribute back, how do you get started? A 12 minute introduction here. Drifting Ruby How to Set Up Factory Bot on a Fresh Rails Project — Factory Bot is a library for setting up Ruby objects as test data – an alternative to fixtures, essentially. Jason Swett Using Postgres's DISTINCT ON to Avoid an N+1 Query — “Recently I fixed a tricky N+1 query and thought I should write it up..” John Nunemaker Need to Upgrade Rails? Don’t Know How Long It Will Take? — Get an action plan for your Rails upgrade and an in-depth report about your technical debt and outdated dependencies ????. FastRuby.io | Rails Upgrade Services sponsor 5 Uses for 'Splats' — 5 different ways to leverage Ruby’s splat (*) operator. Jason Dinsmore Running Multiple Instances of Webpacker — If you’re working on multiple Rails apps at once, changing where Rails gets served up is easy by configuring the port, but what about Webpacker? That requires another tweak. Scott Watermasysk Performing Asynchronous HTTP requests in Rails — How to update parts an app’s pages with asynchronous HTTP requests. A step-by-step how-to with JavaScript’s fetch() function, and Rails native server-side partial rendering. Remi Mercier How to Use AWS SimpleDB from Ruby — If you haven’t heard of AWS SimpleDB, you wouldn’t be alone as it’s not very popular, but it’s a pretty simple and cheap way to store simple documents in the cloud. Peter Cooper What's The Difference Between Monitoring Webhooks and Background Jobs AppSignal sponsor Ways to Reduce Your Heroku App's Slug Size — You might be surprised Heroku didn’t already do some of this for you. Rohit Kumar A Chat with Thibaut Barrère — If you missed our interview with Thibaut Barrere (Rubyist, and creator of the Kiba ETL framework) in last week’s issue, you can catch up here. Glenn Goodrich ???? Code and Tools Rodauth 2.0: Ruby's 'Most Advanced' Authentication Framework — A authentication framework that can work in any Rack-based webapp. Built using Roda and Sequel, Rodauth can be used with other frameworks and database libraries if you wish. Why’s it so advanced? More info on that here. Jeremy Evans RubyGems 3.1.3 Released — Lots of little bug fixes and tweaks. RubyGems Blog Business: Business Day Calculations for Ruby — Define your working days and holidays and then you can do ‘business day arithmetic’ (for example, what’s in 5 working days after now taking holidays and weekends into account?) GoCardless Lockbox: Modern Encryption for Rails Andrew Kane split: The Rack Based A/B 'Split' Testing Framework — A mature framework with robust configuration and multiple options for determining the winning option. Split P.S. In last week's issue, one of the links to our sponsors was incorrect and some readers emailed us to say they really wanted to read the promised article, Let’s Explore Big-O Notation with Ruby, so here it is. Apologies for any inconvenience. Full Article
and npm's CTO: So Long, and Thanks for All The Packages By nodeweekly.com Published On :: Thu, 16 Apr 2020 00:00:00 +0000 #334 — April 16, 2020 Read on the Web Node Weekly npm Has Now (Actually) Joined GitHub — We announced GitHub’s acquisition of npm a month ago but now the process is complete. Not much real news here but the plan is to now focus on community engagement and improving registry infrastructure. Jeremy Epling (GitHub) Node v13.13.0 (Current) Released — fs.readv is a new function to sequentially read from an array of ArrayBufferViews, util.inspect now lets you specify a maximum length for printed strings, the default maximum HTTP header size has been increased to 16KB, there are three new collaborators, and more. Michaël Zasso Get Better Insight into Redis with RedisGreen — Modern hosting and monitoring services include memory usage maps, seamless scaling, key size tracking, and more. RedisGreen sponsor ▶ Watch the Live Coding of a New Feature for Node.js — This is not something for novices, but if the idea of watching ‘over the shoulder’ of a Node.js collaborator implementing a new feature directly into Node itself interests you.. this could be a valuable hour spent. Vladimir de Turckheim node-libcurl 2.1: libcurl Bindings for Node — libcurl is a very powerful and well established way to fetch data from URLs across numerous protocols. node-libcurl 2.1.0 brings support for the latest version of libcurl (7.69.1) to us in the Node world. Jonathan Cardoso Machado npm's CTO: 'So Long, and Thanks for All The Packages!' — Ahmad Nassri was npm’s CTO but has now left. Here, he reflects on the past ten years of npm, the repo, the company, and the achievements of both. Ahmad Nassri ???? Jobs Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started. Vettery Node.js Developer at X-Team (Remote) — Join X-Team and work on projects for companies like Riot Games, FOX, Coinbase, and more. Work from anywhere. X-Team ▶️ Get ready for your next role: Pluralsight is free for the entire month of April. Stay Home. Skill Up. #FreeApril — SPONSORED ???? Tutorials Working With AWS Route 53 from Node — Route 53 is Amazon Web Services’ suite of DNS-related services. Like every AWS service, you can control it via an API, and here’s how to manipulate hosted zones from Node. Valeri Karpov Best Practices Learnt Running Express.js in Production for 4 Years — There’s a lot of stuff packed in here focused around middleware, testing, logging, and general concerns around scaling and keeping apps running in production. Adnan Rahić The Node.js Security Handbook — Improve the security of your Node.js app with the Node.js security handbook made for developers. Sqreen sponsor How To Set Up an Express API Backend Project with PostgreSQL — A pretty extensive walkthrough of creating an HTTP API using Express with Node.js and Postgres on the backend, then deploying it all on Heroku. Chidi Orji Porting to TypeScript Solved Our API Woes — From the guy behind the (in)famous Wat video comes a tale of porting a backend from Ruby to TypeScript. Gary Bernhardt How to Mass Rename Files in Node Flavio Copes ▶ Let's Build a Digital Circuit Simulator In JavaScript — A special episode of the Low Level JavaScript series takes us on a brief journey into the world of digital logic. Low Level JavaScript The Story of How I Created a Way to Port Windows Apps to Linux — We mentioned ElectronCGI recently as a way to let .NET and Node.js code depend upon each other, but here its creator explains more about the how and why. Rui Figueiredo How to Create an Alexa Skill with Node — Implementing a custom ‘skill’ for Amazon Alexa by using Node and AWS Lambda. Xavier Portilla Edo ???? Tools, Resources and Libraries Node v10.20.1 (LTS) Released — If you’re still using Node 10, don’t use v10.20.0, use this, due to a bug in the .0 release. Bethany Nicolle Griggs emoji-regex: A Regular Expression to Match All Emoji-Only Symbols Mathias Bynens ip-num: A Library to Work with ASN, IPv4, and IPv6 Numbers — Happy in both Node and the browser. dadepo Optimize Node.js Performance with Distributed Tracing in Datadog Datadog APM sponsor verify-json: Verify JSON Using a Lightweight Schema — A lighter weight alternative to something like JSON Schema. Yusuf Bhabhrawala middle-manager: A Lightweight 'No BS' Presentation Tool — A bit of humor, really. It turns Markdown into basic presentations but then the magic is it detects your ‘BS’ business language so you can remove it ???? Anders Full Article
and Ellie and Nele: From she to he - and back to she again By www.bbc.co.uk Published On :: Tue, 10 Mar 2020 00:43:56 GMT When two trans men fell in love they began to have second thoughts about their gender. Full Article
and Life and struggle after YouTube fame By www.bbc.co.uk Published On :: Wed, 11 Mar 2020 00:43:14 GMT Dax was one of YouTube's first stars, but 13 years later, few people remember his name. Can a vlogging legend seize glory again? Full Article
and Blasian love: The day we introduced our black and Asian families By www.bbc.co.uk Published On :: Wed, 11 Mar 2020 00:20:43 GMT Blasian - black and Asian - couples now exist in South Africa... but they don't always have an easy time. Full Article
and Birth in a pandemic: 'You are stronger than you think' By www.bbc.co.uk Published On :: Tue, 31 Mar 2020 23:09:29 GMT Coronavirus is throwing many birth plans up in the air and leading some health trusts to increase home births. Full Article
and Coronavirus: Where has all the hand sanitiser gone? By www.bbc.co.uk Published On :: Thu, 02 Apr 2020 06:48:18 GMT Shelves all over the world are empty - it turns out more alcohol is needed, to ramp up production. Full Article
and Coronavirus: The grandad who became a TikTok star without realising it By www.bbc.co.uk Published On :: Sun, 12 Apr 2020 23:42:47 GMT Joe Allington was persuaded to dance on TikTok for the first time in January. Now he's got 1.5 million followers. Full Article
and Stop and search: the controversial police power By www.bbc.co.uk Published On :: Sat, 07 Dec 2019 09:04:42 GMT Reporter Aaron Roach Bridgeman speaks to suspects, police and campaigners. Full Article
and Why being gay in Russia is about "love and passion" By www.bbc.co.uk Published On :: Sat, 15 Feb 2020 00:19:02 GMT The secret moment between two gay Russian lovers that defied haters. Full Article
and Rob Lawrie, the ex-squaddie, and the girl taken By www.bbc.co.uk Published On :: Mon, 30 Mar 2020 00:13:01 GMT Rob thought he was helping a refugee girl and her father as they struggled to get to the UK. But he found out it was all a lie. Full Article
and Coronavirus: Love and dating in lockdown By www.bbc.co.uk Published On :: Thu, 09 Apr 2020 16:33:03 GMT How dating and love continue for three couples during the coronavirus lockdown. Full Article
and Coronavirus: DIY hair shaving and beauty treatments By www.bbc.co.uk Published On :: Fri, 17 Apr 2020 07:15:21 GMT As hair dye and clippers become the next thing on the stockpile list - we look at how people are managing their hair and beauty. Full Article
and Ex porn-star and activist explores men's rights issues By www.bbc.co.uk Published On :: Tue, 21 Apr 2020 06:16:04 GMT Philipp travels to a conference on men’s issues in Chicago, shedding light on the controversial movement. Full Article
and Sex, Disability, and Sex and Disability By www.bbc.co.uk Published On :: Thu, 23 Apr 2020 01:12:00 GMT Disability and sex is a topic around which there are a lot of misconceptions, but what do disabled people think when people get awkward talking about sex with them? Full Article
and Ultra-Orthodox and trans: 'I prayed to God to make me a girl' By www.bbc.co.uk Published On :: Sat, 25 Apr 2020 23:28:57 GMT Growing up as a Hasidic Jew, Abby Stein had no idea trans people existed - she just felt sure she was a girl. Full Article
and Ramadan and Coronavirus: Breaking my fast on Zoom By www.bbc.co.uk Published On :: Thu, 30 Apr 2020 23:57:07 GMT How fasting in lockdown and isolation has changed Ramadan for young Muslims this year. Full Article
and Coronavirus tests and masks sold by fraudsters online By www.bbc.co.uk Published On :: Fri, 10 Apr 2020 04:54:22 GMT A BBC investigation has found online scams selling fake protective equipment and coronavirus tests. Full Article
and Coronavirus: Should maternity and paternity leave be extended? By www.bbc.co.uk Published On :: Sun, 26 Apr 2020 23:22:29 GMT A petition calling for maternity leave to be extended due to coronavirus has attracted many signatures. Full Article
and Coronavirus: Bread and cake tips from a self-isolating baker By www.bbc.co.uk Published On :: Fri, 08 May 2020 23:02:33 GMT Ray normally runs his family bakery, Rinkoffs, but is currently staying at home with his wife. Full Article
and Playing With React and D3 By reactjsnews.com Published On :: Thu, 21 Apr 2016 17:00:00 +0000 D3 is great at data visualizations, but it manipulates the DOM directly to display that data. Rendering DOM elements is where React shines. It uses a virtual representation of the DOM (virtual DOM) and a super performant diffing algorithm in order to determine the fastest way to update the DOM. We want to leverage React’s highly efficient, declarative, and reusable components with D3’s data utility functions. At this point, we can safely say that React is the preferred JavaScript library for building user interfaces. It is used practically everywhere and is almost as pervasive as jQuery. It has an API that is simple, powerful, and easy to learn. Its performance metrics are really impressive thanks to the Virtual DOM and its clever diff algorithm between state changes. Nothing, however, is perfect, and React too has its limitations. One of React’s greatest strengths is the ease with which it integrate third-party libraries, but some libraries, especially opinionated ones, are more difficult to integrate than others. An extremely popular library that can be tricky to integrate with React is D3.js. D3 is an excellent data visualization library with a rich and powerful API. It is the gold standard of data visualizations. However, Because this library is opinionated about data, it is no trivial endeavour to get it to work with React. A few simple strategies permit these two libraries to work together in very powerful ways. Editor’s Note: Check out our upcoming workshop, React and D3, a crash course in learning how to create data visualizations with these two in demand libraries. Reserve your spot now on Eventbrite and get 20% off admission. Learn more at the Eventbrite page What is React? React is an open-source JavaScript library for creating user interfaces that addresses the challenges of building large applications with data that changes over time. Originally developed at Facebook, it is now seen in many of the most commonly used web applications including Instagram, Netflix, Airbnb, and HelloSign. Why is React so popular? React helps developers build applications by helping manage the application state. It’s simple, declarative, and composable. React is not a traditional MVC framework because React is really only interested in building user interfaces. Some have called it the “V(iew)” in MVC, but that’s a little misleading. React’s viewpoint is different. As application logic has reoriented toward the client, developers have applied more structure to their front-end JavaScript. We applied a paradigm that we already understood from the server (MVC) to the browser. Of course, the browser environment is very different from the server. React acknowledges that client-side applications are really a collection of UI components that should react to events like user interaction. React encourages the building applications out of self-contained, reusable components that only care about a small piece of the UI. Other frameworks such as Angular also attempt to do this, but React stands out because it enforces a unidirectional data flow from parent component to child component. This makes debugging much easier. Debugging is the hardest part of application development, so while React is more verbose that other libraries or frameworks, in the end it saves a lot of time. In a framework like Angular’s, it can be hard to figure out where a bug is coming from: The view? The model? The controller? The directive? The directive controller? Data in Angular flows in many different directions, and this makes it hard to reason about that state of your application. In React, when there is a bug (and there will be!), you can quickly determine where the bug originated from because data only moves in one direction. Locating a bug is as simple as connecting the numbered dots until you find the culprit. What is D3? D3 (Data-Driven Documents) is a JavaScript library for producing dynamic, interactive data-visualizations. It’s fairly low level, and the developer has a lot of control over the end result. It takes a bit of work to get D3 to do what you want, so if you’re looking for a more prepackaged solution, you’re probably better off with highcharts.js. That said, it is fairly simple to pick up once you get the hang of it. D3 does four main things: LOADS: D3 has convenient methods for importing data from CSV documents. BINDS: D3 binds data elements to the DOM via JavaScript and SVG. TRANSFORMS: data can be adjusted to fit your visual requirements TRANSITIONS: D3 can respond to user input and animate elements based on that input Why Would We Want To Use React with D3? D3 is great at data visualizations, but it manipulates the DOM directly to display that data. Rendering DOM elements is where React shines. It uses a virtual representation of the DOM (virtual DOM) and a super performant diffing algorithm in order to determine the fastest way to update the DOM. We want to leverage React’s highly efficient, declarative, and reusable components with D3’s data utility functions. Also, once we create a chart component, we can want to be able to reuse that chart with different data anywhere in our app. How to use React and D3? D3, like React, is declarative.D3 uses data binding, whereas React uses a unidirectional data flow paradigm. Getting these two libraries to work together takes a bit of work, but the strategy is fairly simple: since SVG lives in the DOM, let React handle displaying SVG representations of the data and lett D3 handle all the math to render the data. Of course, we’ll have to make compromises. React is unopinionated and flexible, thereby allowing you to accomplish whatever needs to be done. Some tasks, like creating axes, are tedious. We can let D3 directly access the DOM and create. It handles axes well, and since we only need to create very few, this tactic won’t affect performance. Let’s go through a simple example. I created a repository you can use to follow along here: playing-with-react-and-d3. You can follow in the unfinished directory and if you get stuck you can take a look at the finished directory. Let’s generate a random list of X-Y coordinates and display them on a ScatterPlot chart. If you’re following the tutorial, a finished example is provided for you under the “finished” directory, but you can also follow along under “unfinished.” I’ve gone through the trouble of doing all the setup for you. The build will automatically be created from “unfinished/src/index.jsx” Let’s start by creating a simple “Hello World!” React component. Create a file under “components” named “chart.jsx” // unfinished/src/components/chart.jsx import React from 'react'; export default (props) => { return <h1>Hello, World!</h1>; } This example is simple, but let’s go over the explanation anyway. Since we’re rendering a simple H1 with no state, we can just export a function that returns the HTML we expect. If you’re familiar with Angular or Ember, it might look weird to insert HTML directly into our JS code. On the one hand, this goes against everything we’ve learned about unobtrusive JavaScript. But on the other hand, it actually makes sense: we’re not putting JavaScript in our HTML, we’re putting our HTML into our JavaScript. React sees HTML and client-side JavaScript as fundamentally bonded together. They’re both concerned about one thing – rendering UI components to the user. They simply cannot be separated without losing the ability to see what your component is going at a glance. The great benefits of this approach is that you can describe exactly what your component will look like when it’s rendered. Also, keep in mind that this is only possible with JSX, which translates HTML elements into React functions that will render the HTML to the page. Now, let’s move on and mount our component to the DOM. Open up “index.jsx” // unfinished/src/index.jsx import './main.css'; import React from 'react'; import ReactDOM from 'react-dom'; import Chart from './components/chart.jsx'; const mountingPoint = document.createElement('div'); mountingPoint.className = 'react-app'; document.body.appendChild(mountingPoint); ReactDOM.render(<Chart/>, mountingPoint); You probably noticed a few things. You might be wondering why we’re requiring a CSS file. We’re using Webpack, which allows us to require CSS files. This is very useful when we modularize both our stylesheets and our JavaScript. We’re also creating a div in which we want to mount our React app. This is just a good practice in case you want to do other things on the page then render a React component. Lastly, we’re calling render on ReactDOM with 2 arguments, the name of the component and the DOM element we want to mount it on. Now, let’s install all the dependencies by navigating to the unfinished directory and running npm i. Then, fire up the server with npm run start and go to localhost:8080 Awesome! We have rendered our first React component! Let’s do something a little less trivial now. Let’s compose some functions that will create an array of random data points and then render a scatter plot. While we’re at it, we’ll add a button to randomize the dataset and trigger a re-render of our app. Let’s open up our Chart component and add the following: // unfinished/src/components/chart.jsx import React from 'react'; import ScatterPlot from './scatter-plot'; const styles = { width : 500, height : 300, padding : 30, }; // The number of data points for the chart. const numDataPoints = 50; // A function that returns a random number from 0 to 1000 const randomNum = () => Math.floor(Math.random() * 1000); // A function that creates an array of 50 elements of (x, y) coordinates. const randomDataSet = () => { return Array.apply(null, {length: numDataPoints}).map(() => [randomNum(), randomNum()]); } export default class Chart extends React.Component{ constructor(props) { super(props); this.state = { data: randomDataSet() }; } randomizeData() { this.setState({ data: randomDataSet() }); } render() { return <div> <h1>Playing With React and D3</h1> <ScatterPlot {...this.state} {...styles} /> <div className="controls"> <button className="btn randomize" onClick={() => this.randomizeData()}> Randomize Data </button> </div> </div> } } Since we want our component to manage it’s own state, we need to add a bit more code than was necessary for our previous “Hello World” stateless functional component. Instead of just a function, we’re going to extend React.Component and describe our component in the render() method. render() is the heart of any React component. It describes what our component is supposed to looks like. React will call render() on initial mount and on every state change. Inside of render(), we are both rendering a scatter plot component as if it were an HTML element and setting some properties or “props”. The ... syntax is a convenient JSX and ES2015 spread operator that spreads the attributes of an array or object instead of doing all of that explicitly. For more information check out: JSX Spread Attributes. We’re going to use render() to pass our data and a style object that will be used by some of our child components. In addition, we’re also rendering a button with an onClick event handler. We’re going to wrap this.randomizeData() with an arrow function and bind the value of this to our Chart component. When the button is clicked, randomizeData() will call this.setState() and pass in some new data. Let’s talk about this.setState(). If render() is the heart of a React component, setState() is the brains of a component. setState explicitly tells React that we’re changing the state, thereby triggering a re-render of the component and its children. This essentially turns UI components into state machines. Inside of setState(), we’re passing an object with data set to the randomDataSet(). This means that if we want to retrieve the state of our application, we need only call this.state.whateverStateWereLookingFor. In this case, we can retrieve the randomData by calling this.state.data. A little side note on how React works: React offers great performance for rendering UI components by implementing a diff algorithm and comparing a virtual DOM in memory with the actual DOM. When you think about it, the DOM is really a large tree structure. If there’s one thing we have learned from decades of computer science research, it’s how to compare and manipulate trees. React takes advantage of clever tree diffing algorithms, but in order to work, each component can only render one parent element (i.e., you cannot render sibling elements). That’s why In the render function we’re wrapping all our elements in one parent div. Let’s get started with the scatter plot component. Create a file unfinished/src/components/scatter-plot.jsx : // unfinished/src/components/scatter-plot.jsx import React from 'react'; import d3 from 'd3'; import DataCircles from './data-circles'; // Returns the largest X coordinate from the data set const xMax = (data) => d3.max(data, (d) => d[0]); // Returns the highest Y coordinate from the data set const yMax = (data) => d3.max(data, (d) => d[1]); // Returns a function that "scales" X coordinates from the data to fit the chart const xScale = (props) => { return d3.scale.linear() .domain([0, xMax(props.data)]) .range([props.padding, props.width - props.padding * 2]); }; // Returns a function that "scales" Y coordinates from the data to fit the chart const yScale = (props) => { return d3.scale.linear() .domain([0, yMax(props.data)]) .range([props.height - props.padding, props.padding]); }; export default (props) => { const scales = { xScale: xScale(props), yScale: yScale(props) }; return <svg width={props.width} height={props.height}> <DataCircles {...props} {...scales} /> </svg> } There’s a lot going on here, so let’s start with the stateless functional component that we’re exporting. D3 uses SVG to render data visualizations. D3 has special methods for creating SVG elements and binding data to those elements – but we’re going to let React handle that. We’re creating an SVG element with the properties passed in by the Chart component and which can be accessed via this.props. Then we’re creating a DataCircles component (more on that below) which will render the points for the scatter plot. Let’s talk about D3 scales. This is where D3 shines. Scales takes care of the messy math involved in converting your data into a format that can be displayed on a chart. If you have a data point value 189281, but your chart is only 200 pixels wide, then D3 scales converts that value to a number you can use. d3.scale.linear() returns a linear scale. D3 also supports other types of scales (ordinal, logarithmic, square root, etc.), but we won’t be talking about those here. domain is short for an “input domain”, i.e., the range of possible input values. It takes an array of the smallest input value possible and the maximum input value. range on its own is the range of possible output values. So in domain, we’re setting the range of possible data values from our random data, and in range we’re telling D3 the range of our chart. d3.max is a D3 method for determining the maximum value of a dataset. It can take a function which D3 will use to give the max values of the X and Y coordinates. We use the scales to render the data circles and our axes. Let’s create the DataCircles component under unfinished/src/components/data-circles.jsx // unfinished/src/components/data-circles.jsx import React from 'react'; const renderCircles = (props) => { return (coords, index) => { const circleProps = { cx: props.xScale(coords[0]), cy: props.yScale(coords[1]), r: 2, key: index }; return <circle {...circleProps} />; }; }; export default (props) => { return <g>{ props.data.map(renderCircles(props)) }</g> } In this component, we’re rendering a g element, the SVG equivalent to a div. Since we want to render a point for every set of X-Y coordinates, were must render multiple sibling elements which we wrap together in a g element for React to work. Inside of g, we’re mapping over the data and rendering a circle for each one using renderCircles. renderCircles creates an SVG circle element with a number of properties. Here’s where we’re setting the x and y coordinates (cx and cy respectively) with the D3 scales passed in from the scatter plot component. r is the radius of our circle, and key is something React requires us to do. Since we’re rendering identical sibling components, React’s diffing algorithm needs a way to keep track of them as it updates the DOM over and over. You can use any key you like, as long as it’s unique to the list. Here we’re just going to use the index of each element. Now, when we look at our browser, we see this: We can see our random data and randomize that data via user input. Awesome! But we’re missing a way to read this data. What we need are axes. Let’s create them now. Let’s open up ScatterPlot.jsx and add an XYAxis component // unfinished/src/components/scatter-plot.jsx // ... import XYAxis from './x-y-axis'; // ... export default (props) => { const scales = { xScale: xScale(props), yScale: yScale(props) }; return <svg width={props.width} height={props.height}> <DataCircles {...props} {...scales} /> <XYAxis {...props} {...scales} /> </svg> } Now, let’s create the XYAxis component; // unfinished/src/components/x-y-axis.jsx import React from 'react'; import Axis from './axis'; export default (props) => { const xSettings = { translate: `translate(0, ${props.height - props.padding})`, scale: props.xScale, orient: 'bottom' }; const ySettings = { translate: `translate(${props.padding}, 0)`, scale: props.yScale, orient: 'left' }; return <g className="xy-axis"> <Axis {...xSettings}/> <Axis {...ySettings}/> </g> } For simplicity’s sake, we’re creating two objects which will hold the props for each of our X-Y axes. Let’s create an axis component to explain what these props do. Go ahead and create axis.jsx // unfinished/src/components/x-y-axis.jsx import React from 'react'; import d3 from 'd3'; export default class Axis extends React.Component { componentDidMount() { this.renderAxis(); } componentDidUpdate() { this.renderAxis(); } renderAxis() { var node = this.refs.axis; var axis = d3.svg.axis().orient(this.props.orient).ticks(5).scale(this.props.scale); d3.select(node).call(axis); } render() { return <g className="axis" ref="axis" transform={this.props.translate}></g> } } Our strategy up to this point has been to let React exclusively handle the DOM. This is a good general rule, but we should leave room for nuance. In this case, the math and work necessary in order to render an axis is quite complicated and D3 has abstracted that pretty nicely. We’re going to let D3 have access to the DOM in this case. And since we’re only going to render a ma Full Article
and Javier Ceppi, Praful Patel, and Jaime Yarza speak to the media during a press conference By www.fifa.com Published On :: Thu, 26 Oct 2017 14:03:00 GMT KOLKATA, INDIA - OCTOBER 26: L-R: Javier Ceppi, Tournament Director at LOC FIFA U-17 World Cup India 2017, Patel Praful and Head of FIFA Tournaments, Jaime Yarza speak to the media during a press conference ahead of the FIFA U-17 World Cup India 2017 tournament at Vivekananda Yuba Bharati Krirangan on October 26, 2017 in Kolkata, India. (Photo by Tom Dulat - FIFA/FIFA via Getty Images) Full Article Area=Tournament Section=Competition Kind=Photo Tournament=FIFA U-17 World Cup India 2017