import React from 'react'; | |
import sinon, { spy, stub } from 'sinon'; | |
import sinonChai from 'sinon-chai'; | |
import { shallow, render } from 'enzyme'; | |
import chai, { expect } from 'chai'; | |
import chaiEnzyme from 'chai-enzyme'; | |
import proxyquire from 'proxyquire'; | |
chai.use(chaiEnzyme()); |
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real
// Using SWR | |
import useSWR from 'swr' | |
function Profile () { | |
const { data, error } = useSWR('/api/user', fetcher) | |
if (error) return <div>failed to load</div> | |
if (!data) return <div>loading...</div> | |
return <div>hello {data.name}!</div> | |
} |
javascript:(function() {"use strict"; var coupons = angular.element("#lt-coupon-area").scope().sharedValues.unfilteredItems.slice(); coupons.filter(function(x){return x.clipStatus==="U";}).forEach(function(item){ var c1 = document.cookie.match(new RegExp('swyConsumerlbcookie=([^;]+)'))[1]; var c2 = document.cookie.match(new RegExp('swyConsumerDirectoryPro=([^;]+)'))[1]; var data = {"items":[]}; var clip = {}; clip.clipType="C";clip.itemId=item.offerId;clip.itemType=item.offerPgm;clip.vndrBannerCd=""; var list = {}; list.clipType="L";list.itemId=item.offerId;list.itemType=item.offerPgm; data.items.push(clip);data.items.push(list); var request = new Request('https://nimbus.safeway.com/Clipping1/services/clip/items', { method: 'POST', mode: 'cors', redirect: 'error', headers: new Headers({ 'Content-Type': 'application/json', 'X-SWY_VERSION': '1.0', 'X-SWY_API_KEY': 'emjou', 'X-SWY_BANNER': 'safeway', 'SWY_ISREMEMBERED': 'false', 'X-swyConsumerlbcookie': c1, 'X-swyConsumerDirectoryPro': c2 }), body: JSON.stringif |
- if you manage JavaScript primitives as state
- if you have simple state transitions
- if you want to have business logic within your component
- if you have different properties that don’t change in any correlated manner and can be managed by multiple useState hooks
- if your state is co-located to your component
- if you’ve got a small application (but the lines are blurry here)
function memorySizeOf(obj) { | |
var bytes = 0; | |
function sizeOf(obj) { | |
if(obj !== null && obj !== undefined) { | |
switch(typeof obj) { | |
case 'number': | |
bytes += 8; | |
break; | |
case 'string': |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": [ | |
"cloudformation:CreateUploadBucket", | |
"cloudformation:CancelUpdateStack", | |
"cloudformation:CreateStack", |
var fs = require('fs'); | |
const INPUT = 'input.txt'; | |
const OUTPUT = `output_${INPUT}`; | |
var lineReader = require('readline').createInterface({ | |
input: require('fs').createReadStream(INPUT) | |
}); | |
var wstream = fs.createWriteStream(OUTPUT); |