pro

Wendy's Roasts Of Pure Fiery Proportions

There's no denying that a Wendy's roast is not like the rest of them. They just hit different. These roasts pulled zero punches, and for that we are grateful. 




pro

Neighbors Go Full Petty, Guy Tows In Pro Revenge

We love a good neighbor revenge story. People can turn real petty on their neighbors, and sometimes that pettiness is addressed with a calculated, borderline genius, pro revenge. In this case, the dude had had enough of his neighbors' rampant pettiness, and how they'd park in his spots. So, he towed in a whole lot of "redneck hardware" and parked it out front of their place, when the moment presented itself. Just imagining what those two weeks must've been like for those neighbors; oh boy. 

Get some more neighbor revenge goodness over here with this entitled neighbor who tasted his own medicine.




pro

Lying Producer Wants Free Talent, Gets Denied

It's amazing that people still think that it should be common practice to demand work from artists and not have to pay them, but luckily there are times like this when they get called on their BS. The crazy entitlement and unreasonable demands just make them out to be more and more of an utter jerk that no one wants to deal with.




pro

Majestically Unprofessional "Not My Job" Moments

Work in any field long enough and you'll see your fair share of wonderfully unprofessional "not my job" moments. There's slides that go right off buildings, misspelled signs and extremely lazy line painting, just to name a few. It makes you feel good about yourself to see people's majestically incompetent "not my job" moments.





pro

April Fool: Peace Talks Trailer Updated With ‘Improved Visual Effects’

NOTE: In our traditional April Fool’s posts, we endeavor to make them credible at the beginning, then crank up the nonsense until the joke becomes obvious. But these days, the idea of knowingly spreading misinformation (even when comically false) sounds exhausting. So here’s our notice ahead of time: This is 100% silliness! Hope it lightens [...]





pro

Can breathing exercises really help protect you from covid-19?

Taking deep breaths and forcing a cough can help clear mucus, but these techniques are unlikely to prevent or treat coronavirus infections – here’s why




pro

BCG vaccine being trialled as potential protection against covid-19

A long-standing hypothesis suggests the BCG vaccine also serves to generally enhance the immune system, meaning it could protect against covid-19, and trials are under way to find out




pro

Massive Spinosaurus dinosaur swam through water propelled by its tail

A well-preserved fossilised tail from Spinosaurus suggests this massive dinosaur may have been able to propel itself and hunt for prey in the water




pro

BCG vaccine helps fight infections by boosting immune cell production

The BCG tuberculosis vaccine boosts the production of immune cells and this may explain how it protects newborns from dying of sepsis




pro

Universal basic income seems to improve employment and well-being

Finland’s two-year test of universal basic income has concluded that it doesn't seem to disincentivise working, and improves recipients’ mental and financial well-being




pro

A good project for my downtime

This looks like a good way to spend my time after classes are over, but I haven’t been able to find it in the Ikea catalog. Has it sold out already?



  • Miscellaneous and Meta

pro

Another professor embarrasses the professoriate

A university professor filed suit against his institution because it chastised him for inappropriate sexual behavior. He wasn’t fired, they just tut-tutted, put a black mark on his record, and told him not to do that anymore. He sued anyway, for his ego. During a class in 2013, a psychology professor at George Mason University […]




pro

I probably shouldn’t send this to my daughter

Skatje is working hard on her thesis in computational linguistics, and might not appreciate a joke about how easy it is. It’s hard enough that I don’t even understand what she’s doing when she tries to explain it!




pro

Hardly Appropriate




pro

Friday Polynews Roundup — The dam bursts for poly on TV, what we offer everyone, when to stay away, and planted seeds are sprouting




pro

Friday Polynews Roundup — Triad storyline on "The Connors," Black Poly Nation gets TV rep, loving polyfamily profiles, community dreams, and evangelical worry that this all hits too close to home



  • Friday Polynews Roundup
  • poly and christian
  • polyamory on TV
  • tabloids


pro

How io_uring and eBPF Will Revolutionize Programming in Linux

#263 — April 22, 2020

Read on the Web

StatusCode Weekly
Covering the week's news in software development, ops, platforms, and tooling.

The Devastating Decline of a Brilliant Young Coder — This is not a technical article but is an important one nonetheless. Lee Holloway essentially programmed Cloudflare into being. But then he became distant and unpredictable, and what happened to him is something that could affect any of us ????

Sandra Upson (WIRED)

How io_uring and eBPF Will Revolutionize Programming in Linux — Even more exciting times are coming for development on Linux thanks to these technologies. A good overview.

Glauber Costa

Slow CI Build? Get a 41:1 ROI by Switching to Semaphore — For every $1 invested in Semaphore, engineers gain $41 in reclaimed productivity. Who said money can’t buy you time?

Semaphore 2.0 sponsor

▶  Mob Programming and the Power of Flow — I enjoyed this insightful walk through the idea of bringing people together and attempting to develop things in an efficient way with numerous people around the same machine (a.k.a. ‘mob’ programming). It’s not for everyone, but it’s neat to see how it can work.

Woody Zuill

Cloudflare Workers Now Supports.. COBOL — COBOL is one of the earliest things you could really call a programming language (it first appeared in 1959!) and is often a source of amusement because it’s seen as old, verbose, clunky, and difficult to maintain. Nonetheless, it’s still in use (particularly in legacy systems) and you can use with Cloudflare Workers too!

