- Retract your bed into the ceiling: https://www.bumblebeespaces.com/.
- The jinja templates have access to the entire g object by default, you don't explicitly need to pass it or its attributes.
- Bootstrap.
- Bootstrap source classes: https://github.com/twbs/bootstrap/blob/master/dist/css/bootstrap-utilities.css (and an analogous file for grid, etc).
- center-block -> mx-auto.
- Great comment on centering options in bootstrap 4: https://stackoverflow.com/a/42559095.
- If you go more than 12 cols, it wraps. There are a few other ways to get around this: nested grids and scrolling.
- "responsive" is such that it updates as your viewport size changes (changing from fullscreen to half, etc). You can specifically use these responsive classes on components like tables, and there are analogs for items like containers (container-fluid).
- Supercontest.
- Fixed the g usage, no longer passing it back to the templating engine. All of the views are 1000x cleaner no. Passing request.url_rule.endpoint for the inferred self blueprint string (like url_for('week.week_picks')) instead of week_link_prefix or switch_link.
- week existed in the url_defaults dict as a key, but was undefined when coming from the lb view, so it didn't look up the max. Changed that to infer the max when either nonexistent OR undefined.
- Restyled EVERYTHING. Removed a lot of my custom css in favor of the bs alternatives.
- A lot of inconsistency was from my usage of bootstrap 4 syntax but with bootstrap 3 compiled css/js in my project vcs. Upgraded, and swapped to cdn usage of bootstrap and notify. Bootstrap requires jquery and popper.
- Added jumbotron for ads at the top.
- Made the syncing nice between 'active' class state for the navlinks. Js basically checks the url and infers what page it's on.
- col-auto for variable width based on content. Changed the name/email nav item to this, in case a name or email is very long. Don't want it to span two lines.
- Renamed the / endpoint to /matchups explicitly. This made the url inference easier to match to the tag ids for active class states.
- no-gutters on the row didn't do exactly what I wanted for the week navs. I nested the grids in a container-fluid for 100% width, then manually set px-0 on the inner cols. Both inner and outer cols had text-center, and both inner and outer rows had justify-content-center. Looks perf now, for all breakpoints.
- Converted the tables to bootstrap. They basically had everything I had written custom in css. So much cleaner.
- In chrome devtools, when inspecting elements, on the css tab: if a property is crossed out, it means that something more specific or something downstream overrode it.
Friday, August 30, 2019
Thursday, August 29, 2019
- Some chargers have a UV bath for sanitizing your phone: https://www.amazon.com/PhoneSoap-Sanitizer-Universal-Patented-Clinically/dp/B072R6MJKQ.
- In Python, you can unpack (destructure) strings as an iterable just like a list!
- Should probably hook my public github apps into travisci at some point.
- Talked with the spacex folks a little bit about investing. Many hold philip morris, which is bullshit, but we talked about recession strategies as well. Some are putting into fixed rate savings accounts @2.5%, which I guarantee I can beat on the public market. My portfolio grew during 07-09. Companies like Netflix, Amazon, Groupon, Lego, and many more all saw between 20-80% annual growth during the last bear.
- APR is a little different, it's the charge.
- The rule of 72: timeToDouble= 72/interestRate So if you want to double your money in ten years, you need to find an annual interest rate of 7.2%.
- two-movies.name is a good alternative for stuff like yesmovies, watchseries, movie4k, etc.
- If any streaming sites go down, this page updates and lists all of them!! https://www.bestfreestreaming.com/
- Vegas odds has the 2019-2020 nba champs at clippers (3.5) lakers (4) bucks (6) rockets (8) 76ers (8) warriors (12).
- Placed fresh order. Trying a ton of new vegetables to juice like radicchio, green cabbage (usually do red), and golden beets (usually do red).
- The Jamie from JRE is Jamie Vernon: http://www.youngjamie.com/. He's a producer/photographer/gamer. His website isn't encrypted lol.
- Started using google calendar more deliberately. Wanted to avoid conflicts like the blake st trip.
- Uninstalled ticktick, no longer need a todo list. Calendar has tasks and I want to keep it all in the same place.
- SpaceX FF draft.
- Bottled kombucha for second fermentation with blueberries. Made new batch.
- Supercontest.
- Talked logistics with petty for a little bit. Gave the creds to the account.
- Created another ticket with some cleanup: https://github.com/brianmahlstedt/supercontest/issues/35.
- Made the sc container names unique to not conflict with bmahlstedt.com.
- Docker system prune (not volumes), reclaiming 13GB lol.
- The password had been wiped on the supercontest db in my local persistent volume. Alter user to fix it, back to what it was before.
- Jinja's |safe filter is what you use to disable all autoescaping. This allows you to do things like pass raw html via python strings to the renderer (similar to a jsx fashion, having html in the app), rather than relying on the template to contain all of the html.
- Removed the week shim, the / home route will run the url_defaults to set the week at the max available.
- Restricted it so that other users' picks for the current week are hidden until midnight on saturday.
- Made the leaderboard, graph, and navbar show first name and last name instead of email. If names aren't present, it defaults back to email.
- Customized the flask-user templates for various things like registration and login. Removed my main/profile and replaced it with the standard user/edit_user_profile. It was just naivete when I first built the app.
- Centered everything, including the feedback route. Styled them all much better and much more consistent. There was a lot of shitty styling, and still is. I've moved bits and pieces over to the proper bootstrap implementation, but there's still a lot of conflict between custom classes and styles.
- Closed https://github.com/brianmahlstedt/supercontest/issues/35.
- Slight bootstrap refresher, since enough time usually passes between UI projects to forget syntax.
- form-group for inputs with other tags. form-control for styling.
- container, row, and col. You can align and justify within. 12 columns. Assign width however you want, and it can be different across different screen sizes. Comes with natural gutters, 15px on each side of each column. You can lay out forms in rows/cols in the same way.
- text-center. <abbr> for hover. <pre> and <code> for code. Variables. User input. nav, navbar (dropdown), jumbotron.
- clearfix should be added to the parent div around floating elements, like float-right or left.
- Pagination, popovers, progress bars, spinners, shadows.
- Width w height h padding p margin m. Margin can go negative (padding can't), so you could have something like mr-lg-n2 which would mean negative right margin on large viewports.
- Screen size callouts apply to that and anything larger. sm > 576px, md > 768px, lg > 992px, xl > 1200px.
Tuesday, August 27, 2019
- eslint-utils>1.4.1 was a critical pin fix. Dependabot submitted PRs for both.
- David Blaine gave a tech talk on how to hold your breath for longer:
- Hyperventilate beforehand (breath in and out very quickly). This purges your body of CO2.
- Full breath in. Don't let any out.
- Don't move at all. Even eyes. Every movement uses oxygen.
- Larger lung capacity is a natural advantage.
- Be in shape. The lower your resting heart rate, the more efficient your oxygen will be.
- Be lighter. The less pounds you carry, the less oxygen you need.
- If you breathe pure O2 (artificially) beforehand, you can hold a lot longer as well.
- During an extreme breathholding attempt, your BPM can drop to ~10. Holyyyyy cow.
- Financial research:
- Feds typically try to keep inflation at about 2% year over year for economic stability. This is a good number to keep in mind for annual raises.
- We are currently in a very long bull market, about 2009-2019. The common definition for a bull market is a 20% swing. So if S&P500 for example hits a low of $1000, then eventually rises to 1200, the bull market will be the time period from that rise until it falls to 1000 again. But it's flexible, bull markets are just general upward trends. There was a long bull market from 1982-2000 (dotcom through y2k). Bear markets are the opposite. These are stupid names. The bull tends to attack upwards whereas the bear swipes downwards.
- Insider sales (executives of big companies selling stock) are often good signs of a swing towards bear. This has been increasing a ton lately (aug saw over 10b sales).
- Yield curve inversion is a comparison of 2yr vs 10yr treasury notes. The longterm note should yield higher interest in a good market, obviously. When it inverts and the 2yr note yields higher interest, it usually means a decline is on its way. The late 20XX recession hit about 2 years after the inversion. Right now, the 2yr is at 1.526% and the 10yr is at 1.479%. The metric here is -4.7 basis points, which is the hundredth-of-percentile difference. This is a really bad inversion.
- The ongoing china trade struggles, tariffs, and presidential tweets are also causing some economic risk.
- All factors above considered, we're very likely headed for bear. Timing is the golden ticket now.
- During recessions, invest in bigger companies. Less risk. Small companies and companies with debt usually do not survive.
- Treasury bonds are one of the safest places to put money before/during a recession. You're effectively loaning the government money and you get paid the interest. This loan is part of the national debt! You can't just buy bonds like shares on the public market, you bid for them.
- Gameplan, I guess: sell some of my smaller holdings and finish the tax burden. If any leftover: bonds or low risk low return big companies.
- Digital ocean sent me an email that they had detected an unsecured mongo instance on my droplet. This is such a cool service - I love it.
- Mongo starts up by default without auth. Any user on the local system can create/delete/read/write. This is how the blog component of my bmahlstedt.com site was set up.
- I would shell into the database (which persists over a docker volume) and add the admin user. Then add a conf file with the creds (gitignore) just like supercontest, and use it within the backend app's docker composition so that it could authenticate when it tries to communicate with the db container. Then you enable auth in the mongo system conf file. https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-mongodb-on-ubuntu-16-04. I chose not to do this, because I don't use the blog.
- A research elephant was given 297mg (that's like 3000 doses) of acid in 1962: https://www.theguardian.com/science/2004/feb/26/research.science.
- Five square puzzle, programmatic solution. http://thinkingames.com/WorkPages/ProductSingle.aspx?pID=5.
- Always check the simple brute force first.
- There are 5^25 permutations of the grid if you ignore rotation and piece constraints. That's 298 quadrillion possibilities, which is way too much to brute force. Even if each grid took 1 microsecond to check, the whole state space would take 1000 years to verify.
- What about if we approach it with the piece-placing route?
- Each 1x2 piece has 20 positions while vertical and 20 positions while horizontal. Then if you count for flipping while in each position, that's 80 positions total. Each 1x3 piece has 15 positions while vertical and 15 positions while horizontal. Then if you count for flipping while in each position, that's 60 positions total.
- There are two 1x2 pieces and seven 1x3 pieces, so we have 80^2*60^7 = 1.79e16. This is 18 quadrillion instead of 298. We're getting a little closer.
- In reality, there are many fewer because as each piece is placed, it increasingly constrains the available positions of the remaining pieces.
- Sounds like we should do a recursive piece-placing strategy, failing fast if any configuration fails?
- Ok but first, ignore the symbols. Let's simply check the permutations for shape placement. Once we have this number N, we can probably brute force. For each shape-constrained grid, we'll have 14*12*10*8*6*4*2*4*2 options, or 5,160,000. The number N shouldn't be too high, there are only so many ways to organize items of length 3 in a 5x5 grid.
- Well let's look at an anchoring strategy for the recursion. This will constrain it even further. No matter the state of the grid, every piece can be considered to have an anchor: its upper-left-most cell. So every grid has 9 anchors. From each anchor, there are only 4 options: 3x1 horizontally, 3x1 vertically, 2x1 horizontally, 2x1 vertically. So we can iterate through each of these permutations, 4^9 = 262,000. Starting in the upper left origin, walk all of these paths with 4 branches at each anchor. This should yield 4x duplicate solutions as well for 90deg rotations, so we expect ~65,000 total iterations to find N from above, N, being a much smaller number because a small percentage of the anchor permutations fit all 9 pieces on the grid.
- There ended up being 164 permutations of shape placements, counting all rotations, which means that N = 41.
- The first attempt at part 2, recursively placing all permutations of the 9 pieces for 5,160,000 options without fail-fast, railed my i5 at 100% cpu for 4 minutes, growing the stack to about 85% of my 4GB of RAM then using the majority of 8GB swap as well. The calculation was not done after 20min, for a single grid of the N=41, so I killed it and proceeded with the validity check after each placement.
- Properly failing fast on part two's recursion yields 32 solutions in ~16s on my i5. This is from N = 164, so we haven't respected rotation yet. The stack is negligible in mem. Once all 32 solutions are known, we could write a programmatic deduplication of the rotation/mirror equivalents, but 32 is small enough to do by hand.
- Solved:
- Put all code in https://github.com/brianmahlstedt/fivesquared.
- Trading bot:
- Created new github repo for this app.
- Wrote my own robinhood api wrapper for transactions, stripped mostly from jamonek. I don't trust third-party code with my financial keys.
- Used yahoo_fin for the inputs. Confirmed they offer live pricing now.
- In py>=3.4, the reload built-in has moved to importlib.reload(). Use `from importlib import reload` then stay the course.
- "Patience is not the ability to wait - it's how we behave while we're waiting." - Joyce Meyer
- If your flow requires break/continue to various layers of loops (more than 1 away), then you need to refactor into functions.
Monday, August 26, 2019
- You have 3 natural cortisol peaks throughout the day, 8-9, 12-1, and 5-6 (approximately). While cortisol is normal regarded as the bad stress hormone, this is only after long-term stress effects. Short-term, cortisol can be regarded as the body's natural upper to increase alertness. Drinking caffeine while the body is already peaking cortisol is not efficient, because then your body starts relying on the external caffeine and reduces internal cortisol production. This is more detrimental than you'd expect - it both REDUCES your natural energy levels and makes you more tolerant of caffeine for external stim. You want to drink caffeine during the cortisol valleys, mid-morning and mid-afternoon. This is like any other drug - take it when you need it, not when the symptoms are absent.
- Smoked a curry pork butt today.
- LD50 is the dose which would be lethal for 50% of people.
- Tons of markets suffered (toys, cars, etc) at the end of last week due to trade wars with China, tariffs, Trump tweets to pull production from China, etc.
- Yes, the gelatin in jello and candy is the same gelatin from rendered animal collagen.
- The yahoo_fin module shows that the live stock prices change on the order of magnitude: seconds. It's not consistent. Sometimes it's one second. Sometimes it's 15 seconds.
- James Randi had a show called exploring psychic powers where he made fools of people who claimed to be psychics: https://www.youtube.com/watch?v=ldr2JTuHBy0.
- Finance research.
- Joined 3 subreddits: r/investing, r/personalfinance, and r/tax.
- SpaceX should be shielded from gigantic market dip, because fundamentally our product has nothing to do with China, and because we're a private company, but unfortunately that's not how the market works. Our valuations will see a decrease from this. I attribute it mainly to how misguided the concept of investment has become. People are not investing because they believe in things, adding value to products they support; they invest as a moneymaking opportunity. They invest for personal financial growth. This lumps the market into a singularity, a big pool representing fluctuating waves of chances, not orthogonal markets representing their respective contributions to society. If investors actually placed money based on virtue, each corner could roller coaster in isolation from the others.
- ETF = exchange traded fund. These are collections of other assets that are grouped to track an index, like the S&P500 ETF does for S&P500.
- "Link in bio" on instagram is annoying af. Just give me the link, don't shamelessly take 4 seconds to self-promote. You're intentionally injecting the equivalent of an ad between the customer and their desired content, causing a bad taste in their mouth before consumption. Not smart.
- New Chappelle standup on Netflix.
Sunday, August 25, 2019
- googlefinance used to be a maintained python wrapper for realtime stock data, but no longer. Yahoo-finance used to be 15min delayed, so it was a lesser option, but now it appears that it offers live prices and is maintained. I'll use yahoo-fin for my bot.
- Joe silva was the longtime matchmaker for the ufc, but now the role is filled by Sean Shelby and Mick Maynard. They're the #2 decisionmakers after Dana.
- Went to an IT-chapter2 themed haunted house last night to promo the upcoming movie. Was awesome.
- Also saw Ready or Not, which was surprisingly good. I had no idea it was half comedy.
- Chipotles, by definition, are just smoked jalepenos. I'll try some with the pork butt tomorrow. They only need to be on for an hour or so.
- Went to Smorgasburg for BBQ day. Finally had Moos. Was very good.
- Andrew luck retired, shocking everyone.
- My amazon visa was declined the past couple times. They didn't have online support, so I called. They card had expired, and they had not sent a replacement. The agent said that was weird - the automated system should have done so already. Got a new one on the way.
- Went to Smorgasburg for the first time. The "row" in the arts district is pretty nice, but the neighboring smorgasburg sector is kinda dumpy. It's a distribution center that has worn forklifts and homeless clutter. They fill it with food stands every sunday and it becomes a nice little food court.
- Moos was there. Overall grade: B+. Satisfied, overall. A- for the actual grade in pitmaster quality, but marked down for the ludicrous prices.
- A. Brisket was very good. Got point only. burnt ends were tasty, good seasoning level. Very tender. Franklins remains untouched, but this comes in shortly after. Light on smoke flavor (i prefer heavy), but light on seasoning (i prefer light) and fantastic on moisture. This is better than my homemade brisket.
- B-. Spare ribs. Decent. Was wrapped too early, because the bark formation was minimal. Not seasoned much at all. My ribs are better.
- C+. Beef ribs. Ok. This cut is hard to screw up because it's so fatty, so the flavor can't really be missed, but the tenderness was average. Doesn't come close to my homemade honey/maple short ribs. I would have given this a B+, but the price was asinine. They charge $56/lb for the regular beef ribs, and $60/lb for the pastrami beef ribs. Absolutely-fuggin-ridiculous. You can get raw short rib, from the plate, prime grade, for $7/lb from a decent distributor.
Saturday, August 24, 2019
- Went through MD/HN.
- Read a bit of Vue's docs, for comparison to React.
- vue init webpack <myproj> is like create-react-app
- Still use components, and they update as the underlying data changes, but you do so with classic html/css/js rather than jsx (html in js). You CAN combine these all into a single .vue file with meta js/css/html.
- You get a few useful html classes like v-for v-if v-bind v-on which allow you to conditionally/customizably display data and/or events.
- Next.js is the framework for full node/react apps (as opposed to create-react-app for simple single-page apps).
- Daytrading is ... just transacting throughout the day on small fluctuations, rather than long-term.
- Shorting, You do this when you think something is overvalued or you expect it to drop.
- Selling shares that you do not own with the obligation to buy them back later.
- Say I short company A. I go to a broker and "sell" 10 shares for $100 each. I then have $1000 and the requirement to "buy" the shares back at some later date.
- This is like the opposite of a regular transaction, where you buy and hope it increases.
- If the price drops, as I expected, to something like $80 then when I "buy" all 10, I will have effectively bought at 80 and sold at 100, making a profit of $20 per share.
- If the price INCREASES, then you are losing money. If it goes to $150, you've lost $50 on each share.
- There is an important difference with this method. Shorting stocks can theoretically lose you an infinite amount of money. With a regular stock purchase, say for $30, you can only lose that $30. If you short a $30 stock, like an early google share, and it rises to $1000, you've lost $970, and will continue to lose more as the price increases.
- Good documentary about dana white and the fertitta brothers: https://www.youtube.com/watch?v=tWMG1PsR21U. TUF saved the early days of the UFC!
- Lot of respect for these guys building a product that THEY supported. Decisions were not solely made for finance or for business, they were made for the furtherment of the sport. These 3 men believed MMA should be up there with NFL/NBA/MLB/NHL, so they sole intent of the UFC was the exposure of that to the fans.
- WME bought the UFC for 4 billion recently. They also own zuffa, miss universe, and more. WME stands for WIlliam Morris Endeavor, but the company is simply known as Endeavor now.
- Here are the rankings for sports agencies from 2018: https://www.forbes.com/sports-agencies/list.
- Bobbing a bike is making it naked and removing the passenger assemblies so it ends at the seat (like a bobtail). I won't remove the tail of the bmw so that I can still use the saddlebags.
- Breakfast at Hangar with the softball crew.
- Change it to ceddit in the url to see the mod-removed comments, etc.
- The reason you have to import react in seemingly unnecessary places is usually due to jsx.
- Dockerfiles can have multiple RUN instructions to build the image, but only one CMD or ENTRYPOINT. This is what is run to start the image.
- Docker rework for bmahlstedt.com.
- Standardized the docker compose file with separate services (and dockerfiles, where necessary) for dev and prod.
- Got it proxied by the nginx container, with routing by domain), and certified by the letsencrypt container (super simple with current umbrella docker-compose infra).
- The frontend in production is actually pretty easy. You just run npm build in an intermediate container then point nginx at the static files in a second container (the docker name for this is multistage build). The output of ./build/ goes into /usr/share/nginx/html.
- Remember, the output of this build looks hardly like the source js you wrote. It bundles and minifies quite a bit for the optimized production build.
- Another kinda weird thing - you still use jwilder/nginx-proxy to route the initial requests to the proper domain. This goes to a flask app with uwsgi on the supercontest app, but for bmahlstedt.com, it goes from the nginx reverse proxy container to another nginx container serving the npm build output. This is not superfluous, something needs to serve the static files. There's another container running pm2/node for the backend, obviously - this just makes more sense because it's nginx->pm2 instead of nginx->nginx.
- Instead of starting the app with `node` I start it with `pm2` the node process manager. This allows you to start/stop/monitor and more.
- The only increase in complexity is because of react-router, which you have to make dynamic. To do this, you simply overwrite the default nginx.conf to include root and index.
- The other
- Deployed to production. Closed ticket #9.
- Cool CDN to get SVGs for common brands: https://github.com/simple-icons/simple-icons.
Thursday, August 22, 2019
- Last night at midnight was my 1 billion second birthday! Legitimately more excited than my regular birthdays. This happens once in a lifetime. Went and saw a rooftop bar showing of the big lebowski.
- Digital ocean now supports managed mysql and redis databases. This is convenient (although I do all the management myself).
- Finished the rusty lake / cube escape series. Absolutely loved them. Intriguing story, macabre, good difficulty balance.
- Lactose intolerance can be beaten: https://elemental.medium.com/can-you-make-a-lactose-intolerance-disappear-de4f4948d8d. The human body is wonderfully adaptive. The more dairy you consume, the more tolerant you become.
- You already knew about this, but remember that flamescope is the name for netflix' graphical perf tool: https://medium.com/netflix-techblog/netflix-flamescope-a57ca19d47bb.
- Making almond milk is the same process as oat milk (blend, strain), but you can optionally do any of the following beforehand: soak, roast, peel. You can skip any of those, you just won't get as much flavor out.
- Removed over 20 fairing pieces on the BMW. Looks so much better now:
Tuesday, August 20, 2019
- Tallow and lard are basically the same, but tallow is from beef and lard is from pork. You simply render the fat (trimming away meat, blood, etc) low and slow and then cheesecloth filter it. While still liquid, you can pour into a pan and then cut into bars after it solidifies at room temp. Then you can use it for cooking, lotion, candles, etc.
- There is a really cool set of escape room mobile games called the rusty lake series. This is the order to play: seasons, lake, arles, harvey's box, case 23, mill, hotel, birthday, theatre, roots, cave, paradise, paradox. I've beaten 7 of the 13 so far, all without hints.
- Remember LAMP = linux apache mysql php. It's an oldschool stack.
- Served papers to the ex for briley. Interesting process. Sent FL-100/110/120/140/142/150, filled out FL-115 as the server myself. Basically just disclosures of assets and then an agreement on how to divide.
- Certified mail costs a few extra dollars and the courier ensures that the package is delivered to the recipient directly.
- "Return Receipt" is when they mail you a slip immediately when the recipient acquires the package.
- A gallon of whole milk blended together with 3-4 jars of peanut butter is ~20,000 calories.
- You can create separate docker-compose files for dev vs prod, or you can create separate services within a single docker-compose file. I prefer the latter. Both require specific command line syntax anyway:
- docker-compose -f docker-compose-prod.yml up
- docker-compose up app-prod
- NODE_ENV is an important environment variable. Express understands it automatically. It basically disables all caching and gives you more verbose logs.
- You should create anonymous volumes for node_modules in docker containers running node apps, if you are also mounting your source dir, because otherwise it will overwrite.
- Remember that the BUILD is all that knows about the dockerfile. You may have slight overlap between actions in the docker-compose and the actually dockerfile because of this. Examples:
- Mounting the src directory vs COPY it over.
- command: or CMD to start the app.
- Docker recomposition.
- Finished all dev containers for frontend/backend/database. Moving on to production next.
- The full address to link containers like app <-> db should use the container NAME (your choice), not localhost or anything.
- For some reason, mongoose's NewUrlParser fails on mongodb://database:27017. Weird. Changed back to the (still default) old, deprecated one.
- You can clean up renamed containers with docker-compose up --remove-orphans
- The axios posts in the react frontend query the backend for blog posts and such. Previously, when everything was on one host, localhost was sufficient as an address here. I had to create a docker network and specify it for all containers that want to talk over it. https://medium.com/@xiaolishen/develop-in-docker-a-node-backend-and-a-react-front-end-talking-to-each-other-5c522156f634.
Monday, August 19, 2019
- Bought and smoked a pork butt. Served with homemade corn tortillas.
- Made new batch of cinnamon oat milk.
- Transferred banana hibiscus kombucha to the fridge after second fermentation. Was tasty, but not as sweet as usual because it fermented for longer than usual due to vacation. Lots of bubbles.
- Made new batch of pecan butter. This one was toasted (350F/5m), with touches of cinnamon, salt, and maple.
- Paid outstanding bill from Dr. Levy.
- Notes from the hawaiian imu:
- You're not smoking the meat, you're heating up rocks and then using them as the single heat source while insulated.
- Dig a pit. Wood on bottom. Rocks above that.
- Burn mesquite wood for a couple hours until the rocks are hot. Almost all of the flavor from the smoke is lost to the atmosphere.
- Banana stalks above the rocks.
- Pig wrapped in chicken wire and place on banana stalks. We only salted (no rub), and it was right before (not enough time to brine).
- Tea leaves above pig for flavor. Banana leaves above tea leaves for insulation.
- Wet burlap above banana leaves for humidity.
- Tarp above burlap for water insulation. Dirt above tarp for heat insulation.
- Come back in 8-12 hours. No probes!
- Every cut was pulled, not just the shoulders. Big pans of full-pig pulled pork.
- All around, a pretty archaic process. Almost all could be replaced with a barrel, just a metal cylinder for smoking. The biggest crimes are definitely the wasted smoke, no brine/rub, and the lack of closed-loop temperature control.
- It came out pretty tasty still. Hogs are delicious. Not fall off the bone tender - I expect it was probably at ~180F. The shoulderblades and hip bones were actually kinda hard to remove, which doesn't happen at 200+.
- No smoke ring, as expected because the pig wasn't exposed to wood fire.
- No bark. No convection. This is particularly tough because the hog is not a homogeneous cut, each region needs and saw different temps (uncontrolled).
- c10k was a challenge proposed to web developers a few decades ago: create a web server that can handle 10,000 clients at once. http://www.kegel.com/c10k.html. nginx was written in response to this challenge!
- Reworked the docker composition for bmahlstedt.com: https://github.com/brianmahlstedt/bmahlstedt.com/issues/9.
- Mongod was not an enabled unit on my machine, so when the laptop died on vacation, systemd did not restart the service on return.
- postgres default is 5432, mongo is 27017. Remember that you'll get binding address-in-use errors if you have the db running on the host and you try to start the container. Kill it on the host with `sudo systemctl stop <>` or change the port.
- Added the whole shebang. Dockerfiles for each container build, compose to bring all the services together, makefile to wrap the common service start commands.
- "Saturday night palsy" is a medical condition where you can permanently damage nerves by sleeping on them wrongly after drinking.
- Betsy wedding trip is the same weekend as the blake st socal trip. Planning miscoordination.
- Finished eloquent javascript and added all notes to drive.
- Watched the new lion king in the background. Was pretty good.
- MIME = multipurpose internet mail extensions. This is a spec for many things, the most common being content-type headers. All popular languages offer a module that can infer the correct mime types based on most common file extensions.
Saturday, August 17, 2019
- shift-esc for chrome task manager.
- 30+ articles from 20+ newsletters, MD/PW/FW/HN:
- Babel compiles es6 js down to older versions, for retro/crossbrowser support, as we know, but if there's an entirely new feature that the old js didn't support, it is called polyfilling.
- While es6 was a gigantic release in 2015, we're now on es10.
- Cool article on import symbols affecting how mocking works: https://nedbatchelder.com//blog/201908/why_your_mock_doesnt_work.html. If you have a module product.py that does `from os import listdir` then you should mock product.listdir, not os.listdir.
- setTimeout() inside of a promise, can be pending, resolved, rejected. Can run different codepaths based on logic, bool, etc. Rejection will raise an exception (error out if uncaught). Promises can have a .then .catch .finally etc.
- OOP (classes) vs FP (functions). Functional programming is a more elementary structure. Pure, no shared state, easier to test, but can do less.
- PyPI stats: https://arxiv.org/pdf/1907.11073.pdf.
- Compound annual growth rate for active packages: 47% (total 178,592)
- Compound annual growth rate for new authors: 39% (total 76,997)
- Compound annual growth rate for new import statements: 61% (total 156,816,750)
- Average releases per package: 6.93
- Average inter-release timing: 65.38 days
- Average packages per author: 2.15
- Average package size: 16.5MB
- MIT license is 34% of all packages.
- 25% are stable/prod (not alpha, beta, inactive, etc)
- 58% crossplatform, 26% posix/unix, 9% mac, 8% microsoft
- A few react tools I can use: https://medium.com/better-programming/22-miraculous-tools-for-react-developers-in-2019-7d72054e2306.
- Webpack bundle analyzer. Shows deps and size.
- React-proto. Helps visualize component layout and more.
- Why did you render. Shows unnecessary renderings in your app.
- Nonsensical article complaining about uber: https://medium.com/radical-urbanist/i-dont-use-uber-neither-should-you-4e1009d0a238.
- I already do advanced to-do listing: https://medium.com/better-humans/this-alternative-todo-list-will-help-you-complete-100-tasks-every-day-aae1130faac8.
- React-pose is pretty awesome for animations on components: https://medium.com/@joomiguelcunha/amazing-react-animation-with-react-pose-3b67d9eb6e07. For simple stuff, css animations are fine, but for more complication view changes, js animations offer more control.
- "Brogrammer"
- GitHub Actions is the extension that allows you to do full CI/CD through your github workflow! https://github.blog/2019-08-08-github-actions-now-supports-ci-cd.
- UFC 241 in Anaheim. Didn't end up going, but watched live.
- Sent out the splitwise bills. House for wes/jcriss, rum fire for everyone, and 1 safeway trip. Settled for Eddie's airbnb.
Friday, August 16, 2019
- Home from Hawaii. Such a good trip.
- Uploaded my pics from both legs to their respective shared albums on google photos.
- Amazon fresh order. Cut and prepped all veggies. Made cacao oat milk.
- Bottled the banana hibiscus kombucha for second fermentation. Started the next batch (green tea).
- My raw cacao powder had a prop 65 warning for reproductive harm on it? https://www.p65warnings.ca.gov/fact-sheets/foods.
- App idea: single-click payment splitter. Similar to splitwise, but a few critical features. You push a button in the app on your phone, and it will check the most recent transaction on your credit card to populate the total. If that's not available, or you paid cash, you can take a single picture of the bill to populate the total. The app then autodetects your friends' phones in the nearby vicinity. It proposes those N people to split it with, then allows you to confirm (or add/remove people, changes portions, etc). Once the whole dinner/vacation/whatever is finished, you can settle up, integrate with venmo, etc. If all goes well, bill splitting becomes a single click of a button whenever you pay for the group.
- Fed mouse.
- Verified that my contact info was correct for both of my domains (required by ICANN).
Wednesday, August 7, 2019
- Fantastic guide to forms in react:
- https://medium.com/@agoiabeladeyemi/the-complete-guide-to-forms-in-react-d2ba93f32825.
- Remember, react doesn't have native form handlers like angular.
- You have uncontrolled input (regular <input> fields in html) and then controlled input fields, where you bind that to the state and keep it up to date with the backend db usually (like the blog post body field in my app).
- Checked in to hawaii flight. Annoying to have to pay to check a bag ($30). There's gonna be traffic on the way to a 9am flight, and LAX is under construction, so I'm gonna take the bike.
- To rename a variable during an es6 obj deconstruction, do `const { key: newName } = obj`
- Added password protection to form submission in the blog component of the app (rather than the whole route, so people can still read). It's simple for now, just an env var defined at server start, and an <input type="password"> field that it checks before creating/editing and a prompt before deleting any blog posts in the db and frontend.
- axios' delete method passes data. post passes body.
- PM2 is a very popular process manager for node. It can be used to start an express app, like `pm2 app.js` instead of `node app.js` or nodemon app.js`.
- Created the ticket for and started working on the container deployment of the new apps that make up bmahlstedt.com: https://github.com/brianmahlstedt/bmahlstedt.com/issues/9. Will finish when I get back from Hawaii in a week!
Tuesday, August 6, 2019
- Chrome extensions.
- Many websites use your cpu without your consent to mine crypto. There are extensions that block this, but they become outdated pretty quickly.
- Added JSON formatter. Makes json responses look pretty.
- OctoLinker turns import/require/include statements into links (on github), so you can jump to other projects quickly.
- Octotree adds a muuuuuch better directory tree on the left sidebar of github.
- And Refined Github. So many improvements to github UI/UX.
- My current list:
- Worked on bmahlstedt.com more.
- Figured out the error from the end of yesterday where the blog component wasn't rendering in the multiroute site. It's because the NAMED import of your reducer gets added to the store by the same name. So if you add the `blog` reducer to the store, then your component's mapStateToProps should have `articles: state.blog.articles`. That `blog` string must match. It wasn't because the db was empty, the state.home object was truly undefined (bc it was state.blog instead).
- Added the scss back (scss = sassy css which is a different preprocessor than sass but basically the same intent).
- Deleted the blog repo from github (it was merged to my main portfolio.
- Installed bootstrap and its two reqs, jquery and popper, into node modules as deps of the project rather than from CDNs in the root index.html. Then all you have to do is `import 'bootstrap/dist/css/bootstrap.css';` if your main index.js. If you want to customize, you can add those scss files and import them below. https://facebook.github.io/create-react-app/docs/adding-bootstrap.
- Then I uninstall bootstrap popper and jquery and instead used react-bootstrap. It is all (most) of the pieces of bootstrap rewritten as react components. It doesn't need jquery or any of that.
- Then I decided to go back to native bootstrap. I didn't like how react-bootstrap forced you to write style and layout and such in react-specific syntax. If you ever switch the view library, it's more work. You don't have html and css and standard bootstrap syntax, you have react-specific bootstrap syntax.
- If you want the "active" capability, you also can't go directly through react-bootstrap. That state is held by react-router, so you're better off just using NavLink from that package.
- Applied both the default class and active class to the NavLink component itself, rather than surrounding it with a <button> or an <a> tag. This made it much cleaner. I'm getting better.
- Cleaned the whole oven interior from the jerky drippings months ago. Terrible chore, but the smoke output is much less now. I'll never make the mistake again of not covering the bottom or putting a collection tray on the lower rack.
- The public/manifest.json file is just to describe metadata about the web app (author, homepage, etc). It's like some of the content in setup.py. It's where a homescreen shortcut would pull data from on a mobile phone, for an example API that manifest.json hooks into.
- NPM
- Two cool specifications for versions constraints.
- ^ means that it will take any minor version and patch version but will wait on major versions. For example, ^1.2.6 means that it will take 1.3 or 1.8.9, but will wait on 2.0.
- ~ is similar, but only for patch versions. It's more restrictive. It will not autoupdate to any major or minor version.
- Installed the new 6.10.3 patch version of npm.
- To regenerate package-lock.json based on updates to package.json or other, just run `npm i --package-lock`.
- npm uninstall <pkg> to remove it from package.json and the lockfile.
- Github detected a few vulnerabilities in dep versions again: open, mime, braces, eslint, js-yaml, webpack-dev-server. This is such a cool feature. Ran the bot to attempt to autofix the minpins. Dependabot couldn't resolve, so I explored a bit manually: `npm audit fix [--force]`.
- The issues were all transitive through an old version of react-scripts that I had pinned from an old tutorial. It was <1, whereas the most recent major version is 3.X.X.
- Nice, bmanning@co's website for the new company: http://www.xonaspace.com/. Quick wordpress. No encryption tho.
- Reread a bit of the bootstrap docs for layout. Remember the grid system: container, row, cols.
- For cols, the numbers add up to 12 bc it's divisible in multiple ways. You could have 2 equal width columns col-6 and col-6, or col-2 col-4 col-6 for 3 columns of increasing width.
- The letters xs sm md lg are for what size screen (device) you want these to apply. Mobile vs monitor etc.
- "col-lg-6 offset-lg-3" would be a cell that is half the screen width, offset to be centered (3-6-3).
- Bootstrap also has cards (used for my vertical blog posts), card-body and card-footer etc.
- Got the 3 mobiles apps for the flight legs, in order: united -> hawaiian -> american.
- Remember, my meal prices summarized: breakfast shake $2, lunch smoothie $4, veggie juice $3, dinner meat $3. Total daily ~$12.
- Downloaded Eloquent Javascript and Data Structures and Algorithms Made Easy as kindle books for Hawaii and the flights.
- Jest is a testing framework for js, just like jasmine. Jest can do more. Jasmine doesn't use a dom so it doesn't need a browser. It's great for node development, because it only needs javascript. Jest, on the other hand, is more comprehensive. It does use a dom. It's more popular.
- @myorg/mypkg is for scoping npm installs. It means that the package is owned by a certani group. This can be used for companies, or for open source things like @types/node. Then it will install all the package suffixes into node_modules/@types/*.
- Typescript.
- I'm not using babel/webpack directly, since I started with create-react-app. It uses react-scripts instead, which uses the js api for webpack instead of you using its cli directly in your build scripts.
- All I had to do was npm install typescripts and the many @types/*, then rename my js/jsx to ts/tsx.
- find . -name "*.jsx" -not -path "./node_modules/*" -not -path "./build/*" -not -path "*.json*" -exec bash -c 'mv "$1" "${1%.jsx}".tsx' - '{}' \;
- And the same with js/ts.
- Then restart the client app (npm start).
- src/index.ts has the main ReactDOM.render(<...>) syntax, so I had to rename it to tsx so it would compile. Without the x, that is (of course) not valid javascript/typescript.
- The @types/* libraries contain *.d.ts files, which are declarations for types.
- React passes a lot of ANY types around implicitly, like for props that can be flexible. It's better to be explicit about all of that and predeclare what objects your props are, but for now I'm just specifying them as (props: any).
- There are vim plugins for typescript so that you get the desired syntax highlighting.
- Ended up not fully implementing this; reverted back to js. I got my hands dirty enough for basic familiarity.
Monday, August 5, 2019
- Added routing to my portfolio site, one for the current bouncing logos and one for the separate mern blog that I had built. Used react router v4, which is dynamic.
- https://codeburst.io/getting-started-with-react-router-5c978f70df91
- https://github.com/brianmahlstedt/bmahlstedt.com/issues/3
- All of the magic for npm start/build/eject/etc with create-react-app comes from the other package react-scripts. This is the same as flask-script.
- Added basic routing (react-router-dom.Router).
- Then added navigation links to the available routes (react-router-dom.Link).
- Then added 404 not found for routes that don't exist (react-router-dom.Switch).
- Then added url parameters (/user/:id in the route, which comes up in this.props.match.params.id in the component).
- You can add nested routes, where one component is rendered in one route but then you load a subcomponent within that calls another route. I implemented this for practice, but then removed it because each of my SPA routes are mutually exclusive, but then added it back for practice again.
- Changed Link to NavLink, where you just add an activeClassName css class that defines how to style the current link.
- Remember the `exact` keyword for some react elements so that the route must strictly match in order to apply. Otherwise, /hello would try to apply both / and /hello because it technically matches both routes.
- Automatic navigation can occur on events as well. This is pretty easy. For example, if you submit a form, you can have it go back to the home page simply by onSubmit = this.props.history.push('/')
- Merged the separate blog and bmahlstedt.com apps, repos, and functionalities. It's now a single app with multiple routes; a home page, a logo page, and a blog page.
- I think that react-scripts assumes the entry point is src/index.js. I changed some component names around and npm start still worked. This is probably customizable, but I'll leave it for now.
- Consumption of red meat has been linked to increased risk of colon cancer. Not common in my family history, but 1 instance.
- Sesame seeds grow into the sesame plant! It's a little green shrub, as you'd expect, but it's a bit strange to think of anything beyond the seed.
- Cacao powder is raw cacao bean (with fat removed and made into butter). Cocoa powder is roasted. You want the former, for its rawness.
- BOA deposit from ally cleared, moved a decent amount of it over to robinhood. That transfer can take up to 6 days, but it usually completes faster.
- You already know cross origin resource sharing (cors). Common use case: ajax to another domain. Other use: specifying when and where your assets can be accessed. Privacy.
- The browser makes the request, so the browser (not your service) first checks if it is going to another origin than the current site. If that other origin is not whitelisted with cors, the browser will reject it.
- Don't store images in databases. They're not built for it, and it can get complicated quickly. Most would suggest storing filepaths in the database that point to the respective images, so that you retain querying functionality etc.
- A grounding reminder that anxiety isn't real: https://blog.heartsupport.com/anxiety-is-nothing-more-than-a-fear-of-what-if-7677d3b5f508. It's just your brain extrapolating to the worst case scenario. "What if?" How about ... no?
- react-cookie is the package that makes it very easy to add cookies to your components/routes.
- 20 minutes daily of stim and traction are well worth it. My elbow and neck are feeling better.
- Remember TENS is for nerve stimulation (pain relief) whereas EMS is for direct muscle stim (contracting for muscle development).
- Read a little bit about smoking a whole pig in preparation for the imu.
- A 100lb hog takes about 12 hours.
- Main yield: ribs, shoulders (butt/pulledpork), loin/tenderloin, and ham (legs).
- 250 is a good temp (lower is better, since you have different cuts and want equalization, but too low and it takes foreverrrr).
- Edible meat is about 40% of the original weight.
- The hog is gutted to the ribcage. It's not spatchcocked, but it is opened and laid flat in a similar manner.
- Dry brine with salt before, then wet brine with olive oil and/or mustard. You want crackly skin. Rub the inside of the ribcage as well.
- Overall, not too different from my smaller sessions. The biggest complexity: cutting.
- Looked up the process for replacing the bent shift fork on the ninja's second gear. It's only slightly more than replacing the clutch plates. You drain the oil, open it up, remove the transmission assembly, then replace the shift fork. Each shift fork is $86.
- Pastrami and corned beef are both just cured for a week in a wet brine before cooking. You can add spices (juniper, mustard, celery, coriander, etc) or just use salt for the brine. The difference is that pastrami is usually smoked after curing, and corned beef is usually boiled. Another difference is that pastrami is usually a fattier beef cut (like the point) whereas corned beef usually starts with a leaner cut (like the flat).
- You can technically cure and smoke anything else - you could make pastrami beef ribs or pastrami pulled pork. It's most common with beef cuts, but you can obviously cure any cut of meat in a wet spiced brine.
- style="visibility:hidden;"
- Remember, chrome devtools has the react extension which gives you the full virtual dom, state/props for all components, and the ability to profile.
- Git won't just stop tracking a file if it's already staged, even if you added it to gitignore. You need to run git rm -r --cached <path>
- Updated and relaunched chrome.
- Good airbnb style guide for react: https://github.com/airbnb/javascript/tree/master/react.
- Use .jsx extension for files containing react components. Just use js for others. It doesn't formally matter (the compiler takes care of it anyway), but it allows for separation of files in eslint targets, and stuff like that.
Sunday, August 4, 2019
- MERN.
- If the backend uses newlines and the frontend uses breaks (almost always the case), you don't need to do any casting. Just have the browser interpret it properly with `white-space: pre-line;`.
- It goes without saying, but the mongo db persists across both server and client app restart.
- Last quarter, netflix posted its first subscriber decrease in 8 years.
- Pre-fork worker process model is exactly as it sounds. Before a request comes in, the web server will pre-fork the master process into many.
Saturday, August 3, 2019
- Typescript is awesome (as are the typing features of py3). I continue to save time as I convert.
- Closures are just the nomenclature for something most programmers already do. You have an outer function that defines some variables, defines an inner function that uses the variables, then returns the inner function for use. In this way, the actual function keeps a set of variables in scope however you choose. This can be for privacy, persistence, whatever. Example:
- outer = function() {
- var a = 1;
- var inner = function () {
- console.log(a);
- }
- return inner;
- }
- Coffee beans outgas too, just like I noticed on my sesame seed bags. That's why they put those one-way valves in the coffee bags.
- I'm wary of bookmarking financial sites. If anybody gets the google creds, they can get a lot. However, if they get those creds, they can get a lot anyway (email, amazon, phone, etc).
- UFC on the east coast, which is awesome because the prelims start in the MORNING here.
- The current administration is taking some misinformed stances on encryption; that it's scary, crime-enabling, etc. The privacy and security of 99% of the world's communication is more valuable than the exposure of 1% of criminal texting. Here is a similar argument to show its fallacy: we should ban doors on homes because they enable criminals to elude law enforcement.
- LA's population is over 10 million.
- Articles like this are so sadly off-target: https://medium.com/s/for-the-record/i-do-not-know-how-to-trust-thin-people-fbe78e633a50. Spreading this false lens is not good. You could rewrite the entire article in a light that doesn't tarnish body positivity, switching a single word, and perhaps it would be more clear to those that believe the post:
- "I get drunk every day. I do not trust people who drink alcohol once a week, once a month, never, or any frequency less than mine. I indulge in it because it feels good, temporarily. I drink the next day again to persist the endorphin rush. Others do it less, and I acknowledge that. But I can't respect it. I know this disposition might be bad for my health, but the short-term satisfaction is important to me. There are other explanations, of course. I'm predisposed to like the rush. I'm dealing with stress, and the seratonin helps me cope. My mind has a propensity for the addictive nature. I was born with a body that enjoys the stimulation more than most. But that's ok. I'm happy with myself. I know that this pattern affects me physically. It affects others, as my behavior changes. I wear the consequences of my routines visibly on my body: the bags under my eyes, the smell, the hands clutched to my headache. Others can notice my habit, and they judge, but I can't trust them. They're biased. They don't do it as often. They indulge less, so they can't understand. They're not concerned for me, they're just condescending. They suddenly turn into public health authorities, thinking they know anything about my situation. Friends judge. Strangers stare. Even doctors. But the science is not clear. And they obviously don't care about me, they just see my body as a walking manifestation of this so-called self destructive habit. I can't trust people who refuse to get drunk every day."
- There are no tigers in africa?
- Worked a lot on the MERN stack again, building my portfolio site.
- Read a little bit of the react-router and react-router-dom docs. I'm no expert yet, but the full picture is slowly becoming more clear.
- Removed title and author from the blog post components. Don't need em.
- Just some easy reminders, coming from more familiarity with pip syntax. npm init to enter a wizard that adds a package.json to your cwd. npm i to install. Add -S to save it as a dep, which means adding it to package.json. Add -D to save it as a development dependency. When you npm i in a fresh clone with the package.json, it will create a node_modules folder and install all your deps locally into it.
- When you install core, it prints "Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)" - yikes. Ads in packages. At the CLI. Nice UX...
- Got the client and server apps both working again, cleaned the repo, committed.
- Here is my diet, every single day:
- Breakfast shake: assorted powders (~$1), homemade oat milk ($1)
- Lunch smoothie: kale ($1.79), tomatoes ($0.79), banana ($0.30), turmeric ($0.20), ginger ($0.10), beet stalks (counted for beets instead)
- Preworkout juice: carrots ($0.75), red cabbage ($0.75), celery ($0.40), beets ($0.75)
- Dinner: almonds ($0.40), smoked meat ($2.00)
- Sometimes I'll have a protein bar at the gym, which is $1.
- The veggies are organic, so the prices are a little bit higher than they would be otherwise.
- Powders: cinnamon, whey protein, creatine, cacao nibs, glutamine, lion's mane, maca, flax.
- Other than that, it's just coffee and water all day.
- Some of these are variable. Chicken vs beef, almonds vs seeds, etc, but the averages are close. Sometimes I'll do sweet potatoes for breakfast, yogurt, bell pepper snack, etc. It washes.
- This obviously is just recurring consumable costs, not single purchase items like blender or infrastructural recurrence like charcoal, spices, etc.
- Rounding up, that's $12/day to eat extremely healthily.
Friday, August 2, 2019
- The Ally transfer processed. I don't see it in my BOA account yet, but I should get a large deposit notification soon. I also had $0.02 left in my Ally account so I just submitted a req for that as well.
- Went through some practice interview questions for js-specific roles (which I'm not applying to). I could answer about half, which I'm satisfied with. After studying, I'll be able to get most. In any case, I'm seeking a full stack position.
- Read the tesla 2019Q2 report: https://ir.tesla.com/static-files/1e70a30c-20a7-48b3-a1f6-696a7c517959.
- Capex = capital expenditure (like overhead). Profit = revenue - capex.
- GAAP = generally accepted accounting principles.
- UrthBox was firm on "no" when I requested that they cancel the mistaken order (3mo subscription renewal), which was already shady. I pretended to enjoy their business, threatening the loss of future orders, making the decision to refund me lot easier for them. The agent spoke with his manager and magically found a way to cancel 2/3 of the order. This is a good strategy for dealing with cancellations/fees/etc. Paint the picture as a financial long-term strategy for them, rather than something subjective or political.
- Make sure to thank them after, even if you don't plan on continuing being a customer of theirs. Pay it forward, ensure this model continues working. If you ghost them, the threats lose value on the macroscale over time.
- app.use() requires a middleware function. You do this for express.Router(), but not for something like your models. You just require() those (import them, don't add them to the express app).
- 204 = no content. You might get some pending requests on an empty db.
- Always forget. lsb_release. Then use -h, or directly show version with -d.
- MERN.
- One of the reason my devtools network request was not responding (and I couldn't find logs) was because the service wasn't started (heh). I had begun the backend app days ago and had not restarted it once I had finished with the frontend. nodemon app.js.
- Moving on to the redux and state portion.
- Wrapped the app component in both a router and a redux provider, which has a store that contains reducers. Then you basically tell it that the state is all the articles, have it connect to the db, map the redux state to react props, then display the props (articles, blog posts) in the react component.
- There was another part completely missing from the tutorial lol: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/. You need to have mongo both installed and running before it can obviously serve a localhost db, otherwise no data is being saved. Surprisingly ........ no errors from express when starting the app and trying to connect. At least not directly presented to the user in the cli. Yikes.
- Yup, that was totally why everything was busted. As I suspected above, the hanging requests were due to the backend waiting for db connections that ... didn't exist because there was no db. 1000% times better now, fast, clearer logs, everything.
- Finished the tutorial, got the baseline working. Now on to customization for my own purposes.
- Created a proper git repo for the blog and customized it.
- Remember, onsubmit is an event, the js function that executes when a form is submitted. onload is the same for when the page has loaded.
- ... in js is the spread operator. If you have an object with multiple properties, and you want to create a second object with 99% the same properties, just changing a few of them, define the second one with the spread operator on the first object. obj2 = {...obj1, changedProp: x}
- Mongo
- Add key, add apt source, apt-get mongodb-org, sudo service mongod start.
- Then remember, you can check logs with journalctl -u <servicename>, or look in /var/log
- 27017 is the default mongo port.
- Enter shell with `mongo`. Just type `help`. Pretty similar to psql and postgres in general. Don't need to terminate statements like psql.
- In the shell, show dbs, use <db>, show collections, <db>.<collection>.find()
- use <db> the db.dropDatabase() to delete one.
- moment.js is a great library for datetime manipulation, such as converting db timestamps into something relative to now, like "17 minutes ago".
- Backticks in javascript are template literals. You can execute code inside of them, to insert expressions (like variables, or math) into strings.
- If you're running the webpack dev server, you'll see "wds live reloading enabled" in the browser console.
- React: be careful when using arrays, and assign each element a unique key. This applies to situations where you might be mapping an arbitrary-length list from db.find(), and rendering a <div> row for each or something. React uses keys to make it more efficient about what changed and what needs re-rendering. For all child elements in a component that has a list, give each one a unique id. https://reactjs.org/docs/reconciliation.html#keys. This is usually pretty easy, since the raw data has a db id in most cases that you can just pass through.
- These tattoos made to look like patches are incredible: https://tattooblend.com/hyperrealistic-patch-tattoos-by-duda-lozano/. Would be so cool to get one of a mission patch. This is my official copyright on that idea.
- npm prune remove unnecessary packages.
- Went through all the redux docs and took notes (in a google doc). Makes much more sense in the context of the simple MERN app I just built.
- Remember the react tab of chrome devtools to help debug and should the whole react virtual dom and everything.
- In javascript, `new` will execute the constructor when creating an object.
Thursday, August 1, 2019
- Final closure on my ally account, realized gain: 6k. Basis was 10k started over 10 years ago to practice a little bit of private investment at the end of high school, got 60% overall.
- The ach from ally is on hold until tomorrow.
- Urthbox charged me another $90 for another 3 month subscription of snacks delivered to Eric's house. I never wanted this, it was a one-time gift. Their fine print is bullshit and I emailed their support team.
- cprofile is a good profiler for python. @profile is a built-in decorator for memory profiling.
- numpy.ndarray can only hold one datatype, so it's mucccccch more efficient than the generic python list (which has to allocate for flexible data types in every element).
- index.js are kinda like __init__.py files in python, spread through the project dirs to organize code and import/export availability within subpackages.
- In js, you can specify one and only one export as "default", which means that imports can call it namelessly. Otherwise, you name your exports and import them by name.
- form-control is bootstrap. my-3 is a spacing example for bootstrap, which sets margin top and bottom (y-axis) to 3.
- Dayum. Finasteride, propecia, antibaldness drug can can impotence and anxiety: https://elemental.medium.com/my-life-has-been-ruined-by-an-anti-baldness-propecia-finasteride-side-effects-ed8b2fcd1e90.
- Police have had facial recognition database for a while. They can identify from mug shots, videos of crimes, etc. https://onezero.medium.com/california-police-are-sharing-facial-recognition-databases-to-id-suspects-3317726d31ad.
- While most are scared of technology like this, I'm a huge proponent. The more data, the better, even if private. This is an accountability problem, not a morality problem. 23andme genetic data, facial data, crime data, advertising data - take it all. I don't have anything to hide, and data connections enable so many useful functionalities.
- MERN:
- High level index.js which does the ReactDOM.render().
- That imports components from other clean files, like a jsx that defines a Switch and a Route inside of a class or hook and exports it.
- AmEx anticipates vacations based on travel purchases, inferring that you'll be away during certain dates and allowing transactions while there. Pretty cool, and not that hard.
- Placed fresh order.
- Morgan is the js library for request logging with node express apps.
- Axios is a library (wrapped around ajax using xml http requests) that allows you to make promise-based requests from the frontend or backend.
- Smoked chicken breast for softball. Tenderization is so important. I used a valentina bottle to pound them flat lol. Bought an actual tenderizer online. Going to try the 48 blade puncture tenderizer instead of the mallet variety.
- NFL is back!! Preaseason week 1 tonight, TNF, broncos vs falcons.
- Trichinella dies at 137F. Salmonella dies at a higher temp, and it takes a bit longer. Getting it above 160 is fine, 165 is even safer.
- Robinhood: Bought beyond from my interdigital sales. Also sold seagate today.
- Ally: Cleared final holdings, microsoft and tesla. I'll reup msft in robinhood.
- Paid rent while the money was moving around.
- It might be worth getting a stackoverflow account and starting to provide answers. The clout is a good bonus. Even better benefits: paying it forward + open source mentality.
- Brake fade is due to heat. Over long applications (braking all the way from like 200mph, or going downhill) the braking power decreases. Gas builds up.
- A strong thought I had today, and have had before: Convenience is the enemy of healthy eating, not flavor. It's so much easier to grab a granola bar or cereal, a sandwich or snacks. Healthy foods are usually ingredients which require some sort of effort to transform from their raw state into a usual meal. This is what makes good nutrition difficult. We have enough distraction and exhaustion throughout the rest of our days; to add more in a neverending task like meal prep is hard.
- To fight against this, I do as much prep beforehand.
- My morning meals have always been a shake. Instead of getting out the teaspoons and measuring 10 different powders every morning, I do it in a batch of 10 jars. Then breakfast is just pouring a jar into water in a bottle.
- I have a veggie smoothie every day. Instead of cutting and apportioning all the kale and tyogurt and carrots and all every time, I batch it all at once. Then a smoothie is just grabbing 5 items from the fridge, rinsing with water, then throwing in a blender and drinking.
- Same goes for carrots/beets for juicing.
- Same goes for bell peppers for hummus/snacks.
- Abstract route logic into other functions, then have your route definitions (decorations) be as simple as possible. This is called route middleware: http://expressjs.com/2x/guide.html#route-middleware. The middleware can be responsible for looking up a user in the database, requiring that someone is an admin, or much more. Then once the middleware accomplishes what it wants, pass to next().
- Read through the express 4 api docs.
- app.use(path, callback)
- If nothing is passed to the first argument for path, it defaults to the home route /, so applies to everything.
- This is exactly where you put your middleware logic, and then mount it.
- Pretty similar to flask all around.
- Read through the mongoose 5 api docs, the mongo shim for node.
- All around similar to sqlalchemy. Define the schema, connect to the db, validate against models, etc.
- Worked with briley for a minute on the hydra angular frontend.
- npm:
- sudo chown -R $USER ~/.npm again.
- -D is the same as --save-dev
- Webpack:
- Pip.
- webpack.config.js provides mores configuration for the package, extending package.json. Both are similar to setup.py. The webpack config allows specification of entry points, resolvers, loaders, much more.
- Can also be used to build your client app or start development (webpack-dev-server).
- Defines the main template to load, the js to run on it (react render, etc).
- Simple MERN blog app:
- Created the client react app, refreshed on the express/mongo backend and server app. Compiled with webpack dev, almost done.
- Webpack config has the entry point defined, which is /src/index.js. This is like main. It loads react and all the components + stylesheets.
Subscribe to:
Posts (Atom)