diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-12-03 14:16:25 -0500 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-12-03 14:16:25 -0500 |
commit | b7ff77b1b3cd271944661d6adfeed4b9ccdc8a10 (patch) | |
tree | 5ab405fd90fd311d328dca058b2bfc66e2d8fb4a /2022/captions | |
parent | bccbe28d87edbaa62f742f35ac22745b7b7fd472 (diff) | |
download | emacsconf-wiki-b7ff77b1b3cd271944661d6adfeed4b9ccdc8a10.tar.xz emacsconf-wiki-b7ff77b1b3cd271944661d6adfeed4b9ccdc8a10.zip |
Add captions
Diffstat (limited to '')
-rw-r--r-- | 2022/captions/emacsconf-2022-realestate--real-estate-and-org-table-formulas--daniel-gopar--main.vtt | 1739 |
1 files changed, 1739 insertions, 0 deletions
diff --git a/2022/captions/emacsconf-2022-realestate--real-estate-and-org-table-formulas--daniel-gopar--main.vtt b/2022/captions/emacsconf-2022-realestate--real-estate-and-org-table-formulas--daniel-gopar--main.vtt new file mode 100644 index 00000000..ba11db44 --- /dev/null +++ b/2022/captions/emacsconf-2022-realestate--real-estate-and-org-table-formulas--daniel-gopar--main.vtt @@ -0,0 +1,1739 @@ +WEBVTT captioned by tom + + +00:00:00.000 --> 00:00:05.453 +Hey, I'm Gopar and this is the + +00:00:05.454 --> 00:00:07.639 +Real Estate and Org Mode Table Formulas talk. + +00:00:07.640 --> 00:00:09.879 +Not very creative, but it is what it is. + +00:00:09.880 --> 00:00:13.051 +Now I just want to say that everything I talk about here + +00:00:13.052 --> 00:00:15.902 +is in the Org Mode in the Emacs manual. + +00:00:15.903 --> 00:00:17.909 +I posted a link to the web version, + +00:00:17.910 --> 00:00:20.479 +but it should be inside of Emacs as well. + +00:00:20.480 --> 00:00:25.096 +Now before I start, I want to showcase the end goal. + +00:00:25.097 --> 00:00:26.806 +That way you know if you guys want to + +00:00:26.807 --> 00:00:28.739 +actually see the talk or not. + +00:00:28.740 --> 00:00:30.491 +So I always think that's pretty cool to see + +00:00:30.492 --> 00:00:31.517 +what you're actually going to build + +00:00:31.518 --> 00:00:32.679 +before you start building it. + +00:00:32.680 --> 00:00:34.285 +Alright. So let me start off with the goal, + +00:00:34.286 --> 00:00:38.762 +the end goal. Here we have a simple table formula + +00:00:38.763 --> 00:00:42.613 +and we have some constants, some values inside the list-- + +00:00:42.614 --> 00:00:44.639 +inside the table, I'm sorry, + +00:00:44.640 --> 00:00:47.672 +and some other stuff that we will get to, + +00:00:47.673 --> 00:00:49.279 +but for now... I don't want to spoil too much. + +00:00:49.280 --> 00:00:50.327 +I just want to give you a demo + +00:00:50.328 --> 00:00:51.799 +of how it actually works. + +00:00:51.800 --> 00:00:56.094 +We have a few values. Let me first go over the constants. + +00:00:56.095 --> 00:00:57.581 +We have PMI, which stands for + +00:00:57.582 --> 00:00:57.590 +private mortgage insurance, + +00:00:57.591 --> 00:01:00.536 +so it's insurance that you'll have to pay + +00:01:00.537 --> 00:01:03.639 +depending on how much money you put into the deal. + +00:01:03.640 --> 00:01:06.067 +The property tax, which is self-explanatory, + +00:01:06.068 --> 00:01:09.316 +the tax that you owe for owning the property, + +00:01:09.317 --> 00:01:11.106 +and then home insurance, + +00:01:11.107 --> 00:01:13.439 +and the interest rate at the loan that you get. + +00:01:13.440 --> 00:01:15.666 +So, here we have a few columns. + +00:01:15.667 --> 00:01:17.411 +The first one is called House, + +00:01:17.412 --> 00:01:20.623 +which I usually just put a description of the house + +00:01:20.624 --> 00:01:21.126 +with the link of the posting, + +00:01:21.127 --> 00:01:22.493 +the price of the house, + +00:01:22.494 --> 00:01:26.189 +the percentage down payment (this I play around with + +00:01:26.190 --> 00:01:27.473 +to see how much the deal will be structured), + +00:01:27.474 --> 00:01:30.528 +the down payment (which is calculated from + +00:01:30.529 --> 00:01:31.754 +the previous two columns), + +00:01:31.755 --> 00:01:34.144 +the monthly mortgage (which is calculated as well), + +00:01:34.145 --> 00:01:37.995 +and then the tenant income (which is what I suppose + +00:01:37.996 --> 00:01:41.005 +would be an example of the tenant income + +00:01:41.006 --> 00:01:42.752 +that I can potentially make off the property, + +00:01:42.753 --> 00:01:45.539 +the 1% rule and the ROI. + +00:01:45.540 --> 00:01:47.707 +I'll quickly go over the last two columns. + +00:01:47.708 --> 00:01:49.200 +So first is the 1% rule. + +00:01:49.300 --> 00:01:50.879 +The 1% rule is essentially + +00:01:50.880 --> 00:01:53.588 +a "rule," in quotes, that says that + +00:01:53.589 --> 00:01:56.277 +if a property matches this specific formula, + +00:01:56.278 --> 00:01:58.319 +it is a good deal to look into. + +00:01:58.320 --> 00:02:00.889 +So for example, the first two pass, + +00:02:00.890 --> 00:02:02.676 +and the last one does not pass. + +00:02:02.677 --> 00:02:04.104 +The last one, at a quick glance, + +00:02:04.105 --> 00:02:05.471 +we can just ignore it and say, + +00:02:05.472 --> 00:02:06.476 +"hey, that's not going to fly," + +00:02:06.477 --> 00:02:07.999 +we'll just ignore it. + +00:02:08.000 --> 00:02:09.890 +I won't go too much into details. + +00:02:09.891 --> 00:02:11.519 +That's just a brief summary. + +00:02:11.520 --> 00:02:14.148 +So now the ROI is the return on investment. + +00:02:14.149 --> 00:02:17.599 +So it says "how much of a return am I getting + +00:02:17.600 --> 00:02:18.959 +on the amount that I invested?" + +00:02:18.960 --> 00:02:21.167 +So let's say you put in $12,000, + +00:02:21.168 --> 00:02:23.455 +and at the end of the year, you cashflow $6,000. + +00:02:23.456 --> 00:02:26.126 +So if you calculate the ROI off of that, + +00:02:26.127 --> 00:02:28.476 +you get a 50% return on investment. + +00:02:28.477 --> 00:02:30.085 +In two years, you'll make your money back, + +00:02:30.086 --> 00:02:31.733 +which is pretty good. + +00:02:31.734 --> 00:02:32.718 +Then all the rest of the years, + +00:02:32.719 --> 00:02:34.347 +you'll just slowly be reaping in all that, + +00:02:34.348 --> 00:02:36.639 +all the excess cash flow. + +00:02:36.640 --> 00:02:40.039 +But yeah, that's it in a nutshell. + +00:02:40.040 --> 00:02:42.269 +So let me demo it real quick. + +00:02:42.270 --> 00:02:44.258 +So for example, I'm going to change the down payment, + +00:02:44.259 --> 00:02:45.744 +but I want you to pay attention + +00:02:45.745 --> 00:02:48.213 +to this column [down payment] + +00:02:48.214 --> 00:02:49.839 +and the monthly mortgage column. + +00:02:49.840 --> 00:02:51.726 +So right here [down payment] is $25,000, + +00:02:51.727 --> 00:02:53.472 +and here [monthly mortgage] is around $1,200, + +00:02:53.473 --> 00:02:55.179 +a little under $1,300. + +00:02:55.180 --> 00:02:57.349 +So what happens if I say, you know, + +00:02:57.350 --> 00:02:58.795 +what I'm going to change the down payment + +00:02:58.796 --> 00:03:00.948 +to 5% instead, because I just + +00:03:00.949 --> 00:03:02.559 +don't want to put 10. + +00:03:02.560 --> 00:03:04.125 +So let's just put say 5. + +00:03:04.126 --> 00:03:06.274 +Then I tab out of here, and voila - + +00:03:06.275 --> 00:03:08.522 +you see it updated to half of $25,000. + +00:03:08.523 --> 00:03:09.946 +So now it's $12,000, + +00:03:09.947 --> 00:03:10.689 +and this [monthly mortgage] went up + +00:03:10.690 --> 00:03:12.233 +over actually $1,300, + +00:03:12.234 --> 00:03:14.783 +and then this [1% rule] hasn't changed at all + +00:03:14.784 --> 00:03:17.679 +and the ROI is there. + +00:03:17.680 --> 00:03:19.147 +So one thing that I should mention is + +00:03:19.148 --> 00:03:20.193 +everything that I'm putting here + +00:03:20.194 --> 00:03:21.279 +is just example numbers, + +00:03:21.280 --> 00:03:25.634 +should not be taken into literal real estate advice. + +00:03:25.635 --> 00:03:26.859 +I just want to put that out there. + +00:03:26.860 --> 00:03:28.367 +These are just examples to show you + +00:03:28.368 --> 00:03:30.519 +how you can potentially make it on your own, + +00:03:30.520 --> 00:03:32.239 +do the formulas on your own. + +00:03:32.240 --> 00:03:35.650 +Alright, so another cool thing that I did was + +00:03:35.651 --> 00:03:37.737 +if there is no tenant income and I tab, + +00:03:37.738 --> 00:03:40.048 +it says "Enter Tenant Income". + +00:03:40.049 --> 00:03:41.032 +So if I don't put anything, + +00:03:41.033 --> 00:03:42.399 +it will automatically tell me, hey, + +00:03:42.400 --> 00:03:44.919 +I can't calculate without the tenant income. + +00:03:44.920 --> 00:03:46.607 +I can also do this right here [ROI field], + +00:03:46.608 --> 00:03:48.475 +say the same thing, Enter Tenant Income, + +00:03:48.476 --> 00:03:50.563 +but I just didn't put it for whatever reason, but + +00:03:50.564 --> 00:03:53.812 +after this video, you should be easily able to + +00:03:53.813 --> 00:03:57.399 +put it without much struggle. + +00:03:57.400 --> 00:04:00.130 +Alright, so if that's something you're interested in, + +00:04:00.131 --> 00:04:02.239 +then keep watching. + +00:04:02.240 --> 00:04:05.239 +So let's go over the basics first. + +00:04:05.240 --> 00:04:07.399 +So, how do we create a table? + +00:04:07.400 --> 00:04:10.368 +Well, we can do M-x org-table-create. + +00:04:10.369 --> 00:04:14.301 +If we run that it, will prompt us in a minibuffer. + +00:04:14.302 --> 00:04:16.892 +It says table size, columns times row. + +00:04:16.893 --> 00:04:18.177 +Usually it's rows times columns, + +00:04:18.178 --> 00:04:19.502 +but it is what it is. + +00:04:19.602 --> 00:04:20.465 +So let's just leave + +00:04:20.466 --> 00:04:24.959 +the default of 5 times 2, and voila, we get this. + +00:04:24.960 --> 00:04:26.399 +Beautiful. Awesome. + +00:04:26.400 --> 00:04:29.510 +So the other way is using the magical C-c C-c + +00:04:29.511 --> 00:04:32.401 +in Org Mode, which basically is context-aware + +00:04:32.402 --> 00:04:36.053 +and does anything, does the right thing like, + +00:04:36.054 --> 00:04:38.599 +almost 100% of the time, which is pretty amazing. + +00:04:38.600 --> 00:04:42.431 +Alright, let's just say I write a pipe, some words, + +00:04:42.432 --> 00:04:44.679 +and then another pipe, Gopar, and then + +00:04:44.680 --> 00:04:47.268 +another pipe. Let's just say we're trying to + +00:04:47.269 --> 00:04:50.599 +write it out via text, because in Org mode + +00:04:50.600 --> 00:04:51.546 +everything has text. + +00:04:51.547 --> 00:04:53.379 +There's nothing fancy about it. + +00:04:53.380 --> 00:04:57.672 +If I do C-c C-c, Org mode should automatically be + +00:04:57.673 --> 00:04:59.839 +context-aware that this area is a table. + +00:04:59.840 --> 00:05:04.294 +So, C-c C-c, boom. So if I press enter, another column. + +00:05:04.295 --> 00:05:06.963 +If I press tab, it should automatically move me. + +00:05:06.964 --> 00:05:09.391 +So yeah, so that's pretty much it. + +00:05:09.392 --> 00:05:11.919 +That's how you get started into the column. + +00:05:11.920 --> 00:05:15.591 +So, I'm assuming most of the people here already know that. + +00:05:15.592 --> 00:05:17.959 +This is just the primary basic review. + +00:05:17.960 --> 00:05:19.807 +So, let's first go... + +00:05:19.808 --> 00:05:22.819 +Let's go dive right into our first formula. + +00:05:22.820 --> 00:05:24.766 +So I copied some values over here, + +00:05:24.767 --> 00:05:27.696 +just to save time, and the columns. + +00:05:27.697 --> 00:05:29.163 +So, let's go ahead and say that + +00:05:29.164 --> 00:05:30.749 +we have single family house, + +00:05:30.750 --> 00:05:33.018 +and the price is a hundred thousand. + +00:05:33.019 --> 00:05:34.163 +And, Let's say that I want the price, + +00:05:34.164 --> 00:05:36.431 +the down payment that I want to put is 10%. + +00:05:36.432 --> 00:05:40.527 +Right. Alright. 10%. Now if I tab + +00:05:40.528 --> 00:05:42.393 +or go to the next column, nothing happens. + +00:05:42.394 --> 00:05:43.879 +Why is that? Well, it's because + +00:05:43.880 --> 00:05:44.984 +(you probably guessed it) + +00:05:44.985 --> 00:05:47.755 +we haven't written or tied any table formulas. + +00:05:47.756 --> 00:05:49.563 +So we're saying, alright, enough talk. + +00:05:49.564 --> 00:05:50.440 +How do we do that? + +00:05:50.540 --> 00:05:52.093 +Well, the answer is very simple. + +00:05:52.094 --> 00:05:54.983 +We do a pound sign (#), if I can find it. + +00:05:54.984 --> 00:05:58.712 +#+ and then we do TBL for table + +00:05:58.713 --> 00:06:01.119 +and then FM for formula. + +00:06:01.120 --> 00:06:03.428 +So, table formula, and the column. + +00:06:03.429 --> 00:06:04.934 +So this, you're already halfway + +00:06:04.935 --> 00:06:07.063 +to writing your first table formula. + +00:06:07.064 --> 00:06:09.171 +So let's say we want to automatically, + +00:06:09.172 --> 00:06:10.978 +Let's just, for exercise, + +00:06:10.979 --> 00:06:13.189 +we want to put the down payment, + +00:06:13.190 --> 00:06:14.615 +just put some type of value in there, + +00:06:14.616 --> 00:06:16.382 +just to make sure that it's working. + +00:06:16.383 --> 00:06:20.992 +So the way Org Mode refers to columns is, + +00:06:20.993 --> 00:06:24.140 +we start with the dollar sign ($) and then + +00:06:24.141 --> 00:06:26.868 +we put the number that the column is. + +00:06:26.869 --> 00:06:29.113 +Indexes start with one, not a zero. + +00:06:29.114 --> 00:06:31.623 +As most of us watching are programmers, + +00:06:31.624 --> 00:06:33.792 +we're probably used to starting with zero, + +00:06:33.793 --> 00:06:34.959 +but it starts with one. + +00:06:34.960 --> 00:06:38.330 +So one, two, three, four, five. + +00:06:38.331 --> 00:06:39.654 +So down payment is the fifth column, + +00:06:39.655 --> 00:06:42.303 +we say five, and then we say equal to, + +00:06:42.304 --> 00:06:44.288 +let's say Gopar. + +00:06:44.289 --> 00:06:47.937 +Then we do C-c C-c to evaluate it, + +00:06:47.938 --> 00:06:50.545 +and the table is automatically updated. + +00:06:50.546 --> 00:06:50.857 +Look at that. + +00:06:50.957 --> 00:06:55.862 +So when you do just this, dollar sign ($) 5, + +00:06:55.863 --> 00:06:57.706 +it updates every single column. + +00:06:57.806 --> 00:07:00.679 +There is a way to specify that this cell only and + +00:07:00.680 --> 00:07:03.224 +this cell only but this is out of scope and it's + +00:07:03.324 --> 00:07:05.639 +not that hard it's just not in this video. + +00:07:05.640 --> 00:07:08.774 +I would recommend, I commend you, or, actually + +00:07:08.874 --> 00:07:12.999 +I recommend that you go check out the manual for that. + +00:07:13.000 --> 00:07:17.624 +All right so, let's say we want to do some basic + +00:07:17.724 --> 00:07:19.224 +arithmetic we want to do some list values + +00:07:19.324 --> 00:07:20.390 +instead of just putting in text. + +00:07:20.490 --> 00:07:21.440 +So how do we do that? + +00:07:21.540 --> 00:07:24.457 +Well, we have to pull the expression that we want + +00:07:24.557 --> 00:07:25.007 +to put in. + +00:07:25.107 --> 00:07:27.859 +So, for example, if we want to add we'll do 20 plus + +00:07:27.959 --> 00:07:31.357 +20 and if we do C-c C-C to evaluate it, it should + +00:07:31.457 --> 00:07:34.224 +update every single column, the entire column, + +00:07:34.324 --> 00:07:38.540 +the fifth column I mean and, tada, it does. + +00:07:38.640 --> 00:07:41.799 +Cool! So now let's say we want to do a little bit + +00:07:41.899 --> 00:07:42.556 +more advanced. + +00:07:42.656 --> 00:07:44.907 +Let's say we want to add the previous column to + +00:07:45.007 --> 00:07:47.007 +this column, so how do we refer to this one? + +00:07:47.107 --> 00:07:50.890 +Well, 1-2-3-4 is the fourth column, so we would + +00:07:50.990 --> 00:07:55.831 +just simply do $4 and this should automatically + +00:07:55.931 --> 00:07:58.057 +be referring to this column (% DP). + +00:07:58.157 --> 00:08:02.190 +So we'll do 10 + 20, it's going to be 30 over here, + +00:08:02.490 --> 00:08:04.174 +and let's do C-C C-c. + +00:08:04.274 --> 00:08:07.024 +Ooh, error, what happened? + +00:08:07.124 --> 00:08:08.874 +Oh my god, oh my god. + +00:08:08.974 --> 00:08:11.719 +Well, this seems scary but no worries. + +00:08:11.720 --> 00:08:14.077 +This is where debugging comes in pretty handy, + +00:08:14.078 --> 00:08:16.740 +which is actually our next section as you can see. + +00:08:16.940 --> 00:08:19.324 +So, what happens if we do, if we go into the + +00:08:19.424 --> 00:08:21.340 +debugging section, what is the first step? + +00:08:21.440 --> 00:08:24.790 +Well, the first step is to try out, is to enable + +00:08:24.890 --> 00:08:26.416 +formula debugger. + +00:08:26.516 --> 00:08:31.294 +So, if you do C-c {, it will turn on a minor mode + +00:08:31.394 --> 00:08:35.509 +that whenever you evaluate a table formula, + +00:08:35.510 --> 00:08:38.290 +the debugger will be enabled, + +00:08:38.291 --> 00:08:39.357 +will automatically kick in. + +00:08:39.457 --> 00:08:41.073 +And if you want to disable the debugger, + +00:08:41.074 --> 00:08:43.774 +you just run the command again, and it will turn off. + +00:08:43.874 --> 00:08:46.607 +So, let's go ahead and run it. C-c {. + +00:08:46.608 --> 00:08:48.790 +As you can see in the mini buffer, it says, + +00:08:48.791 --> 00:08:51.441 +"formula debugging has been turned on". Awesome! + +00:08:51.541 --> 00:08:53.157 +So if we go back to our table + +00:08:53.158 --> 00:08:58.400 +and we try to run this, and see what's going on, we see... + +00:08:58.500 --> 00:09:00.440 +Oh, first off, before we look + +00:09:00.441 --> 00:09:01.390 +at the buffer that just opened, + +00:09:01.391 --> 00:09:02.490 +look at the mini buffer, + +00:09:02.491 --> 00:09:04.974 +it says "Debugging Formula. Continue to next?" + +00:09:05.074 --> 00:09:07.874 +So if you have multiple or a series of formulas, + +00:09:07.974 --> 00:09:09.690 +it will say, "hey, do you want to debug this one + +00:09:09.691 --> 00:09:10.374 +or the next one?" + +00:09:10.474 --> 00:09:11.958 +So this is just saying, "hey, do you want to go + +00:09:12.058 --> 00:09:13.090 +into the next formula?" + +00:09:13.190 --> 00:09:14.990 +And since there's no next formula, + +00:09:14.991 --> 00:09:16.057 +debugger will just exit out + +00:09:16.058 --> 00:09:18.199 +and leave you with the other buffer to see. + +00:09:18.299 --> 00:09:19.949 +For now, we'll just click no. + +00:09:20.049 --> 00:09:22.590 +Right now, it doesn't matter if you click yes or no + +00:09:22.591 --> 00:09:23.540 +because there's only one formula, + +00:09:23.640 --> 00:09:26.072 +but we'll just click no, and let's go ahead and + +00:09:26.172 --> 00:09:27.657 +pay attention to the new buffer. + +00:09:27.757 --> 00:09:29.807 +Well, over here it might seem a little confusing, + +00:09:29.808 --> 00:09:32.390 +but don't worry, we're just going to ignore most of this. + +00:09:32.490 --> 00:09:33.890 +The first thing that we're going to pay + +00:09:33.990 --> 00:09:35.457 +attention is to the original. + +00:09:35.557 --> 00:09:38.067 +So it says, okay, this is the original, so we have + +00:09:38.167 --> 00:09:41.124 +a quote expression, which is just trying to add the + +00:09:41.324 --> 00:09:41.740 +fourth column. + +00:09:41.840 --> 00:09:42.840 +And if we go over here + +00:09:42.841 --> 00:09:44.207 +once everything is finalized, + +00:09:44.208 --> 00:09:47.107 +it says "hey, we're trying to add this 10, + +00:09:47.207 --> 00:09:50.240 +but it's actually a string 10, and added to 20. + +00:09:50.340 --> 00:09:52.325 +So of course it's going to be an error, so now we + +00:09:52.425 --> 00:09:53.999 +know what the error is. + +00:09:54.099 --> 00:09:56.090 +So you're saying all right cool, awesome, now how + +00:09:56.190 --> 00:09:58.840 +do we transform that string into a number? + +00:09:58.940 --> 00:10:02.607 +Well, Org Mode formulas have these flags + +00:10:02.608 --> 00:10:05.674 +that you can use, and essentially a flag looks like this. + +00:10:05.774 --> 00:10:10.257 +It's a semicolon (;) followed by some letter + +00:10:10.258 --> 00:10:13.270 +or some identifier + +00:10:13.370 --> 00:10:16.490 +that will let Org mode know that hey, + +00:10:16.590 --> 00:10:18.290 +this should be turned into a number + +00:10:18.291 --> 00:10:20.207 +or this should be turned into whatever. + +00:10:20.307 --> 00:10:22.724 +There's different ones for alpha literal + +00:10:22.725 --> 00:10:23.863 +and for a bunch of... + +00:10:23.963 --> 00:10:25.274 +I think there's even "i" for "integer", + +00:10:25.474 --> 00:10:26.819 +so it depends what you want. + +00:10:26.919 --> 00:10:28.202 +So for now we're just going to put "number" + +00:10:28.203 --> 00:10:29.490 +because it's a real number. + +00:10:29.590 --> 00:10:33.699 +If we do this and the debugger is still on, + +00:10:33.707 --> 00:10:35.274 +(remember because it automatically + +00:10:35.374 --> 00:10:36.374 +stays on until we turn it off), + +00:10:36.474 --> 00:10:41.540 +if we reevaluate the the formula, + +00:10:41.640 --> 00:10:43.624 +we should be able to see it. + +00:10:43.724 --> 00:10:47.379 +But first, before I do that, let's check step two. + +00:10:47.479 --> 00:10:52.240 +I'll now rerun formulas with C-c * and table, + +00:10:52.340 --> 00:10:54.639 +which calls org-table-recalculate. + +00:10:54.640 --> 00:10:58.507 +To do this, you actually have to be inside the table. + +00:10:58.607 --> 00:11:02.354 +Otherwise, Org mode will try to do some other stuff + +00:11:02.454 --> 00:11:04.325 +because it is context-aware, so depending on + +00:11:04.425 --> 00:11:06.324 +the context it might do something else. + +00:11:06.424 --> 00:11:09.124 +So if we do C-c *... + +00:11:09.224 --> 00:11:12.724 +As you can see the debugger has kicked in, + +00:11:12.824 --> 00:11:14.102 +says, "Do you want to continue to next?" + +00:11:14.202 --> 00:11:17.580 +Let's press yes (y), and it has been applied. + +00:11:17.680 --> 00:11:20.971 +So as you can see, it only updated one column-- + +00:11:21.071 --> 00:11:22.977 +I'm sorry, one row--and the thing is, + +00:11:23.077 --> 00:11:28.007 +when you run this, the recalculate, it will only + +00:11:28.107 --> 00:11:30.361 +run for the current row that you're in. + +00:11:30.461 --> 00:11:32.785 +If you want to run for the entire table, + +00:11:32.885 --> 00:11:36.240 +you're going to do C-u C-c *. + +00:11:36.340 --> 00:11:38.407 +Before I do that, let me turn off the debugger + +00:11:38.507 --> 00:11:40.807 +since we no longer are in need of it. + +00:11:40.907 --> 00:11:44.977 +So C-c {, and debugging has been turned off. + +00:11:45.077 --> 00:11:50.807 +Now let me do C-u C-c * and as you can see + +00:11:50.808 --> 00:11:54.320 +the other rows also calculated, updated as well. + +00:11:54.420 --> 00:11:54.924 +Beautiful! + +00:11:55.024 --> 00:11:58.507 +So as I mentioned, feel free to look / browse the + +00:11:58.607 --> 00:12:00.107 +documentation for more flags + +00:12:00.108 --> 00:12:02.640 +because each flag has its own special meaning + +00:12:02.641 --> 00:12:07.139 +and will do different things, which is pretty cool. + +00:12:07.140 --> 00:12:08.124 +All right, cool. + +00:12:08.224 --> 00:12:10.007 +We're done with debugging and we fixed it. + +00:12:10.107 --> 00:12:12.075 +So there, now we know how to create formulas + +00:12:12.076 --> 00:12:14.207 +and how to debug them whenever they break, + +00:12:14.307 --> 00:12:15.040 +which is awesome. + +00:12:15.140 --> 00:12:18.324 +All right, but remember how I said that you can + +00:12:18.424 --> 00:12:23.659 +only debug... Whenever you run recalculate, + +00:12:23.660 --> 00:12:25.340 +It will only run the first formula? + +00:12:25.440 --> 00:12:28.439 +Well, let's say you want to have multiple formulas? + +00:12:28.539 --> 00:12:30.807 +This is completely valid, except the bad thing is + +00:12:30.907 --> 00:12:34.090 +that you have to do C-c C-c C-c on each each one, + +00:12:34.190 --> 00:12:39.457 +because C-u C-c * won't recalculate everything. + +00:12:39.557 --> 00:12:40.350 +It won't. + +00:12:40.450 --> 00:12:41.557 +Sadly, it doesn't do it. + +00:12:41.657 --> 00:12:44.189 +There is a way that you can do it, + +00:12:44.289 --> 00:12:46.459 +which is hacking together some elisp. + +00:12:46.460 --> 00:12:47.474 +You can probably find it + +00:12:47.475 --> 00:12:48.707 +or you can probably make it yourself + +00:12:48.807 --> 00:12:51.107 +if you look around, but that's out of scope for this. + +00:12:51.207 --> 00:12:57.099 +So now, how do we... We can write all the formulas + +00:12:57.100 --> 00:12:59.007 +we want in one single line. + +00:12:59.107 --> 00:13:01.740 +There's a way to to distinguish + +00:13:01.741 --> 00:13:03.340 +when one ends and one begins + +00:13:03.341 --> 00:13:04.707 +and that is the double colon (::). + +00:13:04.807 --> 00:13:07.607 +So right there, and a new formula will begin. + +00:13:07.707 --> 00:13:08.374 +So for example, + +00:13:08.474 --> 00:13:12.224 +let's say for the seventh column we say "gopar". + +00:13:12.324 --> 00:13:17.407 +If I do C-c C-c, it'll run every single thing + +00:13:17.507 --> 00:13:19.226 +so that... "gopar". Tada! + +00:13:19.326 --> 00:13:20.624 +There, awesome. + +00:13:20.724 --> 00:13:22.440 +But this is going to get very annoying if you're + +00:13:22.540 --> 00:13:25.007 +simply trying to edit formulas like this, right? + +00:13:25.107 --> 00:13:26.933 +So that's where the nicer debugging, + +00:13:27.033 --> 00:13:28.790 +nicer editing section comes in. + +00:13:28.890 --> 00:13:32.299 +So, yes, just like as mentioned, table calls + +00:13:32.300 --> 00:13:33.507 +only the first formula. + +00:13:33.607 --> 00:13:36.349 +So what's the step onto this nicer editing section? + +00:13:36.449 --> 00:13:40.424 +Try out "C-c ," or `org-edit-special'. + +00:13:40.524 --> 00:13:44.557 +So let's go back to the table formula and call it... + +00:13:44.657 --> 00:13:47.590 +oh my god, look at that, + +00:13:47.690 --> 00:13:49.890 +a new buffer just for editing, + +00:13:49.990 --> 00:13:52.599 +and each formula is in its own line to make + +00:13:52.699 --> 00:13:54.624 +it easier, which is beautiful! + +00:13:54.724 --> 00:13:58.715 +So, let's just say I want to do another calculation. + +00:13:58.815 --> 00:14:02.607 +Let's do eight times eight, which should be 64, + +00:14:02.707 --> 00:14:04.740 +and we have no need of putting this flag + +00:14:04.741 --> 00:14:07.440 +because the flag only affects it on the input coming in. + +00:14:07.540 --> 00:14:09.074 +I should have mentioned that earlier. + +00:14:09.174 --> 00:14:10.774 +Only input coming in. + +00:14:10.874 --> 00:14:13.174 +There is ways to affect the output, + +00:14:13.274 --> 00:14:16.474 +which we'll also cover in this topic later on, + +00:14:16.574 --> 00:14:19.131 +but for now, you can either leave the end flag + +00:14:19.231 --> 00:14:21.990 +or leave it out. It will still work fine. + +00:14:21.991 --> 00:14:23.507 +Let's just leave it out for now. + +00:14:23.508 --> 00:14:26.624 +Let's just do C-c C-c to make sure + +00:14:26.625 --> 00:14:28.774 +that everything is working. + +00:14:28.874 --> 00:14:30.690 +64. Beautiful. + +00:14:30.790 --> 00:14:33.066 +So there you have it. You can have multiple formulas + +00:14:33.166 --> 00:14:34.778 +just stacked up into one line, + +00:14:34.878 --> 00:14:36.390 +and whenever you need to edit it, + +00:14:36.391 --> 00:14:38.257 +just go into that into that line + +00:14:38.357 --> 00:14:41.024 +and "C-c ,", and tada! + +00:14:41.124 --> 00:14:44.350 +You have this ready, good to go, and for editing. + +00:14:44.450 --> 00:14:45.824 +Oh and if you want to exit out, + +00:14:45.825 --> 00:14:48.940 +also just do "C-c ," again and you're back. + +00:14:49.040 --> 00:14:51.890 +I did not mention that. Sweet! + +00:14:51.990 --> 00:14:54.774 +So now we know how to have + +00:14:54.775 --> 00:14:57.006 +a better editing experience. Sweet! + +00:14:57.106 --> 00:15:00.240 +So now comes the formatting section which I talked about. + +00:15:00.340 --> 00:15:01.874 +So what's the first step? + +00:15:01.974 --> 00:15:05.507 +Well for formatting, Org mode uses + +00:15:05.508 --> 00:15:08.574 +the printf function from C. + +00:15:08.674 --> 00:15:10.374 +So those who are familiar with C, + +00:15:10.375 --> 00:15:12.823 +you'll feel right at home because the way you format it + +00:15:12.923 --> 00:15:13.940 +is exactly the same way. + +00:15:14.040 --> 00:15:16.557 +So for example, this will print off + +00:15:16.558 --> 00:15:18.873 +a floating number with two decimal points. + +00:15:18.973 --> 00:15:21.540 +As you can see here, this is how you will use it. + +00:15:21.640 --> 00:15:26.324 +It will be after the semicolon and it will be "%.2f". + +00:15:26.424 --> 00:15:28.157 +So let's go ahead and test that out. + +00:15:28.158 --> 00:15:30.590 +Actually, let's go ahead to our latest function-- + +00:15:30.690 --> 00:15:32.340 +I mean, to our latest formula. + +00:15:32.440 --> 00:15:33.840 +Let's go ahead to the nicer buffer + +00:15:33.841 --> 00:15:39.207 +and let's do, Ctrl... Let's enter the semicolon, + +00:15:39.208 --> 00:15:45.324 +and then let's put the percent sign, we do 2f. + +00:15:45.424 --> 00:15:49.174 +Actually, let's make it five + +00:15:49.175 --> 00:15:52.590 +just to differentiate from the formula, and let's see. + +00:15:52.690 --> 00:15:57.174 +Let's run it, and tada! + +00:15:57.274 --> 00:16:00.179 +So yeah, as you can see, five decimal points. + +00:16:00.180 --> 00:16:01.857 +and if we want zero decimal points, we can also + +00:16:01.957 --> 00:16:04.957 +just move point zero, and tada! + +00:16:05.057 --> 00:16:06.124 +Just like that. + +00:16:06.224 --> 00:16:08.774 +We can also just leave it as is how it was before, + +00:16:08.874 --> 00:16:10.874 +because before, we didn't even actually need it, + +00:16:10.875 --> 00:16:13.014 +but yeah, just an example. + +00:16:13.114 --> 00:16:15.090 +And just a reminder, there are + +00:16:15.091 --> 00:16:17.357 +plenty more ways of formatting, + +00:16:17.358 --> 00:16:19.640 +just look at the documentation. + +00:16:19.740 --> 00:16:21.724 +There will be more. Basically every single thing + +00:16:21.725 --> 00:16:25.574 +that you need, just use the documentation as reference. + +00:16:25.674 --> 00:16:28.340 +Cool! So now we know how to debug, + +00:16:28.341 --> 00:16:29.774 +how to write formulas + +00:16:29.775 --> 00:16:32.824 +and how to get a better, nicer editing buffer + +00:16:32.825 --> 00:16:35.124 +for the formula so we don't have to do it all + +00:16:35.125 --> 00:16:36.240 +in a single line. + +00:16:36.340 --> 00:16:38.657 +So, what about conditional prompts, like I was + +00:16:38.757 --> 00:16:43.390 +showing in the first table in the end goal? + +00:16:43.490 --> 00:16:47.299 +Well that's actually pretty simple because we already + +00:16:47.300 --> 00:16:48.324 +know how to do this. + +00:16:48.424 --> 00:16:51.133 +Yes, if you think about it for a second, if we are + +00:16:51.233 --> 00:16:54.221 +able to pull lisp s-expressions, then we are able to + +00:16:54.321 --> 00:16:56.290 +basically do it already. Here's an example. + +00:16:56.390 --> 00:17:01.807 +We're saying if the second column is empty, is zero-- + +00:17:01.907 --> 00:17:04.619 +so actually, this should be with the N flag + +00:17:04.620 --> 00:17:06.940 +because we will transform empty values as zero, + +00:17:07.040 --> 00:17:08.819 +and that's how Org mode will read those. + +00:17:08.820 --> 00:17:12.424 +It's saying if the second flag is zero, + +00:17:12.425 --> 00:17:16.952 +then I want you to put "Enter the values." + +00:17:17.052 --> 00:17:20.440 +And if it's not empty, we're going to put + +00:17:20.540 --> 00:17:22.190 +"Values entered." We're going to recognize. + +00:17:22.290 --> 00:17:24.240 +So let's go ahead and actually do this. + +00:17:24.540 --> 00:17:28.990 +So let's grab this, and let's type it in. + +00:17:29.090 --> 00:17:36.457 +So let's go ahead. "Enter the values," because it + +00:17:36.557 --> 00:17:37.390 +doesn't have any. + +00:17:37.490 --> 00:17:42.440 +So let's go ahead and say "Hello EmacsConf" + +00:17:42.441 --> 00:17:47.224 +and let's go ahead and run it again. + +00:17:47.324 --> 00:17:48.457 +Since there are values, + +00:17:48.458 --> 00:17:51.574 +it's going to overwrite what's here and put value entered. + +00:17:51.674 --> 00:17:53.398 +So let's go ahead. + +00:17:53.498 --> 00:17:55.690 +Tada, so there you go. + +00:17:55.790 --> 00:18:00.524 +So that is pretty much how you do conditional props, + +00:18:00.624 --> 00:18:01.940 +which is pretty straightforward + +00:18:01.941 --> 00:18:02.724 +once you think about it + +00:18:02.725 --> 00:18:05.440 +because if you are able to insert Lisp expressions, + +00:18:05.441 --> 00:18:08.240 +then you are able to just do that check + +00:18:08.241 --> 00:18:11.074 +and do the conditional check yourself. + +00:18:11.174 --> 00:18:13.540 +So, custom formulas. + +00:18:13.640 --> 00:18:15.324 +Yeah, you'll see what I mean. + +00:18:15.424 --> 00:18:19.924 +We want to be able to put our own custom functions, + +00:18:20.024 --> 00:18:23.890 +and you probably have an idea how to do this already. + +00:18:23.990 --> 00:18:27.059 +Yes, we also know how to do this already. + +00:18:27.060 --> 00:18:30.357 +Before I continue, I'm going to say that I already + +00:18:30.457 --> 00:18:31.940 +have some formulas that I use + +00:18:31.941 --> 00:18:33.374 +which are not part of this talk + +00:18:33.375 --> 00:18:37.390 +because they're just functions that calculate some stuff. + +00:18:37.490 --> 00:18:39.990 +So for example, they calculate the monthly mortgage, + +00:18:40.090 --> 00:18:43.257 +the monthly PMI, property tax, homeowners insurance, + +00:18:43.357 --> 00:18:44.757 +so a bunch of other stuff. + +00:18:44.857 --> 00:18:49.729 +I have these functions already and they are a bit off, + +00:18:49.829 --> 00:18:52.212 +but for this example, they're doing everything. + +00:18:52.312 --> 00:18:54.390 +It's close enough, so don't worry too much. + +00:18:54.490 --> 00:18:56.824 +Just an example, you can have your own function + +00:18:56.924 --> 00:18:59.213 +that does something else like calculate + +00:18:59.313 --> 00:19:01.540 +a REI B rental or something like that. + +00:19:01.640 --> 00:19:03.219 +So you can do whatever you want. + +00:19:03.220 --> 00:19:04.724 +As long as you can call via Lisp, + +00:19:04.824 --> 00:19:07.899 +you can call it in Org mode, in the table formulas. + +00:19:07.900 --> 00:19:11.337 +So let's exit out of there. + +00:19:11.437 --> 00:19:13.807 +Now that we know how to do everything, + +00:19:13.808 --> 00:19:20.924 +let me go back to the original table and go from there. + +00:19:21.024 --> 00:19:26.524 +Let me close all these out actually. + +00:19:26.624 --> 00:19:29.524 +Now let's go back and revisit this table, + +00:19:29.624 --> 00:19:31.619 +since we'll be much, much more familiar + +00:19:31.620 --> 00:19:35.418 +except for one thing, which I will explain. + +00:19:35.518 --> 00:19:38.040 +So we have the constants right there + +00:19:38.041 --> 00:19:39.690 +and we have the house prices + +00:19:39.691 --> 00:19:42.499 +and we have everything just like I mentioned before. + +00:19:42.500 --> 00:19:44.023 +The main part that we want to look at + +00:19:44.123 --> 00:19:45.024 +is the table formula. + +00:19:45.124 --> 00:19:47.474 +So let's open up our special editing buffer, + +00:19:47.574 --> 00:19:49.674 +"C-c ,", + +00:19:49.774 --> 00:19:52.390 +and as you can see, I have some right here. + +00:19:52.490 --> 00:19:53.524 +So, the fifth column I'm saying, + +00:19:53.624 --> 00:19:55.824 +"Hey, we're gonna call this function + +00:19:55.924 --> 00:19:58.557 +rei-calculate-down-payment, and I'm gonna + +00:19:58.657 --> 00:20:00.757 +pass in the third column and fourth column + +00:20:00.758 --> 00:20:02.339 +and I'm going to pass in t." (true) + +00:20:02.340 --> 00:20:05.874 +I believe this is just to normalize, + +00:20:07.174 --> 00:20:12.057 +to convert to the proper decimal place, + +00:20:12.157 --> 00:20:14.079 +so let's not worry too much about that. + +00:20:14.179 --> 00:20:16.690 +Then for the sixth column, we're going to say + +00:20:16.790 --> 00:20:18.045 +"I calculate the monthly mortgage." + +00:20:18.145 --> 00:20:20.124 +We're going to pass in the third column + +00:20:20.224 --> 00:20:21.339 +the INTEREST_RATE, which we have + +00:20:21.439 --> 00:20:22.979 +defined over here in the constants. + +00:20:22.980 --> 00:20:26.274 +The 30, I believe this is for 30 years, + +00:20:26.374 --> 00:20:29.323 +PMI, the PROPERTY_TAX and HOME_INSURANCE, + +00:20:29.423 --> 00:20:30.774 +and then the fourth column. + +00:20:30.874 --> 00:20:33.824 +Then everything is going to be accepted as numbers, + +00:20:33.924 --> 00:20:35.074 +and we're going to have two decimals + +00:20:35.174 --> 00:20:36.174 +at the end of the place. + +00:20:36.274 --> 00:20:37.507 +So, what else? + +00:20:37.607 --> 00:20:40.074 +Over here is where we have our conditionals. + +00:20:40.174 --> 00:20:42.274 +We're saying, "hey, if the seventh column is 0, + +00:20:42.374 --> 00:20:44.302 +press 'Enter Tenant Income'." + +00:20:44.402 --> 00:20:48.407 +Over here as well, if the seventh column is zero, + +00:20:48.507 --> 00:20:51.724 +we're going to press 'Enter Tenant Income' + +00:20:51.824 --> 00:20:53.605 +and for this one we're going to say, + +00:20:53.705 --> 00:20:55.940 +"Hey, we're going to normalize the price." + +00:20:56.040 --> 00:20:59.240 +I believe this is a 1% rule. + +00:20:59.340 --> 00:21:01.390 +This could have been extracted into a function, + +00:21:01.490 --> 00:21:03.939 +but I just did the calculation right here. + +00:21:04.239 --> 00:21:07.890 +This, I believe, is the ROI, 12 months. + +00:21:07.990 --> 00:21:11.007 +This is just calculating the cash flow. + +00:21:11.107 --> 00:21:14.907 +This is a very rudimentary function or formula. + +00:21:15.407 --> 00:21:16.732 +Do not use this because there is way more + +00:21:16.733 --> 00:21:18.840 +to go into calculating the cash flow + +00:21:18.841 --> 00:21:21.499 +and also, it differs from person to person. + +00:21:21.599 --> 00:21:23.774 +Some people are more conservative, + +00:21:23.874 --> 00:21:26.959 +other people are way more liberal, so it just + +00:21:26.960 --> 00:21:28.874 +depends how you want to calculate it. + +00:21:28.974 --> 00:21:34.240 +As you can see, we have the N flag for numeric number + +00:21:34.241 --> 00:21:36.090 +and then we're saying we're formatting + +00:21:36.190 --> 00:21:37.694 +to one decimal place. + +00:21:37.794 --> 00:21:43.207 +The %% sign is just to input a percent sign as itself. + +00:21:43.208 --> 00:21:45.419 +Otherwise, Org mode is going to think + +00:21:45.420 --> 00:21:47.940 +it's some type of a formatter, which it's not. + +00:21:48.040 --> 00:21:49.140 +If you do... As I mentioned, + +00:21:49.240 --> 00:21:51.690 +if you've used the printf function in C or C++, + +00:21:51.790 --> 00:21:55.507 +then you probably know how to use it. + +00:21:55.607 --> 00:22:01.824 +Okay, so this is pretty much everything in a nutshell. + +00:22:01.924 --> 00:22:04.970 +So, one thing that I do want to say + +00:22:05.070 --> 00:22:06.379 +is the last section, + +00:22:06.479 --> 00:22:07.774 +which is automatically updating, + +00:22:07.874 --> 00:22:10.174 +which is the part that blew my mind + +00:22:10.175 --> 00:22:11.457 +when I realized that Org Mode can do this. + +00:22:11.557 --> 00:22:12.477 +So how do we do it? + +00:22:12.577 --> 00:22:14.659 +Well, you probably guessed just from looking at + +00:22:14.660 --> 00:22:18.324 +at the first table that we have right now. + +00:22:18.424 --> 00:22:20.774 +We add a column at the beginning + +00:22:20.874 --> 00:22:22.857 +of the table with a percent (%)-- + +00:22:22.957 --> 00:22:24.857 +I'm sorry, with the pound sign (#) + +00:22:24.957 --> 00:22:28.457 +or hashtag as the younger kids call it. + +00:22:28.557 --> 00:22:31.045 +So this is what we do. + +00:22:31.145 --> 00:22:32.819 +We added a column at the beginning of the + +00:22:32.820 --> 00:22:34.984 +table, we do pound sign (#). + +00:22:35.084 --> 00:22:35.790 +So this is what it's for. + +00:22:35.890 --> 00:22:38.839 +This lets Org mode know that "hey, + +00:22:38.840 --> 00:22:41.140 +I want the values, the table formulas, + +00:22:41.240 --> 00:22:43.957 +to automatically run on each tab change." + +00:22:44.057 --> 00:22:46.240 +Now I believe that you can make it so that + +00:22:46.340 --> 00:22:49.123 +it changes, so that it updates on every keystroke. + +00:22:49.223 --> 00:22:51.024 +I think that's too much. + +00:22:51.124 --> 00:22:53.007 +And then you can also make it so that + +00:22:53.107 --> 00:22:56.019 +only certain rows update or certain columns. + +00:22:56.020 --> 00:22:58.219 +There's a plethora of things that you can do. + +00:22:58.319 --> 00:23:00.924 +You should definitely read up on the documentation, + +00:23:01.024 --> 00:23:03.425 +because you will probably make a way better talk, + +00:23:03.525 --> 00:23:06.974 +a way more advanced talk than I on this one, + +00:23:07.074 --> 00:23:09.574 +so I'm looking forward for that. + +00:23:09.674 --> 00:23:12.459 +But this is essentially how you build + +00:23:12.460 --> 00:23:15.507 +a Org mode table formula that will help you know + +00:23:15.508 --> 00:23:17.125 +if a property is correct. + +00:23:17.225 --> 00:23:22.340 +So, let's go ahead and as a final out to this demo, + +00:23:22.440 --> 00:23:25.419 +let's go ahead and enter a new column. + +00:23:25.420 --> 00:23:30.174 +Org-mode automatically puts the pound sign (#), + +00:23:30.274 --> 00:23:35.440 +which is awesome, and let's just say 'Emacs House', + +00:23:35.540 --> 00:23:39.590 +and let's say it is 100k. + +00:23:39.690 --> 00:23:44.339 +So 100k, and as you can see it's already trying to + +00:23:44.340 --> 00:23:46.040 +calculate the monthly mortgage, + +00:23:46.140 --> 00:23:47.090 +but we'll see about that, + +00:23:47.190 --> 00:23:49.879 +and let's just put 10% down. + +00:23:49.880 --> 00:23:53.057 +So 10% of 100k should be 10,000. + +00:23:53.157 --> 00:23:56.407 +So 10,000, correct, and the monthly mortgage is that + +00:23:56.408 --> 00:24:00.090 +and let's just say the tenant income is, + +00:24:00.190 --> 00:24:01.657 +as you can see right here, + +00:24:01.757 --> 00:24:05.874 +tenant income is, let's say 1500. + +00:24:05.974 --> 00:24:07.274 +Is it passing the 1% rule? + +00:24:07.374 --> 00:24:09.424 +Yep! What's my ROI? + +00:24:09.524 --> 00:24:13.879 +118%, which is kind of cool actually. + +00:24:13.880 --> 00:24:14.707 +That's a nice deal. + +00:24:14.907 --> 00:24:17.657 +So this is a rudimentary way of + +00:24:17.757 --> 00:24:20.319 +calculating deals in Org mode. + +00:24:20.419 --> 00:24:44.380 +I hope you found it interesting, and yeah, that is it. |