John Graham-Cumming

Quick bytes:

???? Jobs

DevOps Engineer at X-Team (Remote) — Join the most energizing community for developers. Work from anywhere with the world's leading brands.

X-Team

Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started.

Vettery

???? Stories and Opinions

How 'Memories', a 256 Byte Demo, Was Coded — You can watch the demo here or enjoy learning just how these unusual developers cram so much into so little space.

HellMood/DESiRE

The Computer Scientist Who Can’t Stop Telling Stories — For pioneering computer scientist Donald Knuth, good coding is synonymous with beautiful expression.

Quanta Magazine

▶  Discussing NGINX and Service Meshes with Alan Murphy — I enjoyed this SE Daily episode last week and learnt a fair bit.

Software Engineering Daily podcast

End-to-End Observability for Microservice Environments — Optimize service costs and reduce MTTR with full data correlation, payload visibility and automated tracing. Try free.

Epsagon sponsor

▶  Performance Profiling for Web Applications — An overview of how to use Chrome DevTools to understand a Web application’s performance bottlenecks.

Sam Saccone

Are Object Stores Starting to Look Like Databases? — A bit, yes.

Alex Woodie (Datanami)

The Case Against CS Master’s Degrees

Oz Onay

Why I Stopped Using Microservices

Robin Wieruch

???? Tutorials

Ask HN: I'm A Software Engineer Going Blind, How Should I Prepare? — This is something I hope none of you have to go through, but we’ve linked to other stories about being a blind coder in the past, and some form of sight loss will affect many of us over the years.

Hacker News

Writing an 'Emulator' in JavaScript (and Interfacing with Multiple UIs) — Tania built a Chip-8 interpreter in JavaScript and has gone into quite a bit of detail about what was involved here. Lots of neat bits and pieces to pick up from this.

Tania Rascia

What It Took to Build a Serverless App That Texts Positive COVID-19 News — Code, a screencast tour, and an article looking at what it took to build a simple serverless app using C#, Azure Functions, and Twilio to text news alerts (but only ones with positive sentiments!)

Gwyneth Pena S.

If You Use grep On Text Files, Use the -a (--text) Option — I could explain why but then you wouldn’t need to read this. Makes a good point.

Chris Siebenmann

Event-Reduce: An Algorithm to Optimize Frequently Running Queries? — In brief, the idea is that rather than having to re-run queries when data changes on a table, you can basically merge in changes to previous query results. Be sure to check the FAQs.

Daniel Meyer

Embedding Binary Objects in C

Ted Unangst

???? Code and Tools

Desed: A Debugger for sed — Demystify and debug your sed (the text processor that comes with nearly every Unix) scripts, from the comfort of your terminal. Step through line by line, place breakpoints, etc.

SoptikHa2

Falcon: An Open-Source, Cross Platform SQL Client — Built around Electron and React, this basic client can quickly do chart visualizations of query results and can connect to RedShift, MySQL, PostgreSQL, IBM DB2, Impala, MS SQL, Oracle, SQLite and more.

Plotly

The SaaS CTO Security Checklist

Sqreen sponsor

Termible: Offer Terminal Apps in the Browser Without Installation — This is a commercial service but I find the idea intriguing. You provide a Dockerfile, embed some code on your site, and let people play with your product/service “live”. HTTPie seems to use it for its live examples.

Termible

X410: An X Server for Windows 10 — If you’re using WSL (Windows Subsystem for Linux) to run Linux behind the scenes of a Windows 10 install, X410 takes things to another graphical level.

Choung Networks

60 Linux Networking Commands and Scripts“I decided to create a network tools go-to-list for myself. Then, I thought, why not turn the list into a blog post?”

Hayden James

Brök: A Tool to Find Broken Links in Text Documents — Built in Haskell.

Mark Wales

xsv: A Fast CSV Command Line Toolkit Written in Rust. — Another ‘Swiss Army knife’ for your slightly structured data.

Andrew Gallant




pro

Meghan McCain Goes Off on Kayleigh McEnany for ‘Spinning Propaganda’

Meghan McCain, The View’s resident conservative host, tore into Kayleigh McEnany for “spinning propaganda” on Thursday morning after the new White House press secretary dismissed the need for increased coronavirus testing as the economy reopens.During her press briefing on Wednesday, McEnany said it was “nonsensical” to think that every American should be able to get tested for coronavirus, even though President Donald Trump said two months earlier that “anybody that wants a test can get a test.” The hosts of The View took the press secretary to task over those remarks.Co-host Sunny Hostin said she found it “shocking” that the White House spokesperson would say that considering recent news that one of the president’s personal valets just tested positive for the virus.“So it’s obviously important enough for everyone in the White House and surrounding the president to be tested for the coronavirus, but it’s not important to the press secretary and to the administration for Americans to be tested for the coronavirus,” she declared. “And so that tells me that she is just spinning lies to the American people rather than being honest with the American people.”After first saying there has been “mixed messaging” coming not just from the White House but from medical experts since the beginning of the coronavirus pandemic, McCain went on to blast McEnany as a propagandist.“I think in regards to Kayleigh McEnany, she was hired for this job because she’s good at spinning propaganda, and she was good spinning propaganda before she got hired,” she exclaimed. “And you can make the argument that’s the role of any press secretaries but it’s probably a little more egregious with this particular president.”The conservative co-host then worried aloud that we were reaching a tipping point on saving the economy, criticizing the Trump administration for not taking the necessary steps to safely reopen the country.“If we don’t start getting a plan to get testing, to somehow pull ourselves out of this and get America back to work,” she proclaimed. “This is going to be far more egregious than any crisis any of us have seen in all of our lifetimes.” “If the tests aren’t important, why is the White House, and everybody else getting tested before they go before the president?” McCain concluded. “I would like to go back to work. I know you would, and I would be comfortable doing that if we all had the capacity to get tested.”Read more at The Daily Beast.Got a tip? Send it to The Daily Beast hereGet our top stories in your inbox every day. Sign up now!Daily Beast Membership: Beast Inside goes deeper on the stories that matter to you. Learn more.





