• Avengers Endgame. I’ve never been a fan of comic book movies. This one had a ton of hype, almost Avatar level. It was average. There is a lot of time travelling and then a big fight and they knock some stones off his glove and win. Who could have predicted such a shocking, unlikely ending.
    • PW: some cool app ideas to practice skills: https://medium.freecodecamp.org/here-are-some-app-ideas-you-can-build-to-level-up-your-coding-skills-39618291f672.
    • Supercontest.
      • Unittests.
        • Had to `sudo systemctl restart postgresql` on my host before running the unittests. Remember, it requires an existing supercontest_unittests db. And remember, I do dev on this laptop as well, so postgresql doesn’t start on boot on my host (it would conflict with docker since I use default ports). Laptop must have died at some point.
        • Used spoof_lines and spoof_scores to populate the test db.
        • Had to install chromedriver on my host (unfortunate dep of the test now, I can fix later but it’s not urgent).
        • Added selenium capability to the tests so that I can actually check the data in the dom after js runs. I don’t do any click functionality to test registration or anything, just verification of the route APIs.
        • Changed to LiveServerTestCase from flask-testing so that I could use selenium. self.get_server_url is offered now. This slows down the tests a bit.
        • Loving selenium so far for unittests. Load a page, submit for data, click buttons, check results.
        • The webdriver API: https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.remote.webdriver. find_element[s]_by_[id,xpath,css_selector,name,class_name,link_text].
        • Changed commit_picks to allow bypass of all checks (on the python app side).
        • Did some color mapping between names and rgba values (which is what selenium returns for the background-color css property).
        • Finished all the python tests that I wanted: user/line/score/pick commit, frontend login, matchup/pick/leaderboard view. Now on to eslint and jasmine for the js.
      • Docker
        • There’s an image on dockerhub with python/chromedriver/chrome/selenium: joyzourski/python-chromedriver. Switched to that instead of basing off python and installing the webdriver functionality manually in the dockerfile.
    • FW/MD
      • Function declaration (definition) vs expression (anonymous). Obvious differences. Former allows a variable of global scope for callbacks, hoisting, etc. Latter less mem.
      • Change detection in a project usually means VCS changes for CI. Change detection in an app usually means frontend or backend. How does the view/controller respond when the model changes data?
      • In docker, `expose` in the dockerfile is just for documentation. `publish` (-p at the cli) is necessary to actually make the ports available. In docker-compose, `expose` in the yml is sufficient to do both.
      • Facebook internals. https://www.wired.com/story/facebook-mark-zuckerberg-15-months-of-fresh-hell/. Didn’t read the article because it’s way too long, but looked interesting.
    • The sharks/vgk game 7 last night was the best hockey game I’ve ever seen. The sharks came back from a 3-0 deficit by scoring 4 goals on a power play due to a 5m major. The knights tied it and pushed it to overtime, where the sharks scored to win. This sealed game 7 after coming back from a 3-1 game deficit in the series.
    • The Damian Lillard buzzer beater last night was also one of the best shots I’ve even seen. 37′ out, at 0 seconds, against Paul George, when tied, to end the series and knock OKC out of the playoffs.
    • Ordered new shoelaces. 54″ just for ref (medium high boots).
    • Jury duty summons can pull from registered voter pools or driver’s license pools (or both).
    • The “utm” you always see in ref links (like HN) is “Urchin Tracking Module”. Urchin is the predecessor to Google Analytics, and is simply a marketing tool. These 5 query params (utm_*) can be added to a URL to collect data: source, medium, content, campaign, term.
    • Did a couple typing tests. I’m about 90wpm with 95% accuracy.
      • Reapplied thermal tape to the compressor on the ducati yesterday to protect it from the exhaust pipes.
      • Dodgeball championships last night, was great playing with the team. I liked this group (cowbell).
      • Went to Slab (same as Trudy’s) BBQ today. Brisket was better than Bludso’s, chicken was about equal, and pulled pork sucked. They also didn’t serve chicken quarters, only halves, which is dumb. Total was $33, which is absolutely ridiculous – that’s the same price as an entire 10lb packer of USDA prime. Very thankful I learned to smoke at home. It’s better quality at about 1/10th the price, for the sacrifice of a little effort!
      • Soundcloud requires you to pay for premium mode to download tracks for offline.
        • Supercontest
          • Scrubbed testing.postgresql. Wasn’t configurable enough for my tests. Couldn’t do stuff like changing the default encoding of the db, so collation in the static model failed. Instead, I just defined a separate uri for test (with proper cleanup) and piggybacked off the host postgres installation (which is obviously then required to run tests….system dep agh).
          • Removed the collation=NOCASE remnant from sqlite in my models. Then I was able to get a successful unnitest env working. Test app connected to test db.
          • The problem now is alembic. The migrations require a local postgresql instance, so I can’t run them nominally on the host – I need to run them in the context of the container. Alembic enters through flask-script, which runs on the app container. So you can run a migrate operation while just connected to one container.  But the upgrade operation needs the migrate.py from the app container and the actual db from the postgres container, so who knows how that will work. I’ll have to look up the right way to use alembic with docker.
            • I guess you’d run the manage.py migrate/upgrade commands through docker-compose exec, not on the host. Ok.
            • Didn’t end up having to migrate since postgres doesn’t need the collation, but for future reference: `python manage.py db migrate/upgrade` needs to be run through `docker-compose exec app_dev/prod` now that you’re working in a container setup.
          • Testing.
            • Added extra_config_settings to get_app(), allowing direct flask args to be passed from elsewhere (like tests, where I suppressed mail and csrf).
            • Added tests to make sure all the user routes (login/profile/logout/etc) work.
        • Debugging.
          • You can run `python -m pdb <myscript.py>` or just put `breakpoint()` in your code.
            • Then you can step through with s.
            • To print, just use `p <var>`.
            • You can also check types, specify new variables, etc! `pp locals()` or globals as well.
            • `l` or `where` will list where you are in the script.
            • `exit` finishes.
        • Remember, a lot of system binaries (like echo) are at /bin, not /usr/bin or /usr/local/bin.
        • Security.
          • Bandit is a cool tool I started playing with: https://github.com/PyCQA/bandit.
          • Added to supercontest tox. I had no issues, just two (example) passwords I had to ignore with # nosec.
        • Internet fiasco.
          • They wouldn’t activate the new account because the modem (which I own, not spectrum) is still attached (maybe mac address) to the old account. After calling them and getting transferred 10 times, and briley doing the same, we finally got it working.
          • In the meantime, I went to a few Hermosa cafes for wifi. The new yellow one doesn’t offer public internet (lol) and gum tree gives out temporary codes which provide access for an hour (lol). What happened to cafes?
        • Indian BBQ.
          • My two favorite cuisines on the planet. Had a thought the other day they I might try some fusion with my smoker at home. Did some research, and nothing came up. I don’t think it’s a very common idea, since the origins of BBQ are the south, and there’s not much overlap between the south and India, at least culinarily. High-level smoked meat with curry-based rubs….sounds delicious.
          • Started first batch today. Curry jerky! Thinly sliced cross rib roast with some premix curry powder. I can play with the levels and finetune later.
        • My xps13 ubuntu18 suddenly couldn’t play sound and just showed “dummy output”. Running `pulseaudio -k && sudo alsa force-reload` fixed it.
        • HN
        • Exported my amazon data to google drive and ran some queries on it. Interesting.
        • Went to San Bernardino yesterday to hang out with Grandma and mom. Got Rosa Maria’s. Called Eric for his bday.
        • PW: GoT and Python https://medium.freecodecamp.org/how-i-used-python-to-analyze-game-of-thrones-503a96028ce6.
        • Guy on jeopardy has now won 10 games straight and holds the top FOUR single-day winning totals (from ~90k-130k). Total is 700k over 10 games. He’s got the second highest total now (non-tourney) after Ken.
        • Reapplied some thermal tape to the denali compressor. Noticed yesterday after the freeway riding that it was worn through.
          • The line between functional programming and OOP is way grayer than most silly online articles try to make it seem. If you have mostly fixed data, and you think your project will scale by adding functionality, then functional programming is a good fit. If most of the functionality is already modelled and fixed, and you think your project will scale by adding more data, then OOP is a good fit. Most projects are combinations of both.
          • Supercontest
            • A good software design reminder: separate functions that read/write data from those that analyze the data. For example: the function that calculates if a pick is good. It queries the picks and matchups, does the math, then commits the results. Instead, it would be better as two functions: one that does the math, then a wrapper that does the query, calls the math func, then does the commit. This makes it a lot easier to unittest. You can write one just for the analytical part, then another that tests the db interfaces.
            • Webtesting options.
            • The dev containers (flask and postgres) only consume about 10% memory (maybe 300MB). Not much cpu diff.
            • Unittests.
              • Changed get_app to accept a URI to make unittesting easier (creating a temp postgres db).
            • Remember the javascript analogs for python:
              • python=node, pip=npm, virtualenv=nodeenv, pylint=eslint, pytest=jasmine
            • Ran some delinting for javascript.
            • Did a little more bazel research. Still not the most useful thing for python, which doesn’t need to be built. Think of it like a make system. You have inputs, you have recipes that define what to do with the build, and then you have outputs (usually files).
              • The real power comes when everything in a highly complex system is built with bazel, because then you can define the deptree for the whole project/monorepo/whatever, even across languages.
              • Everything is a file, remember! This is why I think the python-package-support is a halfway solution.
          • Keanu Reeves founded a motorcycle company in 2011 named ARCH and it is headquartered in Hawthorne, CA!
          • Started using the whatsapp web app on my laptop. Convenient.
          • Also switched my default messaging (SMS) app to google, which has a web app. Texting from my browser on the laptop!
          • Changed the trackpad setting from area to fingers (1 anywhere for click, 2 anywhere for right click).
          • Reinstalled GNOME system monitor. Wasn’t working properly. Still amazed at how resource-hoggy chrome is.
            • Supercontest
              • Ansible
                • Falls back on paramiko (python) if openssh fails.
                • Setup
                  • sudo apt install ansible (this gives ansible-playbook and others)
                  • added southbaysupercontest.com to /etc/ansible/hosts
                  • ssh-agent bash
                  • ssh-add ~/.ssh/digitalocean
                  • ansible all -a “/bin/echo hello”
                • A lot of ansible’s power used to be the composition of various microservices, which docker-compose is a much simpler alternative for. It still has relevance in fleet management, however, and that’s what I’ll use it for.
                • Refamiliarized myself with their documentation.
                • I could just write a shell script to ssh, git pull, run the make target for docker-compose, then rsync dump files back and forth, but I’m gonna use ansible just for fun. It will enable scaling, load balancing, and more later (if need be).
                • Added playbooks to deploy the whole app remotely from local, as well as backup and restore the db. You simple enter through a oneliner make call, which farms out to ansible (which goes back and calls other make recipes).
                • Closed ticket #10.
                • Did a few test deploy/backup/restore operations between my laptop and the production server.
                • Upgraded docker-compose to 1.24 on southbaysupercontest.com. The py apt version was installed.
              • Unittests
              • Chromedriver
                • Tested the linefetching capability in the docker container. There were holes.
                • libnss3 was necessary for chromedriver.
                • You also need the chrome binary. Added.
                • Couldn’t verify end-to-end without some spoofing, because westgate has no lines during the offseason.
                • Here is another awesome script: https://gist.github.com/ziadoz/3e8ab7e944d02fe872c3454d17af31a5. If I have any problems at the start of the 2019 season, I can just add that to app/Dockerfile.
            • You can’t band-aid a poor engineering decision with software: https://www.youtube.com/watch?v=H2tuKiiznsY.
            • To rebalance panes in tmux so they’re equally spaced, used ctrl-b then alt-1 (vertical) or alt-2 (horizontal).
            • Python 3 natively keeps command history across interpreter sessions (like ipython does). Very convenient.