Share Something You Learned Challenge (week of September 26th)


#1

Rules:
1/ Reply with:

  • a sentence
  • a paragraph
  • some code
  • some notes
  • OR a link to a blog post, Github repo, or codepen
    … describing something you learned, or featuring something you accomplished

2/ Share something regularly!

3/ Anyone can participate

4/ You can post new learnings throughout the week.

Goal: get to 10 posts this week. I’ll start a new thread next week.


#2
  • Learned that I can sort by an object’s values and then alphabetically by an object’s keys using the standard javascript sort function simply by using an || operator, like so:
   sortable.sort(function(a,b) {
        return b[1] - a[1] || a[0].localeCompare(b[0]);
    });
  • In Django, do not type forms.CharField when you mean to use forms.IntegerField; otherwise, you will get a weird ISE.

#3

Today I learned that Slack bots almost certainly need to juggle multiple access tokens to accomplish meaningful tasks through the API.

  • Bot user tokens can’t have resource-based OAuth scopes added to them, any scopes other than bot requested during the OAuth installation flow have no effect on the bot user token
  • “Bots” typically switch between using both a bot user token and any number of user tokens to complete their operations

– Slack: Token Types

Whilst it is possible for a bot to post messages using the ‘bot’ token, it isn’t possible to search for channels or messages unless you switch to using the ‘bot user’ token.


#4

This week I began learning linked lists. I had a misconception about how hard or complex they would be, and I was happily surprised to learn that they aren’t too bad.

A linked list is different than an array in that is fixed sequentially. The way this is accomplished is that in addition to each node of data in the linked list, they have a location pointer field that has information about the next item in the sequence or the last item in the sequence.

A doubly-linked list contains both.

The implementation of a linked list appears to usually be declaring a node class and a linked list class. In this structure, you instantiate the nodes with the node data, and the pointer value indicating where that node lives in the sequence.

It looks like the linked list class is responsible for changing the pointers if you needed to insert a node or delete a node and update the remaining pointers accordingly to fit the new entry into the sequence.

Now that I know the concept isn’t as hard as I was picturing, my next step is to start practicing using them.


#5

This is great. Have you tried implementing one from scratch yet? If not, this could be an interesting thing to try benchmarking and see the relative efficiency of various operations.


#6

A few sqlite3 commands I learned today while working on Django side project:

  • .database
  • .table
  • .schema auth_user
  • .indexes

SELECT commands are normal.

Gah, should probably just create a MySQL DB and connect it locally.


#7

Today I learned…

There can be numerous ways to do one thing in vi or vim. To save and exit the file, in command mode, you may type any of :wq, :x, or ZZ.

You may access unix commands from within vi by using an exclamation point after a semi-colon and preceding the command, such as :!rm file.

The last one I found interesting is that you may suspend vi on some systems by typing CTRL-Z to return to your command line, and to resume using vi, type fg.


#8

In continuing my exploration of my tools, today I learned…

Vim comes with its own file explorer accessible from an open file with the command :Explore. This file explorer is the first thing you see if you open a directory in vim, which is what I did unknowingly and, at first, I did not realize what I was looking at. I now can navigate between files within vim… kind of.

Also, just tested that :e . does the same thing as :Explore.

This technically wasn’t today, but I used it again today. Those git config --global things can also be done with --local instead of --global. Obviously this configures settings for the current git repository. The settings file for the current repository is available inside a repo’s .git folder, called config. So, instead of ~/.gitconfig for global settings, you might edit [repo-root]/.git/config. I’m using these tricks to practice configurations without messing with my global setup.

I also figured out how to use split panes in iTerm2 on the Mac. CMD-D splits side-by-side (new on the right), and CMD-Shift-D splits above-and-below (new on the bottom).

I feel my tool-savvy growing exponentially.