pro

'Never Seen Anything Like This': Experts Question Dropping of Flynn Prosecution

WASHINGTON -- The Justice Department's decision to drop the criminal case against Michael Flynn, President Donald Trump's former national security adviser, even though he had twice pleaded guilty to lying to investigators, was extraordinary and had no obvious precedent, a range of criminal law specialists said Thursday."I've been practicing for more time than I care to admit and I've never seen anything like this," said Julie O'Sullivan, a former federal prosecutor who now teaches criminal law at Georgetown University.The move is the latest in a series that the department, under Attorney General William Barr, has taken to undermine and dismantle the work of the investigators and prosecutors who scrutinized Russia's 2016 election interference operation and its links to people associated with the Trump campaign.The case against Flynn for lying to the FBI about his conversations with the Russian ambassador was brought by the office of the former special counsel, Robert Mueller. It had become a political cause for Trump and his supporters, and the president had signaled that he was considering a pardon once Flynn was sentenced. But Barr instead abruptly short-circuited the case.On Thursday, Timothy Shea, the interim U.S. attorney in the District of Columbia, told the judge overseeing the case, Emmet G. Sullivan, that prosecutors were withdrawing the case. They were doing so, he said, because the department could not prove to a jury that Flynn's admitted lies to the FBI about his conversations with the ambassador were "material" ones.The move essentially erases Flynn's guilty pleas. Because he was never sentenced and the government is unwilling to pursue the matter further, the prosecution is virtually certain to end, although the judge must still decide whether to grant the department's request to dismiss it "with prejudice," meaning it could not be refiled in the future.A range of former prosecutors struggled to point to any previous instance in which the Justice Department had abandoned its own case after obtaining a guilty plea. They portrayed the justification Shea pointed to -- that it would be difficult to prove to a jury beyond a reasonable doubt that the lies were material -- as dubious."A pardon would have been a lot more honest," said Samuel Buell, a former federal prosecutor who now teaches criminal law at Duke University.The law regarding what counts as "material" is extremely forgiving to the government, Buell added. The idea is that law enforcement is permitted to pursue possible theories of criminality and to interview people without having firmly established that there was a crime first.James G. McGovern, a defense lawyer at Hogan Lovells and a former federal prosecutor, said juries rarely bought a defendant's argument that a lie did not involve a material fact."If you are arguing 'materiality,' you usually lose, because there is a tacit admission that what you said was untrue, so you lose the jury," he said.No career prosecutors signed the motion. Shea is a former close aide to Barr. In January, Barr installed him as the top prosecutor in the district that encompasses the nation's capital after maneuvering out the Senate-confirmed former top prosecutor in that office, Jessie K. Liu.Soon after, in an extraordinary move, four prosecutors in the office abruptly quit the case against Trump's longtime friend Roger Stone. They did so after senior Justice Department officials intervened to recommend a more lenient prison term than standard sentencing guidelines called for in the crimes Stone was convicted of committing -- including witness intimidation and perjury -- to conceal Trump campaign interactions with WikiLeaks.It soon emerged that Barr had also appointed an outside prosecutor, Jeff Jensen, the U.S. attorney in St. Louis, to review the Flynn case files. The department then began turning over FBI documents showing internal deliberations about questioning Flynn, like what warnings to give -- even though such files are usually not provided to the defense.Flynn's defense team has mined such files for ammunition to portray the FBI as running amok in its decision to question Flynn in the first place. The questioning focused on his conversations during the transition after the 2016 election with the Russian ambassador about the Obama administration's imposition of sanctions on Russia for its interference in the American election.The FBI had already concluded that there was no evidence that Flynn, a former Trump campaign adviser, had personally conspired with Russia about the election, and it had decided to close out the counterintelligence investigation into him. Then questions arose about whether and why Flynn had lied to administration colleagues like Vice President Mike Pence about his conversations with the ambassador.Because the counterintelligence investigation was still open, the bureau used it as a basis to question Flynn about the conversations and decided not to warn him at its onset that it would be a crime to lie. Notes from Bill Priestap, then the head of the FBI's counterintelligence division, show that he wrote at one point about the planned interview: "What's our goal? Truth/admission or to get him to lie, so we can prosecute him or get him fired?"Barr has also appointed another outside prosecutor, John H. Durham, the U.S. attorney in Connecticut, to reinvestigate the Russia investigators even though the department's independent inspector general was already scrutinizing them.And his department has intervened in a range of other ways, from seeking more comfortable prison accommodations last year for Paul Manafort, Trump's former campaign chairman, to abruptly dropping charges in March against two Russian shell companies that were about to go to trial for financing schemes to interfere in the 2016 election using social media.Barr has let it be known that he does not think the FBI ever had an adequate legal basis to open its Russia investigation in the first place, contrary to the judgment of the Justice Department's inspector general.In an interview on CBS News on Thursday, Barr defended the dropping of the charges against Flynn on the grounds that the FBI "did not have a basis for a counterintelligence investigation against Flynn at that stage."Anne Milgram, a former federal prosecutor and former New Jersey attorney general who teaches criminal law at New York University, defended the FBI's decision to question Flynn in January 2017. She said that much was still a mystery about the Russian election interference operation at the time and that Flynn's lying to the vice president about his postelection interactions with a high-ranking Russian raised new questions.But, she argued, the more important frame for assessing the dropping of the case was to recognize how it fit into the larger pattern of the Barr-era department "undercutting the law enforcement officials and prosecutors who investigated the 2016 election and its aftermath," which she likened to "eating the Justice Department from the inside out."This article originally appeared in The New York Times.(C) 2020 The New York Times Company





