|
Post by Youngster Joey on Dec 14, 2020 6:36:18 GMT -5
To save you of your misery, Derman:
format-for-select - For every value in vals (which is a list of maps of lists of maps of varying lengths), replace the key names of "name" with "label", "id" with "value", and "subteams" with "options". This is meant to transform a JSON from the API to the format that React-Select wants for dropdowns. Yes, I could have just designed my API in Python to give me back this format, but I'm a purist that didn't want the backend to know about the frontend.
tree-seq-depth - Takes in aforementioned JSON of list/maps/list/maps. Walk through a node. Add the node to the list of collected nodes, but first remove its children, and add a key/value pair for its depth. If the node has children, then recursively apply this function to all of its children (adding a 1 for depth) and concatenate the result to the existing collection of nodes. Then flatten the list of lists.
There was probably a better way to do this, but I'm bad at functional programming and modified this from code I found elsewhere.
select-team-options Rightmost function takes in a variable number of arguments, then calls the next function with the result, etc. I could have gotten away with (format-for-select (tree-seq-depth :subteams :subteams vals)), but, meh, wanted to try something new.
tree-seq-path This just walks down each node of that JSON, applies a function to the node, adds it to the list, then if the node has any children, recursively calls the function and adds the results to the list.
get-child-teams Performs a depth-first search on the JSON (I'm good with variable naming conventions, clearly--need to clean that up), and returns each node if it's a vector or map. Then for each node, we filter to nodes that are a map AND have a key/value pair matching the parent-id. Then for each matching node, we call that tree-seq-path with a function that extracts the ids.
In the end, it basically just goes through and grabs all of the child nodes of one or more parent ids.
And as I'm looking through this again, I'm realizing I have some bloat and could remove a line or two.
All of this is because I have a ragged hierarchy of department->team->subteam. I want someone to be able to select, say, a department from a dropdown and have it hide all of the child teams below it.
|
|
Derman
Oracle Knight
I still don't have a knife tag on my golden birth knife
Posts: 194
|
Post by Derman on Dec 14, 2020 9:21:42 GMT -5
I initially tried to understand it from what the mobile site showed, which for some reason removes indentation from code blocks...
I think I now understand how Clojure works (seems to be really simple actually), and I was able to get a general idea what individual parts were supposed to do. The nested functions is where my brain stopped working. With your explanation I can get a better idea of what's going on.
|
|
|
Post by Youngster Joey on Dec 14, 2020 11:44:56 GMT -5
Yeah, the trickiest part about Clojure is that you sort of have to read inside-out. I probably write my code in sort of a Pythonic way, because I find working inside-out to be a bit confusing.
It's interesting that's considered "normal" in Lisp, but no one likes reading nested SQL queries, which are basically the same concept in a way...
|
|
|
Post by Youngster Joey on Dec 15, 2020 8:20:29 GMT -5
So far, my two weeks off is going awesome. I feel like the main character from Office Space. Not giving a sh*t is great!
|
|
Derman
Oracle Knight
I still don't have a knife tag on my golden birth knife
Posts: 194
|
Post by Derman on Dec 16, 2020 5:52:51 GMT -5
Nice to hear that you are enjoying it. It took me a while to adjust to not having any responsibilities. I still felt like I should be doing something. But today I had to wake up early to give a presentation on one course project, and it took me a while to remember why I had an alarm at 8am, so I guess I'm finally in the "not giving a sh*t"-mode. Also I went the whole day yesterday thinking it was Monday.
I think now's the right time for the annual mention of how hard it is to come up with good Christmas presents for people. Still haven't figured out what I'm going to give my parents.
|
|
|
Post by Youngster Joey on Dec 16, 2020 22:07:00 GMT -5
Wow, want to do something depressing? Grab random posts you've written on this forum of varying lengths so you have some believable lorem ipsum text for the website you're building.
Then read all of the posts you wrote last year when life was normal.
Feels bad, man.
Still haven't done Christmas shopping. I'm actually looking forward to seeing my family this year? My family isn't close, but interaction with people is a very exciting prospect.
|
|
|
Post by Youngster Joey on Dec 17, 2020 10:58:06 GMT -5
You know, snow is cool and all, but it's less cool when you have a car and no shovel and you gotta scrape off all the snow yourself. Snow's cooler when your parents do the inconvenient stuff.
I finally dug myself out, picked up some coffee at the bagel store, got out of my car, immediately slipped, and RIP coffee and my tailbone. My a** still hurts, but I'm most sad about my coffee. I really wanted that coffee.
|
|
|
Post by Friendly Person :) on Dec 18, 2020 2:23:54 GMT -5
The nice thing about having your own tier list is that you can do completely illogical things. Obsidian Tide absolutely, hands down, belongs in the Trinity. Does that make four things in the Trinity? Yes it does. Am I still going to call it 'The Trinity'? Yes I am. Is it because I can't think of a good name for four objects in a group? Yes it is. Do I care? No I do not.
-edit- After doing some research, it seems that the follow up to "Trinity" is "Quaternity". Now I just want to use that to confuse the f*ck out of people.
|
|
|
Post by Youngster Joey on Dec 18, 2020 8:27:02 GMT -5
Ooh, that's a cool word. I had never really thought about alternatives to trinity.
I got my coffee this morning sans slipping. My tailbone still hurts. Stupid ice.
I remain resolute that not working is awesome. I've been busy all week with my Clojure app. It's nice to know I can still enjoy programming. Apparently I just don't like it when it's my job, kekeke. TBF, I'm learning way more with my app than I am work, which probably factors into a lot of my enjoyment. I really enjoy Clojure. With other programming languages, I can just google "how do I do [Python thing] in [language]" and there's generally a direct corollary, because they're always C-based languages. Kind of like translating Spanish to Italian, not too much different. Clojure is like translating Spanish to Japanese, in that some sh*t just doesn't translate one-to-one. You can still say the same things in the end, but you have to think about a completely different way of expressing the problem. Can't do the word-for-word translation gig.
The downside of learning a language by yourself in a side project is that you have no one to review your code :<
|
|
Derman
Oracle Knight
I still don't have a knife tag on my golden birth knife
Posts: 194
|
Post by Derman on Dec 18, 2020 13:33:29 GMT -5
Some people say "make your hobby your profession and you'll never have to do work in your life" (or something like that, translating is hard). Should be "make your hobby your profession and you'll have to find a new hobby".
I can say that learning is a big factor in how much I enjoy programming. Lua was nice because it forced me to do a lot of things myself because of how simple it is and Rust forces me to think about things differently because of the borrow checker. In both languages you can always look up how to do things, but I always prefer to come up with a solution myself. Clojure could be fun, but the way it works is so different that I find it pretty intimidating. And I can't really think of any projects where I would use it.
|
|
|
Post by Youngster Joey on Dec 19, 2020 13:58:29 GMT -5
It's really not so intimidating once you start! If you want to wade into frontend development, it's a good place to use it, in lieu of nasty Javascript.
One day I want to get back to learning Go.
Cue my usual grousing about Christmas gift purchases. I don't think I dislike the practice of giving people gifts if I know them well, I think, because then I'm happy if I came up with something thoughtful for them. I enjoy doing that. But my family's style of giving gifts is everyone submits a list of items they want, and you just pick an item off the list to give them. My parents are wealthy, and therefore Christmas is kind of a "what stuff do you need, we'll buy it all for you" holiday. For my siblings and I giving gifts to one another, it's pretty silly. Basically all you are doing is swapping money on things everyone would have bought for themselves anyway. I mean, if Christmas didn't exist, I would have bought snowshoes anyway. (Actually, I would have purchased them earlier in the season, even.)
I would say, let's buck the trend and buy my siblings stuff they didn't ask for, but, embarrassingly, I don't know my siblings well enough to do that...
I guess that's why I don't like Christmas very much. It's not that I'm ungrateful, but I really dislike how hollow and mechanical it feels, and it kind of drives home how not close my family is. I don't know how to change it, either.
I will say I'm at least somewhat excited for Christmas this year? Normally everyone comes on the last possible day (23rd/24th) and leaves immediately (26th), because, again, we're not close and no one actually wants to spend time together. My brother always immediately leaves to go spend a week with his friends instead. This year, no one can see anyone or do anything, so (hopefully) spending time together feels a little more appealing? I mean, I'm looking forward to it, because it beats me being in an apartment all alone like I have been for months.
With that said, my sister (who gives not one f*ck about COVID, so that's definitely not the reason) still hasn't confirmed whether she is coming, so maybe I'm wrong.
/endrant
|
|
|
Post by Friendly Person :) on Dec 19, 2020 14:48:59 GMT -5
My dad's family's Christmas get-together was cancelled, although I wouldn't go anyway. Popping positive for a COVID test wouldn't just delay my departure until I get better: it would delay it for weeks-months. Meanwhile my mom's get-together is truncated to only one other person anyway, so no problems there.
Most of my gifts have been in the form of necessities for Japan, so I'm not complaining. Thus, Derman definitely wins the "most fun" Christmas gift of the year.
|
|
|
Post by Youngster Joey on Dec 19, 2020 15:21:19 GMT -5
Yikes, yeah, that would be rough if you tested positive just before going. I'm guessing you must be practically barricaded in the house to avoid it. I can't imagine how much that would suck if it got delayed...
|
|
|
Post by Friendly Person :) on Dec 19, 2020 21:52:53 GMT -5
Pretty much. Just telling people "nope" left and right. "Want to hang out while I'm in the state?" "Nope!". "Want to come to my wedding reception?" "Nope!".
Also someone egged my car today, but they did such a bad job I'm not even angry, just confused. Like, you chucked two tiny ass eggs at it. BFD?
|
|
|
Post by Youngster Joey on Dec 20, 2020 3:00:04 GMT -5
Whew, finally finished making some serious updates to my Clojure app. Took me all week. It's no longer stateless! Among other things, I added a database, built out an API, fixed bugs, restructured the repo, created a view of messages with pagination, and embedded SMS functionality.
And it's almost 3 AM and I'm not 20 anymore. Tomorrow's gonna suuuuuuuuck.
|
|