Say we have an API client with three methods, getItem(), updateItem(), and deleteItem(), each of which returns a Promise. There are only two functions you need to worry about: then() and catch().
Each call to then() creates another step in the Promise chain, and if there’s an error at any point in the chain, the next catch() block will be triggered. Both then() and catch() can either return a raw value or a new Promise, and the result will be passed to the next then() in the chain.
Convert callback to Promises
If a function doesn’t return a Promise but rather a callback, like Node’s fs.readile function,
then you can convert the call to a Promise as follows. The new function, called readFilePromise, converts the original function, called readFile, into a Promise.
To use the new promise function, do this.
To create Promises out of ordinary values, use Promise.resolve() and Promise.reject().
If you have a function that needs to return a Promise, like fs.readFile, but handle certain cases synchronously, you can use Promise.resolve() and Promise.reject() to create Promises out of ordinary values, like this.
Running concurrently
Promise.all is a convenient method for running an array of Promises concurrently, i.e. all at the same time. For instance, say we have a list of files we want to read from disk. Using the readFilePromise function we created above, it would look like this:
Here’s another example
And another example (from Kyle Simpson)
In the example above, we can use the new Promisified function in the chain as follows. We can also create a new Promise that returns a Promise of an ordinary value to keep the chain going.
When traveling, it’s super handy to be able to see a map of just the places you want to visit. This can easily be done with Google Maps. In addition, with Google Maps you can zoom in and out and get directions to each place of interest. Here’s how to create a custom Google Map with your choice of places.
1. Go to maps.google.com and log in 2. Click the hamburger menu icon and then “Your Places” 3. Click the “Maps” tab 3. At the bottom, click “Create Map” 4. In the search bar, enter the name or address of a place then click the search button. 5. Google Maps will place a balloon on the map where the place it along with a description box. 6. In the description box, click “Add to map”
7. Repeat steps 4-6 adding as many locations as you’d like 8. To make it easier to see the location, change the color and details of the base map.
9. To share or embed a map, click the hamburger menu icon and then “Share or embed map”
If you want to make your location markers stand out more, you can change their color and icon, e.g. from default blue to red.
To show routes, click the “Add directions button and then add an address for each location.
Or, click on the Draw a Line button and choose “Add driving route”.
You can then drag the blue route line to follow the paths or roads you want.
To add a picture to each location, click the camera icon. You can upload or add one or more pictures by URL from Google Images.
To be safe, you can calculate your basal metabolic rate (BMR) which is how many calories you burn doing absolutely nothing and just doing the bare minimum to live (breathe, etc).
For me, my BMR is 1818 calories / day.
Weight loss facts
You should not lose more than 2 lbs / week.
1 pound (~0.45 kg) of fat = 3500 calories
To achieve a 2 lb weight loss per week, you’d need to lose 1000 calories per day.
In a heavy skillet like cast iron add olive oil over medium heat.
Add onions and cook them until soft.
Add meat and stir using a wooden spoon tell it is almostly cooked.
Add tomatoes, serrano pepper, and bell pepper let simmer until the tomato mixture begins to reduce,taste and adjust the seasoning to your liking. cover the skillet, and cook on low heat tell completely cooked.
Here’s an interesting video comparing the bond strengths of various epoxies. Overall, the JB Weld – Original wins the test. Don’t get JB Weld – KwikWeld or ExtremeHeat as they are weak.
Lead-based paint and lead-contaminated dust are the most hazardous sources of lead for U.S. children. Lead-based paints were banned for use in housing in 1978. All houses built before 1978 are likely to contain some lead-based paint. However, it is the deterioration of this paint that causes a problem.
If possible, buy a house built after 1978 to avoid lead paint.
Avoid Asbestos
Unless you perform detailed testing to rule out the presence of asbestos, every pre-1981 building must be treated as if it contains asbestos.
Avoid Plaster Walls
Plaster walls were used to finish interior houses up until the 1950s at which time it was replaced with drywall. Plaster walls are like stucco. Since they are hard, cutting and drilling a hole for, say, hanging a picture is difficult.
If possible, buy a house after the 1950s to avoid having to deal with plaster walls.
Avoid Old Wiring Systems
Old homes used knob and tube wiring till around 1920. After that, flexible cables were used till the 1940s. After that, cables were run through metal conduit till around 1965. Around 1965, homes began using modern NM cable commonly called Romex.
If possible, buy a house after 1965 to avoid having to deal with old wiring systems.
Roofs
Roofs are one of the most expensive parts of a house. Replacing the shingles on a roof can cost around $10,000. Shingle roofs commonly have a lifespan of 25 years.
If possible, find out when the roof was installed to determine whether the roof will need replacing soon or not.Concrete tile roofs are very long lasting so it would be good to get a house with that.
Transfer Tax and Title Fees
Don’t assume that your agent will draft an agreement correctly that is in your best interest. Certain things such as title and escrow fees and city and county transfer taxes are either paid by the seller, buyer or both, depending on which county the property is in. For California, you can reference this table.
Avoid Flood Zone
If the property is in a flood zone and you need a loan to buy the house, the lender will require you to pay for flood insurance. That is yet another expense you should avoid having to pay. To determine if a property is in a flood zone, enter the address at FEMA Flood Map Service Center.
If the property is in a Special Flood Hazard Area (SFHA), then you will be required to buy flood insurance. For example, the property at 2421 Country Club Boulevard 28 Stockton, CA 95204 is in a special flood hazard area as shown in the map below.
HOA
Some properties may appear much cheaper than others for the same square footage. Beware, however, that these properties can be just as expensive or even more expensive because they may be part of an association and require a monthly HOA fee which can range from $25 to over $500 per month.
Homeowner’s Insurance
Shop around for homeowner’s insurance. State Farm is the largest insurer with 17% of the market. They also provide an instant online quote and replacement cost estimator and their premiums are usually cheaper than other big-name insurers.
When choosing insurance coverage, one of the biggest issues is the cost to completely rebuild your house. One way to determine this is by using DwellingCost.com. Some appraisers use this.
Homeowner’s insurance costs can vary wildly. You should get a quote from an insurance broker and compare costs.
Mortgage Shopping
When shopping for a mortgage, you can probably get a better rate from a non-bank lender. Here are some rate comparison sites:
Also, consider getting a mortgage from a credit union. Unlike banks, credit unions are not for profit so they can offer lower rates. For example, if you live in Alameda County in the San Francisco Bay Area, you can become a member of 1st United Credit Union and get competitive rates for personal and rental property home loans. See their rates.
Selling Your House to Buy a New House
If you want to sell your existing house and buy another, e.g. because you’re moving or need a bigger home, then keep in mind that the first 10 years of your 30-year mortgage primarily goes to paying interest rather than principal. As such, if you were to sell within the first 10 years, you wouldn’t have much equity from your monthly mortgage payments. Of course, if your house went up in value, then you may have a decent amount of equity.