pro

Nicola Sturgeon: 'Care home situation profoundly upsetting'

Nicola Sturgeon says the situation in care homes is "profoundly upsetting".




pro

Brexit: Simon Coveney says trade talks progress not good

The Irish deputy PM says time is short to reach a trade deal this year, with much still to do.




pro

Met Police end probe into pro-Brexit campaigners

Leave campaigners were accused by the Electoral Commission of breaking the law over spending limits.




pro

Watford third team to oppose Premier League neutral venue proposals

Watford become the third team to publicly oppose the use of neutral venues when Premier League football returns.




pro

Slovenia cyclists hold anti-government protest

Thousands accused PM Janez Jansa of using the coronavirus crisis as a pretext to restrict freedoms.




pro

Coronavirus: Volunteers help protect NHS workers

The army of volunteers making essential supplies for NHS workers fighting Covid-19.




pro

React Router & Webpack in Production

I’ve been working on a pretty large react-router codebase at work. Currently it has around 50~ code splits, which as you can imagine, is a lot of routes. This is going to be a post on the things I’ve learned throughout building out my development / production config and how we are using webpack in production.

###Initial Setup

Before I really dive into how my webpack config is setup and the problems I’ve found, I’ll quickly go over how this app is setup. Currently, there’s one entry point and it looks like this:

import React from 'react'
import { render } from 'react-dom'
import { match, Router, browserHistory } from 'react-router'
import AsyncProps from 'async-props'
import routes from '../routes/index'
/* globals document, window */

const { pathname, search, hash } = window.location
const location = `${pathname}${search}${hash}`

match({ routes, location }, () => {
  render(
    <Router
      render={props => <AsyncProps {...props}/>}
      routes={routes}
      history={browserHistory}
    />,
    document.getElementById('app')
  )
})

It looks like a standard react-router setup, except a couple things are different. For one, there’s way too many routes to have them all in this file, so we are importing the main route object into this file. Second, we are using match on the client side. Without matching first, the client side would try to render before the splits were downloaded causing an error. You can read a little more about match on the client here.

Next, we are using Ryan Florence’s awesome async-props library for loading data into components. It allows me to load data from an api before the server renders components. It will pass the data down to the client for the client-side render, and then data will load as you navigate to new pages automatically.

###Routes

Our main routes file looks like this:


export default {
  component: 'div',
  path: '/',
  indexRoute: require('./index'),
  childRoutes: [
    require('./login'),
    require('./account'),
    ...
  ]
}

There’s a lot more require’s in our app of course. And these are nested pretty deep. The files referenced in the root file have more child routes, and those use require.ensure which you can read about in the webpack docs on code splitting. It tells webpack to make a new bundle, and then load that bundle when require.ensure is called on the client. Here’s an example:

if(typeof require.ensure !== "function") require.ensure = function(d, c) { c(require) }

module.exports = {
  path: 'account',
  getComponent(location, cb) {
    require.ensure([], (require) => {
      cb(null, require('../../views/master/index.jsx'))
    })
  },
  childRoutes: [
    require('./settings'),
  ]
}

There’s a few things going on here. First, we have a function at the top that will polyfill require.ensure. Why? Well, on this project we are server rendering our whole site as well, which I would rather not do, but due to the type of site we are building: we have to. The next thing is the relative require path. I’m using this awesome babel resolver plugin along with webpack’s resolve paths so that I can import files like this:

import Header from '../../master/header'
//becomes
import Header from 'master/header'

Why do I have to use a babel plugin AND webpack’s resolve feature? Once again, doing a server rendered app, the code is ran on the server and also through webpack. In this particular app, I haven’t had time to experiment with webpacking the server. Anyways, if I didn’t use the babel plugin, errors would be thrown on the server, but webpack would work fine. This is one of the common things I have ran into while building this app.

Realizing some things need to be done slightly different on the server or client. You may still be wondering why I am referencing the component as a relative path in the above route example, and that’s because the babel plugin I’m using only works with import and not require. My route objects are the one place that I have these “nasty” looking paths.

