• Started watching schitt’s creek. Good show.
    • Horribly verbose article, but centers on an important piece of advice: https://medium.com/better-humans/how-to-read-academic-content-once-and-remember-it-forever-e44f26d82566. After you learn something new, summarize it to yourself every morning for the next week. This will force you to retain the information, it will require that you understand it enough to explain it, it will remind you of the small corners that are easier to forget, allowing you to look them back up, etc.
    • Went to Benihana.
    • Added the chrome extension “Improved YouTube” – it now defaults to 1.5 speed, removes all ads, and equalizes volume.
    • The new meat tenderizer works incredibly. It uses the spike grid instead of just a mallet. Flattened >1lb breasts to under a quarter inch. Smoked curry chicken.
    • Blake St. fantasy draft.
      • This channel doodlechaos is so cool: https://www.youtube.com/watch?v=vcBn04IyELc&feature=youtu.be. He syncs classic songs with that line rider game.
      • Finance.
        • Great article on algorithm trading: https://medium.com/s/story/predicting-the-stock-market-is-easier-than-you-might-think-4f1e0bc05cfe.
        • As a nonprofessional trader, your best bet is to follow exactly what the smart money (professionals) are doing. Jump on their trains. You can’t outsmart them, and they have a much larger influence on the market.
        • Remember, the word for technology in the investment banking + hedge fund profession is FinTech.
        • GDP is a fantastic predictor for success.
        • ISM = institute for supply management. They publish a monthly index, based on hard data, about how the economy is trending. 50 is neutral, 0 bad, 100 good.
          • If it’s hovering above 50, that’s good and you’ll see bull growth in most markets.
          • If it’s increasing, no matter where it currently is, that’s good and you’ll see bull growth in most markets.
          • If it’s hovering below 50, that’s bad and you’ll see bear decline in most markets.
          • If it’s decreasing, no matter where it currently is, that’s bad and you’ll see bear decline in most markets.
          • Therefore: Buy when ISM is below 50 but trending upward after a valley. Sell when ISM is above 50 but trending downward after a peak.
          • Example report: https://www.instituteforsupplymanagement.org/ISMReport/MfgROB.cfm. This is so useful. Given the current state of slight growth but slowing rate, the advice would be to sell soon when it plateaus.
        • PMI = purchasing manager’s index. JPMorgan publishes this. It’s including in the ISM report. Same general idea.
      • There are tons of other css libraries out there for frontend besides bootstrap: bulma, spectre, tailwind, ant, foundation. They’re similar: bunch of classes to help lay out and style sites. Most use flexbox for gridding like bootstrap, as well as offering many similar components and utilities. Some are pure cs, some have features that require js and offer a corresponding bundle.
      • Added logos to the supercontest readme: https://github.com/brianmahlstedt/supercontest/blob/master/README.md. Took a while (annoyingly) to get the md/html rendering to jive, and I did it on master like an idiot, but it looks much better now. If ever I want to do this on another landing page, it will just be a copy-paste.
      • Made walnut butter. Still good, but my least favorite of the nut butters by far.
      • Alembic is written by the same guy who wrote SQLAlchemy.
        • Solid pier night for wes’ farewell yesterday. Saw Dom Mazzetti from broscience at tower 12, said wassup.
        • Reread a lot of the bootstrap documentation for tables and forms.
        • Supercontest.
          • Updated the week_matchups and week_picks templates to use bootstrap tables properly.
          • Pale green, light coral, and khaki were the primary colors – now it’s table-success, table-danger, and table-warning.
          • Added routes and nav buttons for /graphql and /graph, the latter being split from the lb into its own view.
          • Added season to the pick and matchup tables. Created two migrations: one for the new col without the NOT NULL constraint, then another to add it. Since the db exists already, you do the first, backfill all the values as desired, then do the second.
            • Psql cmmand to write all the values: update public.pick set season=2018; commit;
            • Manually edited the alembic migration to do this all in a single version file: add col, set value, add null constraint.
          • Flask can’t do nested blueprints, so I basically converted week_blueprint to season_week. The matchups and picks routes use both. The leaderboard and graph routes only use season. Added similar url_defaults and value preprocessors for g, where many of the subsequent db queries are dependent on season now.
          • Season addition was a lot of work. It was a nontrivial uprooting of most views/templates/models. Every db interaction basically had to be updated to specify season now.
          • Reorganized the template hierarchy so that everything wasn’t just in layout.html anymore. It’s a lot cleaner now, nesting all the nav rows and everything. Each template has a corresponding js file (for the most part).
          • Active-navlink logic is universal now. All have the id nav_<route>, then it just inspects window.location.pathname.split(‘/’).includes(id) to add the active class. All navs do this except the week navs, which work slightly differently. They don’t just display all available weeks, they display all 17 from the beginning, and disables the ones that aren’t available yet. This is because the nested grid, 17>12. It’s easier to just lay out the structure and fill it in as it comes, rather than make the html grid nesting dynamic. It distinguishing these ids to loop over by using weeknav_ instead of nav_.
          • Added a function is_today() which does the str-int mapping for days of the week. This is already being used for restricting picks wed-sat. I added it to the fetching of scores on the /matchups route as well, so that it only checks the nfl scores if it’s a gameday (thurs, sun, mon).
          • Ran into some problems because datetime.now() type objects are off in the docker container locally, as well as on the digital ocean droplet. Looks like they’re just utc:
            • bmahlstedt@bmahlstedt-xps13:~/code/supercontest$ docker-compose exec -T supercontest-app-dev date
            • Sun Sep  1 05:18:22 UTC 2019
            • bmahlstedt@bmahlstedt-xps13:~/code/supercontest$ docker-compose exec -T supercontest-database date
            • Sun Sep  1 05:18:33 UTC 2019
            • bmahlstedt@bmahlstedt-xps13:~/code/supercontest$ date
            • Sat Aug 31 22:18:39 PDT 2019
          • Fixed by adding the following to the dockerfile:
            • RUN echo America/Los_Angeles >/etc/timezone && ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
          • Flask appends any unused values as query params, so for the lb/graph I had to remove the week info in url_defaults and value_preprocessor. Only need season.
          • Switch from nav pills to tabs to better imply hierarchy.
          • Closed the season ticket: https://github.com/brianmahlstedt/supercontest/issues/54.
          • Changed everyone’s name (on the prod db) to properly split first and last.
          • Deployed to production.
          • Emailed everybody with the new site and instructions. Done! Last items will be wednesday’s smoketests when the lines are released.
        • The new joker movie is apparently phenomenal. https://www.youtube.com/watch?v=zAGVQLHvwOY.
        • Impunity is the same root as punish, immunity from punishment.
        • The flask-scripts/python/alembic migrations all operate on a local database, so you have two options: run the commands in the db container or copy the db over and run the commands on the host. In order to do the former, you’d have to bloat the db with system apps like python, so I’m going to do the latter.
        • ctrl-t as a vim shortcut for tabs conflicts with ctags’ shortcut ctrl-t to jump back a definition. I find the latter more useful.
        • zip(*iterableWithNestedIterables) is how you unpack in python! Never knew that was the inverse of itself.
        • 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.
        • 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.
        • 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.
            • 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 1×2 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 1×3 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 1×2 pieces and seven 1×3 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 5×5 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: 3×1 horizontally, 3×1 vertically, 2×1 horizontally, 2×1 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.
                  • 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.