##Webpack

I was prompted to make this article after tweeting this out:

A couple people wanted a better explanation as to what’s happening here. When I was first building my production webpack config, even after using all of these plugins:

new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
  compress: { warnings: false },
  comments: false,
  sourceMap: false,
  mangle: true,
  minimize: true
}),

My bundle looked like this:

That’s pretty huge if you think about it. And I’m not talking about the amount of bundles. I’m talking about the file size. After searching everywhere for a solution to get the bundle size down further, I found webpack’s AggressiveMergingPlugin. This thing is a life saver. As you may have seen from the tweet, the output turns into this:

Just having the main, vendor, and one other bundle brings the whole site under 1MB. I’m using the plugin to only merge files if the size reduction is more than 50%, which is the default.

People talk about code splitting in webpack and think it’s really amazing to load the JS for the page you’re on and nothing more. It sounds great. The problem is that the file size is immensely bigger. If someone more familiar with webpack has a better idea as to why this is, I’d like a better explanation. It isn’t feasable to keep the splits instead of merging them. This site is pretty large, with a lot of routes as you can tell from the screenshots. Codesplitting without merging would cause way more waiting on the client side every time you navigate to a new page. Even if the JS was heavily cached, the first time you hit these pages it will have to load a 300kb bundle for some of them.

##Caching

That takes us to caching. We are about a month away from publicly launching this site, so we haven’t setup the workflow for pushing updates through a cdn, but that will be the end result. For now, in my webpack config, my output object looks like this:

output: {
  path: __dirname + '/public/assets/js/[hash]/',
  filename: '[name].js',
  chunkFilename: '[id].js',
  publicPath: '/assets/js/[hash]/'
},

This is in the production config of course. This way I can cache the files and when I update the code, the hash will change and the browser won’t be caching the old code. I pass in the hash as an env variable at runtime to that the server has the correct path to the assets folder.

##Problems

There were a few big problems I came across while building out a server rendered app with dynamic routes. The first was page titles. How am I supposed to have the right title on the client and on the initial server render? Thankfully, Ryan has yet another solution. react-title-component solves this perfectly.

The next was, how do I hit an api, wait for the response on server render, load new data on route changes, and of course, do this at the component level. As I mentioned before, async-props solves this problem too. It will give you route info so that you can make requests based on things in the url.

The next problem is one that I haven’t fully solved. Webpack is getting really slow. It takes around 20 seconds on a maxed out macbook 15” to build code in production. On the server, it takes more like a minute! If I’m in development mode, it takes around 10 seconds to make the initial build, and sometimes it lags on building the splits on code change. If anyone has insight into this I would love to hear it.

This one goes along with the webpack one, and it is reloading the server. I haven’t tried to webpack the server but I hear doing so works great for this. I don’t think it would fix the problem with webpack being slow though, and in fact it would probably make it even slower.

##Folder structure

I almost forgot to throw this one in here! I’m really happy with the structure of this project. I have a views folder that has all of the same folders and file names as the routes folder. It makes it really easy to find things. These also correspond with the URL to the page. /account/settings will be in views/account/settings.jsx and routes/account/settings.js. The same is true for my tests folder.

##Conclusion

I hope this gave you a good glimpse at how webpack and react router work at a larger scale than you see most blog posts cover. If you have any questions or things that you would like me to talk about that I haven’t already, please leave a comment below and I will update this post! I’m sure that I forgot a few problems and tips writing this. I was thinking this would be a short post but it blew up on me!




pro

Using Proxies with Redux Types

One of the most common problems that I run into when using Redux is trying to figure out why an action is not being captured by a reducer. For someone just getting starting with Redux, debugging this issue can be especially overwhelming because of how Redux manages data flow. So before you start pouring over configuration code, or the logic contained in your action creators and reducers, please, make sure your action types are defined and spelled correctly.

One of the most common problems that I run into when using Redux is trying to figure out why an action is not being captured by a reducer. For someone just getting starting with Redux, debugging this issue can be especially overwhelming because of how Redux manages data flow. So before you start pouring over configuration code, or the logic contained in your action creators and reducers, please, make sure your action types are defined and spelled correctly.

In any application that I have built, most bugs that I have run into are simply due to typos. However, the solution to this particular problem is harder to spot because no errors are raised when the application is run. Take a look at the snippet below.

// actionTypes.js

export const FETCH_FILE_REQUEST = 'fetch_file_request';
export const FETCH_FILE_SUCCESS = 'fetch_file_success';
export const FETCH_FILE_FAIL = 'fetch_file_fail';


// filesReducer.js

import {
  FETCH_FILE_REQUEST,
  FETCH_FILE_SUCESS,
  FETCH_FILE_FAIL
} from '../actions/actionTypes';

const filesReducer = (state = {}, action) => {
  switch (action.type) {
    case FETCH_FILE_SUCESS:
      return { ...state, file: action.payload };
    default:
      return state;
  }
}

export default filesReducer;

Assuming we dispatched an action with type FETCH_FILE_SUCCESS, the filesReducer should catch the action before the default case is returned. But what if that is not happening? Where do we start the debugging process. There does not appear to be anything wrong with the code in the reducer; the action type was imported and matches the case in the switch statement. There are no errors in the browser. Where is the issue?

You may have noticed that I misspelled SUCCESS in filesReducer.js, but the reason this can be hard to catch is because importing undefined types does not cause an error, so when we import FETCH_FILE_SUCESS, its value is actually undefined, so our reducer always hits the default case.

It would be nice if the existing import/export system could help us catch this. Unfortunately, since action types are just strings, validating their existence is challenging. Luckily, we have another option.

Enter Proxies

Proxies are a feature of ES2015 that allow us to customize operations on a object. They can be used in many different ways, and you can find some useful examples here and here. For our problem, this example from Mozilla looks promising:

let validator = {
  set: function(obj, prop, value) {
    if (prop === 'age') {
      if (!Number.isInteger(value)) {
        throw new TypeError('The age is not an integer');
      }
      if (value > 200) {
        throw new RangeError('The age seems invalid');
      }
    }

    // The default behavior to store the value
    obj[prop] = value;

    // Indicate success
    return true;
  }
};

let person = new Proxy({}, validator);

person.age = 100;
console.log(person.age); // 100
person.age = 'young'; // Throws an exception
person.age = 300; // Throws an exception

So if proxies can be used to validate that properties assigned to an object are of a certain type and value, we should definitely be able to ensure that our action types are never undefined, or else throw an error that will be easy for us to fix. Let’s refactor our actionTypes.js file.

// actionTypes.js

const types = {
  FETCH_FILE_REQUEST: 'fetch_file_request',
  FETCH_FILE_SUCCESS: 'fetch_file_success',
  FETCH_FILE_FAIL: 'fetch_file_fail'
}

const typeValidator = {
  get(obj, prop) {
    if (obj[prop]) {
      return prop;
    } else {
      throw new TypeError(`${prop} is not a valid action type`);
    }
  }
}

module.exports = new Proxy(types, typeValidator);

First, we define a object containing all our action types. Then we define our validator handler typeValidator. The get method inside our handler is called a trap, and provides access to the properties of a object. If the property we are looking for, an action type, in this case, exists in the types object, return that prop, unmodified. Otherwise, throw an error because the prop does not exist.

Finally, export a new proxy, passing the types object as the target and the typeValidator as the handler. However, it is important to note that the ES2015 module system does not work well with proxies, so module.exports and require() must be used for exporting and importing the types.

Barely any code needs to change in the reducer and action creator files, but in order for the action types to be imported successfully, we just need couple lines of code in a new file:

// actionTypesProxy.js

export const {
  FETCH_FILE_REQUEST,
  FETCH_FILE_SUCCESS,
  FETCH_FILE_FAIL,
} = require('./actionTypes');

// in the reducer and action creator files
// change '../actions/actionTypes' to
// '../actions/actionTypesProxy'

By creating a proxy to verify the existence of an action type, we no longer have to worry about correctly naming a property upon import because an error will be thrown in the browser console as soon as the application starts. So, reduce the number headaches you get when developing an application using Redux and start using proxies.

Interested in learning how to build applications using Redux with ReactJS. Check out this online course! Modern React with Redux





pro

Al Sadd progress as Hienghene impress




pro

Cristian Borruto (L) of Argentina protects the ball from Joao Matos (R)

Cristian Borruto (L) of Argentina protects the ball from Joao Matos (R) during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




pro

FIFA Beach Soccer World Cup 2019: Clash of styles with keepers prominent

FIFA Beach Soccer World Cup 2019: clash of styles with keepers playing prominent role




pro

Russia v Portugal - Promo - FIFA Confederations Cup 2017

Promo previewing match 5 of the FIFA Confederations Cup 2017 - Russia v Portugal




pro

Mexico v New Zealand - Promo - FIFA Confederations Cup 2017

Promo previewing match 6 of the FIFA Confederations Cup 2017 - Mexico v New Zealand




pro

Germany v Chile - Promo - FIFA Confederations Cup 2017

Promo previewing match 8 of the FIFA Confederations Cup 2017 - Germany v Chile




pro

Cameroon v Australia - Promo - FIFA Confederations Cup 2017

Promo previewing match 7 of the FIFA Confederations Cup 2017 - Cameroon v Australia




pro

New Zealand v Portugal - Promo - FIFA Confederations Cup 2017

Promo previewing match 10 of the FIFA Confederations Cup 2017 - New Zealand v. Portugal




pro

Mexico v Russia - Promo - FIFA Confederations Cup 2017

Promo previewing match 9 of the FIFA Confederations Cup 2017 - Mexico v Russia




pro

Match 12: Chile v. Australia - PROMO - FIFA Confederations Cup 2017

Promo previewing match 12 of the FIFA Confederations Cup 2017 - Chile v. Australia




pro

Germany v Cameroon - Promo - FIFA Confederations Cup 2017

Promo previewing match 11 of the FIFA Confederations Cup 2017: Germany v Cameroon.




pro

Portugal v Chile - Promo - FIFA Confederations Cup 2017

Promo previewing match 13 of the FIFA Confederations Cup 2017: Portugal v Chile.




pro

Germany v Mexico - Promo - FIFA Confederations Cup 2017

Match 14: Germany v Mexico - Promo - FIFA Confederations Cup 2017




pro

Match 15: Portugal v Mexico - Promo - FIFA Confederations Cup 2017

Promo previewing match 15 of the FIFA Confederations Cup 2017 - the match for third place between Portugal and Mexico.




pro

The Final: Chile v Germany - Promo - FIFA Confederations Cup 2017

Promo previewing match 16 of the FIFA Confederations Cup 2017 - the Final between Chile and Germany.




pro

We are very goal-oriented, focus should be on process: Gopichand

National badminton coach Pullela Gopichand feels this lockdown can help everyone understand that it should not be always goal-driven and it is important to focus on the process as well.

"It is a very similar kind of scenario for athletes as well. I have maintained this stand for a very long time, I think we are all very goal-oriented and we are driven by something that comes up in the next week, next month or next year -- especially when it comes to our careers," Gopichand was quoted as saying by Mumbai Mirror.

"It has to be the reverse. You have to focus on your process, get up in the morning and do the best work that you can do today - everything else will fall into place," said Gopichand.

Almost all sporting events in the world have come to a standstill due to the coronavirus pandemic with the Olympics also being postponed by a year. Gopichand also advised people not to get too involved with COVID-19 news all the time.

"You have to create a distance. You cannot be involved so much in the situation so much that you're mentally affected by it. A certain guru said that you should treat the problem like it's your neighbour's problem. Don't get too involved. You need to report the news, that's your duty and job but don't get so agitated by it that you lose sleep over it. We need to distinguish between both and find a way to insulate yourself," he advised.

"I have been spending the last 21 days in quarantine with my family -- it's tough but at least we have something to fall back on. It is a lot harder for daily wage earners and people who live in small houses, five to six people in a room. For them, it's really tough. This is a rare event in global history so we just need to shut up and sit at home quietly to flatten the curve," he said.

Catch up on all the latest sports news and updates here. Also download the new mid-day Android and iOS apps to get latest updates.

Mid-Day is now on Telegram. Click here to join our channel (@middayinfomedialtd) and stay updated with the latest news

This story has been sourced from a third party syndicated feed, agencies. Mid-day accepts no responsibility or liability for its dependability, trustworthiness, reliability and data of the text. Mid-day management/mi




pro

Will always play IPL for Royal Challengers, promises Virat Kohli

The love and loyalty of the fans will never let him leave Royal Challengers Bangalore till the time he is playing IPL, skipper Virat Kohli said on Friday. RCB have reached the IPL final thrice but have not gone on to win the trophy. During a live session on Instagram with former South African captain and RCB teammate AB de Villiers, Kohli said winning the tournament remains the goal but he would not leave the team irrespective of the results. "It has been such an amazing journey. It is always going to be our dream, winning the IPL together. There is no scenario where I could think of leaving the team ever.

"You can feel emotional about the season not going well but till the time I am playing IPL, I am never leaving this team. The fans, their loyalty has been amazing," said the India skipper. Responding to Kohli's feelings towards RCB, De Villiers too acknowledged the support of fans over the past nine years. Kohli, on the other hand, has been with RCB since 2008.

"Same for me. I never want to leave RCB but to do that I got to keep scoring runs. I am not the captain you see," said the South African in jest. The COVID-19 pandemic has forced the "indefinite" suspension of the 13th IPL, which was supposed to start last month but Kohli said he is still hopeful of the cash-rich event happening at some stage. "We have no clarity at this moment but I am optimistic that at some stage we will have something," he said.

Both Kohli and de Villiers also recalled their early days in international cricket and their growth as cricketers and friends. Kohli said at times, the youngsters coming in have too much regard for the "system" and he wants to see them break the norm. "I want to see youngsters coming in scoring 500-600 runs. I want people to break the norm. Sometimes I feel people have too much regard for the system in sport. When you break the shackles, you do something special."

Kohli also acknowledged contribution of Mark Boucher, Gary Kirsten and Duncan Fletcher early on in his international career. "Gary always gave me positive feedback. Boucher told me in 2008 to improve my game against the short ball. He had the vision. Then Fletcher, he had a keen eye for the game. So many people who have contributed (to my growth)," said Kohli.

De Villiers picked the 119 at Wankhede in the 2015 series decider as his best knock against India. Kohli picked the 119 he scored in Johannesburg Test in 2013. "I was always really motivated to win the series after 2-2 . I was incredibly motivated to do something special," de Villiers said. They also picked their combined South Africa and India ODI team. It included Sachin Tendulkar, Rohit Sharma, Virat Kohli, Ab de Villiers, Jacques Kallis, M S Dhoni (captain), Yuvraj Singh, Yuzvendra Chahal, Dale Steyn, Jasprit Bumrah and Kagiso Rabada.

Catch up on all the latest sports news and updates here. Also download the new mid-day Android and iOS apps to get latest updates.

Mid-Day is now on Telegram. Click here to join our channel (@middayinfomedialtd) and stay updated with the latest news

This story has been sourced from a third party syndicated feed, agencies. Mid-day accepts no responsibility or liability for its dependability, trustworthiness, reliability and data of the text. Mid-day management/mid-day.com reserves the sole right to alter, delete or remove (without notice) the content in its absolute discretion for any reason whatsoever




pro

Owe villagers hold up traffic at Kharghar to protest against illegal mining

Over 200 residents of Owe Camp village (Those rehabilitated due to the Koyna dam construction in 1960) at Kharghar, Navi Mumbai, protested on Thursday from 7.30 am to 12.30 pm, because of several problems they are facing due to the alleged illegal mining in the area for years. They blocked the road for vehicles going towards the mining sites.

They say they have complained to and requested several senior officers from the City and Industrial Development Corporation (CIDCO) and the Panvel City Municipal Corporation (PCMC) to act against those involved and stop it, but claim no one helped them. One of the residents, Ramchandra Jadhav said, "For past five to six years we have been facing many issues. Our houses have developed several cracks because of the mining.

Also, when we asked the project manager to show us permission for it, we found none had it. We are facing health issues due to the air pollution." He added, "We have sent letters requesting the mining be stopped, to the PCMC commissioner, tehsildar, collector of Raigad district and Maharashtra Pollution Control Board."

PCMC chief Sudhakar Shinde said, "I haven't seen the letters. But we will look into the matter soon." CIDCO PRO Mohan Ninave did not respond to calls and messages.

Catch up on all the latest Mumbai news, crime news, current affairs, and also a complete guide on Mumbai from food to things to do and events across the city here. Also download the new mid-day Android and iOS apps to get latest updates





pro

Navy officer's mysterious death: Son claims siblings killed father for property

Did an ex-Navy lieutenant die of a fall in the bathroom or because his sons and relatives killed him over a property tussle? The Kharghar police will seek answers to just that, after the Panvel judicial magistrate first class (JMFC) court on July 2 ruled in the favour of the deceased's youngest son, and directed them to file a murder case against three other sons and three relatives. The case was finally registered on July 7.

The court was acting on the case of merchant navy captain Jagjit Singh, 47, who has alleged his brothers Kuljit Singh, 58, Kuldeep Singh, 54, and Kulmit Singh, 50, and three other relatives killed his father, ex-Navy lieutenant Sarjit Singh Virk, 86, at Kharghar on April 16.

Smelled a rat
Jagjit smelled a rat soon after his brothers called him around 10.47 am on April 16, to inform him that their father had died after falling in the house. A grief-stricken Jagjit was not in the condition to listen to anything immediately after getting the tragic news.


Sarjit Singh with wife Anup Kaur

"But after gaining composure," he told mid-day, "I called Kulmit asking how he [Sarjit] passed away. Kulmit passed the phone to our brother Kuldeep. While he was speaking, Kulmit kept prompting him to tell me that father fell inside the bathroom and succumbed to his injuries."

"I was in Mohali. My brothers said they will take some time to complete the formalities, and that I shouldn't rush to Kharghar. The next day, I got a text message from Kulmit saying they're going to perform my father's final rites. I begged them to wait until I reached through text and WhatsApp messages, and also called the pradhan of the Kharghar Gurudwara and Kharghar cops to tell them about my situation and my objection to the final rites. As a result of that, they waited till I reached Kharghar," Jagjit added.

Injuries on the face
On April 18, Jagjit went to the Kharghar police station, where cops showed him the post-mortem reports and other documents. He was then taken to the mortuary of the Vashi municipality hospital to see his father.

That's where Jagjit saw injuries on his scalp and cheek and three broken teeth. He clicked some pictures. "When I saw the injuries, I was confident that these marks were not caused by some accidental fall; he was hit by something. I had a word with cops, but they refused to entertain my grievances, so I went to court," added Jagjit.

Greed for property
Jagjit's suspicions against his brothers are based on a history of rifts he's had with them over their alleged greed for family property. According to his statement to the cops, Jagjit said, "In 2015, my mother Anup Kaur passed away. She'd distributed her property and some money equally among her four sons, but my brothers Kulmit and Kuldeep siphoned them off. Also, from October 2016 to February 2017, they forced my father to transfer Rs 26 lakh from our joint account to their accounts. I had filed a criminal case against them in Lambi police station, Punjab on April 11for the same."

"Also, my father was witness to attempts made by the same brothers to transfer my share of ancestral land to their name. In the meantime, they took father to Kharghar last year and cut off our communication. After he moved there, the only thing I heard about him was news of his death. I am suspicious of my brothers and other relatives having killed my father to hide their wrongdoings," alleged Jagjit. mid-day reached out to Kulmeet Singh Virk for comment, but he remained unavailable.

Case filed
Jagjit had gone to the cops with his allegations, but they'd turned him down, after which he went to court. His advocate Naresh Pradhan said, "We'd gone to the Panvel JMFC with whatever proof we had, presented our case and told the court that an investigation needs to be done. The court found substance in our demands and asked Kharghar cops to investigate the matter."

Senior inspector of Kharghar police station, Pradeep Tadir, said, "According to the direction of JMFC, we have filed a case against Kuljit Singh, Kulmeet Singh, Kuldeep Singh and three other relatives under sections 302 (murder) and 120 B (criminal conspiracy) of the Indian Penal Code on July 7. We'll ask for a detailed opinion from our forensic experts to seek clarity. The primary report had suggested that the death was natural and occurred due to a fall."

Catch up on all the latest Mumbai news, crime news, current affairs, and also a complete guide on Mumbai from food to things to do and events across the city here. Also download the new mid-day Android and iOS apps to get latest updates