<![CDATA[Dylan's Dev Blog]]>https://blog.dylanlu.com/https://blog.dylanlu.com/favicon.pngDylan's Dev Bloghttps://blog.dylanlu.com/Ghost 5.85Fri, 01 Nov 2024 17:43:08 GMT60<![CDATA[Detect Ping Pong Ball With Deep Learning]]>https://blog.dylanlu.com/detect-ping-pong-ball-with-deep-learning/67246ddfbd94f9a3688491b5Fri, 01 Nov 2024 06:19:25 GMT

Earlier I mentioned that the new direction of my project was to create a 3D reconstruction of a ping pong game using pose detection and ball tracking. My first step was to track the ball movement, and it looks like I did it (with decent accuracy)!

YOLO

You Only Look Once (YOLO) is a deep-learning architecture for object detection and tracking. The benefit of using this model over something like Fast R-CNN or other models is that it can run inference very fast (as the name implies, it only looks once).

I actually didn't realize that a whole auto referee system for ping pong was already created several years ago, as described in this paper: https://arxiv.org/pdf/2004.09927. Those guys, however, use a two-step system to detect the ball; I want to do it faster so that we can run the app on a smart phone.

YOLO is currently in V11. The python library makes it really easy to use as well, since I only need to specify my dataset directory and it will take care of the rest.

model = YOLO("yolo11n.pt")
results = model.train(
    data="../dataset/opentt.yaml", 
    project="..", 
    epochs=300, 
    patience=10, 
    batch=-1, 
    imgsz=640
)

The harder part was getting good data, but luckily the authors of the paper I mentioned above made their dataset open source. All I needed was a nice conversation with ChatGPT and we had could pull frames and annotations from the video!

Detect Ping Pong Ball With Deep Learning
There's like 10,000 of these images

You can look at the rest of the code, which I'm pretty proud of. This is actually my first deep learning project where I wrote my own code to train a model (even though I used YOLO).

GitHub - ccs-cs1l-f24/ping-pong-deep-learning
Contribute to ccs-cs1l-f24/ping-pong-deep-learning development by creating an account on GitHub.
Detect Ping Pong Ball With Deep Learning

Results

After 4.5 hours of training on my RTX 3070 Ti, I thought it was all a waste because the loss was really high and it automatically stopped at 46 epochs. Even worse, I tried testing with an image I took a while ago with James and it didn't work! But I figured out it was because the ball in that image was orange when I trained on only white balls.

Detect Ping Pong Ball With Deep Learning
No ball detected 😦

But the confusion matrix seems kind of promising. Looks like it can detect the ball about 80% of the time, which is not bad for my first model.

Detect Ping Pong Ball With Deep Learning
Detect Ping Pong Ball With Deep Learning
Running inference on test image

Conclusion

Yay, I made some good progress. My next step is to input a video and see whether it can consistently track the ball throughout each frame (and how fast). Then, I'll need to track the table and the people. So yeah I'd probably need to retrain my model for another 5 hours with more data 😭

]]>
<![CDATA[Ping Pong iOS App]]>https://blog.dylanlu.com/ping-pong-ios-app/67118912d672646268b957a8Mon, 21 Oct 2024 05:35:15 GMT

For my CCS Computing Lab class, I'm working on an app to automatically track and display ping pong scores on the phone (using computer vision). Right off the bat, however, there are a lot of problems to consider. First off, the ball can be hit at such high speeds that it would be impossible to capture precise movement data at 60fps. Also, you'd have to position the camera to perfectly capture the entire table, which may not necessarily be possible in all scenarios.

My First Prototype

To combat these issues, I decided to track points in a simpler—though less automated—fashion. When a player wins a point, they simply raise their non-dominant hand to indicate that they've won.

Though this approach is much more basic, I think it works better in practice, even if there's a way to track the ball accurately. Considering how many edge cases there are for deciding who wins a rally, it's probably better to let the human decide, rather than hope that the AI will guess correctly; using the hand-raise method ensures that the players always have control over the score, not letting there be any mistakes that they'd have to manually override.

To test my idea, I built a quick prototype using Python and my Macbook webcam. The demo code uses OpenCV and Google's MediaPipe to detect the players and determine whether they've raised their hand or not.

GitHub - ccs-cs1l-f24/ping-pong: Ping pong scoreboard using computer vision
Ping pong scoreboard using computer vision. Contribute to ccs-cs1l-f24/ping-pong development by creating an account on GitHub.
Ping Pong iOS App

After testing it at the downstairs ping pong table, it seems to work pretty well! Now time to build it for iOS.

Ping Pong iOS App
Raising my left hand to indicate I've won

Moving it to iOS

This step was a little harder since I have much less experience with Xcode and Swift, but I actually ended up learning a lot by forcing myself to build it here. When building previous Xcode projects, I had no idea what the MVVM (Model-View-ViewModel) or MVC (Model-ViewController) architectures were, so I got confused when I'd see so many different project formats. This time, however, I decided to learn one and stick with it. SwiftUI is a new framework that Apple recommends and uses the MVVM architecture, so I decided to go with that. It's actually pretty similar to React, where Views are like "dumb" components that render the props they're given, and ViewModels handle the backend logic. For MVC, ViewControllers are supposed to handle the logic and rendering at the same time, which can get messy.

Since SwiftUI is relatively newer and offers less control than UIKit (the previous framework), I spent most of my initial time trying to port Google's example iOS code for MediaPipe to work under SwiftUI. Luckily, the process wasn't that hard, as SwiftUI gives us a UIViewRepresentable class that allows you to run UIKit code in a SwiftUI app.

Once MediaPipe was set up, all I needed to do was write a callback function that processes the pose information, as seen below.

extension ScoreDetectionService: PoseLandmarkerServiceLiveStreamDelegate {
    func poseLandmarkerService(_ poseLandmarkerService: PoseLandmarkerService, didFinishDetection result: ResultBundle?, error: Error?) {
        // This delegate is called by the PoseLandmarkerService delegate, which processes data then gives it to us
        guard let poseLandmarkerResult = result?.poseLandmarkerResults.first as? PoseLandmarkerResult else { return }
        
        for playerLandmarks in poseLandmarkerResult.landmarks {
            // Extract useful pose landmarks
            let noseLandmark = playerLandmarks[0]
            let leftWristLandmark = playerLandmarks[15]
            let leftShoulderLandmark = playerLandmarks[11]
            
            // Check which side of screen
            let isLeftSide = noseLandmark.x < 0.5
            
            // Check if raising hand
            let isRaisingHand = leftWristLandmark.y >= leftShoulderLandmark.y
            
            // Pass it to the corresponding player side hand detection service
            if isLeftSide {
                self.leftSidePlayer.update(isRaisingHand: isRaisingHand)
            }
            else {
                self.rightSidePlayer.update(isRaisingHand: isRaisingHand)
            }
        }
    }
}

This function will detect which side the player is on and whether or not they are raising their hand. We then update the player state to see if they've raised their hand long enough.

class PlayerHandDetectionService {
    var handRaised: Bool = false
    var handRaiseStartTime: Date = Date.distantFuture
    var handRaiseCounted = false
    
    var onPlayerWinsPoint: () -> Void
    
    init(onPlayerWinsPoint: @escaping () -> Void) {
        self.onPlayerWinsPoint = onPlayerWinsPoint
    }
    
    func update(isRaisingHand: Bool) {
        // TODO: If we've been raising our hand long enough, give a point
        
        // Get current time
        let currentTime = Date()
        
        // If raising hand, check if we passed the threshold
        if isRaisingHand {
            // Just started raising our hand
            if !self.handRaised {
                self.handRaised = true
                self.handRaiseStartTime = currentTime
                self.handRaiseCounted = false
            }
            // We've raised our hand long enough, give a point
            else if !self.handRaiseCounted && currentTime.timeIntervalSince(self.handRaiseStartTime) >= DefaultConstants.handRaiseDurationThreshold {
                self.onPlayerWinsPoint()
                self.handRaiseCounted = true
            }
        }
        // Else, reset hand check state
        else {
            self.handRaiseStartTime = Date.distantFuture
            self.handRaised = false
            self.handRaiseCounted = false
        }
    }
}

And the result works pretty well!

Ping Pong iOS App
To lazy to go downstairs but it works!

Next Steps

I actually ended up testing the app and it seems to work fine. The only problem is that no one wants to raise their hand, either because it's awkward or just annoying.

For my next steps, I have two ideas:

  1. The logical next step is to make the app automatically detect the points (despite the challenges I described earlier). Someone on YouTube kind of got this working, so it's definitely possible.
  2. Perhaps more interesting, I want to build an app that will "transcribe" the game into a full 3D reconstructed live scene, where the player can go back and analyze their form and see where they can improve. I'll do this by detecting where in space each item is at every frame, then rendering that into a 3D scene with something like Three.js or Unity. I was thinking of using low poly models to make everything look more cohesive.

For my second idea, I also want to try implementing a deep learning model that will test your form against professional players' forms that hit the ball in a similar situation; thus you can see how to improve. To go even further, an LLM could teach you specific steps/advice to achieve better form.

Overall, I think my next steps will be way harder and more ambitious, but hey, that sounds more fun anyway.

Ping Pong iOS App
Inspiration - https://www.youtube.com/watch?v=WS9ST9A6XEM

]]>
<![CDATA[The Paradox of Choice]]>More choice is paradoxically worse for us, mostly because we will hesitate and feel less satisfied with the end result. Moreover, you're less likely to even make a choice when you have too many options.

Key Ideas

  • Maximizers vs Satisfiers: satisfying does not mean having low standards; it&
]]>
https://blog.dylanlu.com/the-paradox-of-choice/66e783870faaf456ecc528dfTue, 08 Oct 2024 21:24:55 GMT

More choice is paradoxically worse for us, mostly because we will hesitate and feel less satisfied with the end result. Moreover, you're less likely to even make a choice when you have too many options.

Key Ideas

  • Maximizers vs Satisfiers: satisfying does not mean having low standards; it's like a DFS algorithm that stops once it finds something that matches its criteria
The alternative to maximizing is to be a satisficer. To satisfice is to settle for something that is good enough and not worry about the possibility that there might be something better.
  • With more options, you're more likely to regret not picking the other choice
  • Second-guessing choices undermine the value of what you picked
  • Constant decision-making drains mental energy; reducing choices helps conserve willpower.

Applications

  • Set up ground rules so that later decisions will be a no-brainer. For example, you can decide never to do more than 5 shots of alcohol 😭
  • Limit your choices to prevent decision paralysis
  • Automate decisions. For example, schedule out your meals for the week
  • Make final purchases (that satisfy your requirements). Don't try looking for things you can return

Quotes

Learning to choose is hard. Learning to choose well is harder. And learning to choose well in a world of unlimited possibilities is harder still, perhaps too hard.

Conclusion

This book shifts your perspective on decision-making, which you'll do a lot every day. I probably subconsciously use these lessons a lot, so I highly recommend it. My friend Mason also recommended the book How to Not Die Alone, which feels like a wrapper for this book but in the context of dating (not entirely sure though, since I'm only on the first chapter).

]]>
<![CDATA[Made to Stick]]>https://blog.dylanlu.com/made-to-stick/6542f13995dd5467248acc0eTue, 08 Oct 2024 21:04:41 GMT

We often hear boring stories, and then forget about them. This book is about how to make them stick, just like proverbs and urban legends.

Side Note: I read this book about 10 months ago, and I've been backlogged on my book summaries. I'm just going to share this draft that I wrote back then.

The Curse of Knowledge

We are cursed with knowledge, and therefore cannot remember what it is like to not know something. This makes it particularly difficult for experts to share with non-experts. Imagine I'm tapping a song on the table, do you think you'd know what it is? To me, the song is obvious, but that's only because I can hear it in my head.

SUCCESs Framework

Simple

  • Simple does not mean dumbed down: it's the Commander's Intent, the one most important thing. You can't have 5 most important things. Pick the "core" and go with it
  • "Don't bury the lead". Start with your most important thing first, then pyramid down

Unexpected

  • Gets their attention
  • Create gaps to keep interest in the plot
  • Fill gaps at the end for satisfaction

Concrete

  • Easier for non-experts to understand, since we are using tangible examples rather than abstract ideas
  • More memorable and it's easy to do

Credible

  • Anti-authorities, like a smoker, can send a powerful message to make you want to avoid something
  • Adding lots of provable details leads to internal credibility; they can just "try it for themselves"
  • Humanized stats are not plain numbers. Imagine a pebble is a nuke that can destroy a city, and I throw it in a metal tin. BOOM! Now I pour a bucket full of pebbles into the can, that's why we need to focus on nuclear safety.

Emotional

  • People are greedy. Tell them what's in it for them, not how impressively engineered your product is
  • One person > many. Sponsoring a single kid in Africa who loves playing soccer and likes piano is easier than donating to "kids in Africa"
  • Appeal to their identity, or their ideal identity. A Texan might throw trash on the floor, but when you associate that with the slogan "don't mess with Texas," they might change their mind.

Story

  • They inspire people to take action
  • They are often concrete, unexpected, and emotional

Other Advice

  • Look for sticky ideas, you don't need to be the one to create them (just like the fat subway guy story)
  • Anyone can come up with brilliant ideas, not just people like JFK. The examples in the book were predominantly normal people

Conclusion (10/8/24)

I actually tried applying some of these lessons to my college application, perhaps a little too forcefully. My Common App, for example, started out with me rapping at a hackathon—something that is generally unexpected. Maybe my applications were cooked from the start; cs and ce are both highly competitive fields, and I wasn't on par with applicants who won national competitions. Doesn't matter now; I'm enjoying UCSB so far.

]]>
<![CDATA[Starting College]]>https://blog.dylanlu.com/starting-college/66f8483bb6201e5a30fea19cMon, 07 Oct 2024 04:19:51 GMT

I've just finished my first two weeks of college, and I'm really enjoying it here. The transition was really easy since I did a 6-week summer program beforehand, so I already had friends coming into school. So far, classes are super chill and I've been attending as many club meetings as possible. I've also done many things that I never would have expected before (more on this later).

Anyway, let's start at the beginning.

Freshman Summer Start Program

Since this would be my first college experience, I was pretty nervous: there were so many new faces and I didn't have anyone I knew to hang out with. To make things worse, the building was really old (musty bathrooms, etc), so I had a bad feeling about how everything would turn out. I missed having my own private room and clean bathroom.

I really did not know what to do on that first night there, and I was kinda too scared to go out and say hi to people. So instead, I just played Sekiro on my M1 Macbook Pro. Probably not the best first impression when my roommate walked in for the first time. And not to glaze or anything, but he was a pretty intimidating guy: 6'2, built, and with a really deep voice (emphasis on the deep voice, I mean like holy shit, I was trying to match my voice so I didn't sound like a little kid). Of course in hindsight, he's a cool dude, and it's kinda funny how scared I was in that moment when I first met him. Overall, my roommate was considerate of my space and was very clean; we got along well I think.

Starting College
Very small room

New Friends, Classes, and Fun Activities

The first few days were just for socializing and meeting new people. I think I made most of my friends by randomly sitting with them in the dining hall, or just complaining about the showers while passing by in the bathroom. To this day, I still hang out with those same people I met.

Starting College
The FSSP squad

By the time classes started, I had a system for brushing my teeth and showering (which seems simple enough until you realize that the showers had no benches to put your stuff on). I ended up adopting the "towel strat," where you would walk to the showers with only a towel on. It was awkward at first, but then again, what have I been training in the gym my whole life for!

The classes were pretty easy—Writing 2 was self-graded and my Greek Myth TA gave everyone A's on their paper—but I still spent a lot of time in the library. There's something kind of satisfying just grinding out homework while overlooking the ocean. I was studious for the first week or so, but then I started getting into Game of Thrones, and that took up most of my time instead.

Apart from class and the library, I'd usually spend my time playing ping pong in the lounge (I was known as the best player in the building) or going to the gym. I actually got noticeably stronger in recent months, and I've gotten some compliments about that from my friends.

Also, of course, I started surfing! My friend who was originally from Santa Cruz took us all out and taught us how to surf. I didn't stand that day, but I guess it led the path to many other fun surfing days. We went probably every week, especially since the beach was a 5-minute walk from our dorm and because we had unlimited access to boards and wetsuits.

Starting College
First surf at Campus Point Beach

Party School?

Once I found my place with my group of friends, we started going out every so often (they went out way more than me; I was trying to be a little more locked in). In Isla Vista, there are parties literally every day of the week. I remember going to one random frat house on a Thursday night (and keep in mind, this is the summer school) yet it was still packed with people.

Anyway, like I said in the introduction, I did something that I never thought I'd do (perhaps regrettably). Actually, I think it was a bad idea. 5 shots was a little too many. I'm not going to say it here but you (AKA future me) definitely know. Fuey and James were surprised as well.

Starting College
Red eyes is my roommate, and uh...
Starting College
5 shots and Louis' tank top!

Beach

We hit the beach a lot. Here are some cool photos.

One Week Back Home

Despite all the fun I had at FSSP, I actually looked forward to going back home. I missed my family and my friends, and I missed having good food. The first meal I ate when I got back was O2 Valley: BBQ pork over rice, popcorn chicken, and boba. The classic combo!

I spent as much time as I could with my parents, but they also had to go to work. My day-to-day life was basically the same as before FSSP.

Berkeley

I also had the chance to visit James and Cheney at Berkeley. Hayden and I took an Uber there (the train didn't work) and I slept over for two nights. We had a lot of fun trying new food, exploring the campus, and best of all, playing 7 hours of poker. I lost money, but oh well.

Starting College

Shopping

When I got back on Monday, I met up with Josh, Max, and Mihlaan and went to Valley Fair mall. I bought a really nice black hoodie (which is my favorite one now), a pair of loose jeans, and some Uniqlo oversized shirts. My friends say that baggy is the way to go; my parents don't like it, I'm not sure what I think. We also got miso soup to end the trip. The next day, they all left for college.

Starting College

UCSB - For real this time

Wow, I actually can't believe that I've started college. I've been thinking about it for almost all my life. It's totally different than what I'd imagined (and perhaps, where I'd imagined), but I'm actually really happy with my stage in life right now.

First, let me show you my room.

I lowkey might be taking up most of the room, but my roommates are super chill (thank god). I've spent a few hours gaming in the first week, but I've stopped for the most part.

Last Good Meal With Parents

The night they dropped me off, my parents treated me to a nice meal. I got lobster and clam chowder. We also took a walk by the pier at night and stumbled upon the place where I had ice cream for the first time ever. Perhaps it was meant to be.

Zero Week and Clubs

I met a lot of new people during zero week, and there were plenty of engineering events that I attended. Overall, this week was purely for making new friends and exploring what the university has to offer (a once-in-a-lifetime moment, just as Mr. Hahn predicted!). I should've talked to more girls, but whatever; maybe after I get a perm and complete my ABB transformation I'll do that.

There were plenty of clubs that I was interested in: ACM, IEEE, Gaucho Racing, Game Dev Club, and UCSB Rocket Club. I only ended up joining ACM and IEEE though, since time is rough. I also checked out other events like the boba social from the Asian Engineering Club.

Church is Really Good?

Church has surprisingly been the highlight of many of my days. I first got started at A2F during the summer and met some of the mentors there—all of them are amazing and really cool people. In particular, Joseph is a CS major from UCSB working remotely as a software engineer. We play basketball together and more recently, I've been going with Surya to his house for Courses 101: delicious food and exploring hard questions about Christianity. His mom also taught Physics at Gunn; what a small world! There's another mentor named Dylan. He's a CE major who also works in the area, and he's really good at surfing. He brought his boards (he has six) the day after I moved in and took me surfing at Campus Point, which I thought was really nice of him. Derek is a software engineer from Berkeley who is also really cool. Eric is a 4th year CCS Physics major who is good at basketball and is probably going to grad school for CS (he said his research lab is looking for undergrads...). Cyril went to my high school! He did CS and is working in Santa Barbara; he knows Fuey's sister and Ethan Kitch's older brother. And finally, we have the pastor, John. Man, this guy is insane. He graduated EECS from Berkeley and went into software engineering, decided he didn't like it, took the LSAT and scored 99th percentile, decided that wasn't right either, scored 99th percentile on MCAT, then realized his true calling was to be a pastor. Wow. This guy is my inspiration for life.

Funnily enough, church has actually been the best networking "club." But of course, I've gotten much more than that from it. I'm still trying to explore my own faith, and I find myself in the same shoes as many of the mentors who used to be just like me. As the year goes on, I hope to learn more about God and figure out who I'm supposed to be.

Today, Surya (a non-Christian, but has been going for 2 weeks) and I took Mason to church. I was surprised to say that he really enjoyed it and even encouraged Beto to come. He doesn't believe in the God aspect of church, but he really relates to lessons about morality and purpose that we discussed this morning. Actually, off-topic, I think at church I saw Rori, someone from my middle school who I haven't seen in years. I wonder who else from Palo Alto goes here.

A New Major?

Finally, let's talk about about something that is HUGE for my college career. Last week, I got an email saying that I got into the College of Creative Studies! Now, though the name sounds a little lame, this is a really great opportunity. If you didn't read my blog post ("Last Week of School") where I stressed out about applying for it, CCS is basically a "graduate" school for undergraduates. Basically, the idea is to accelerate lower div CS classes to push you straight into upper div as soon as possible. By Spring, I'll be taking upper div CS courses.

Not only is the program accelerated, but there are other perks. Best of all, perhaps, is that being in CCS greatly increases chances of getting research, because the professors know that we're the real deal. The class size is also really small, so you can make a close connection with your peers and with your professors (this year is only 5 people in CCS Computing, though generally there are about 15 per year). Some of my classmates are quite strange, but I think it'll be fine. My friend Ezra from Gunn is also one of the 5 in this program.

My offer into this major is actually contingent on my performance in the first class. Professor Richert Wang told me that if I'm not done with the CS 24 labs by the end of week 5, I could be in some trouble. It's been 4 days since he told me that; I finished all of it. Looking forward to finishing CS 32 this week!

For my CCS Lab, I'm working on an AI ping-pong scoreboard app that can automatically track points. My first approach is to detect when a player raises their hands to indicate that they've won the rally. Soon, I could look into actual automation, but I think the hand-raise approach works better in practice.

Starting College

I've also started applying to research and internships, now that I have the CCS badge under my name. Wish me luck!

Future

Idk man. I've been writing this post for over an hour now. I hope there are good things to come. I want to make new friends, eventually talk to girls, and continue to grow as the best version of myself.

]]>
<![CDATA[The Summer Before College]]>I had some stuff about my Portugal trip written a few weeks ago that I never got around to finishing. So I guess I'll try summarizing my entire summer in this one blog post.

Senior Grad Trip - Portugal

My friends and I just got back from our

]]>
https://blog.dylanlu.com/portugal-and-summer-plans/667493e055d34f46005d4731Wed, 17 Jul 2024 22:52:10 GMT

I had some stuff about my Portugal trip written a few weeks ago that I never got around to finishing. So I guess I'll try summarizing my entire summer in this one blog post.

Senior Grad Trip - Portugal

My friends and I just got back from our senior trip in Portugal a few weeks ago. I loved it. The food was really good, the mountains and beaches were really pretty, and people were very friendly. The only downside is that the last two Airbnb's smelled really bad (especially in the bathroom), and there were lots of drug dealers out on the streets at night time (although it was interesting to see people try selling cocaine to us).

Lisbon

We spent the first five days in Lisbon, where we explored the city, tried all sorts of new food, and looked at some castles. The Airbnb was really nice, though it was located more on the outside of the city, where all the business buildings were. We were really tired the first night, so we just walked to the nearest restaurant, which served burgers that looked and tasted like cat food. Not fun.

We spent our first real day trying out different foods in the city. The bifanas and the pastel de natas were really good, so we made sure to get more when we visited other places. We also tried margaritas for the first time!

We'd usually get back around 10-11 pm, just in time for some late-night poker. In the first few games, I profited about $110, though that number slowly dwindled down to somewhere around $60 by the end of the trip. I don't think the alcohol helped...

The Summer Before College
I made $100 that day...

Oh and we also saw a soccer game, although it was just a friendly match and Ronaldo didn't play (he played literally two days after, what the heck man!). That was pretty fun, but everyone around us was smoking so I guess not that fun.

On the last night before we left Lisbon, we also hit the casino. We came in with about $25 each and lost it all in a matter of 20 seconds—three hands of blackjack. It took us longer to walk from the entrance to the table than to actually play the game. I guess that's why no one looked happy there (although we saw one woman cash out $10,000).

Sintra

This was probably the most beautiful place I've ever seen. We started by seeing the castle and a famous well. It was cool, but it wasn't anything spectacular in my opinion. What really stood out was the hike we did right after. Since it was starting to rain a little, all the other tourists left, meaning the mountain was all to ourselves. And on top of that, there was mist everywhere around us (it looked so cool).

I also bought a souvenir shirt here. Turns out, when I went to buy my parents a gift on the last night of the trip, I accidentally bought the exact same shirt without realizing. I don't know how that happened.

Lagos/Luz

Even though Lisbon and Sintra were really pretty, I think the highlight of the trip was Lagos. It's a small beach town with lots of really good food. My personal favorite was the restaurant where I got sushi as an appetizer and steak for my main course. The entire atmosphere of the place was kinda cool too, with menu items like "Vegan bitch" and other interesting names.

But the food wasn't the best part, it was the beach! We did a boat tour, went on Kayaks, and chilled by the ocean, sipping our Piña Coladas. We even started a Jetski rental an hour before our bus back to Lisbon.

Overall Thoughts

Even though I really wanted to go to Japan, I think this trip exceeded my expectations. We made some really awesome memories here and I think everyone would want to come back if we had the chance.

The Rest of My Summer

After getting home and settling in, I spent some time preparing for college. I met with Al a few times at the Mitchell Park Library to talk about UCSB and photonics stuff. The first meeting was mostly about his "Start UC" program that he wants to start with me, but I told him that I wanted to wait until I settled into college before taking on this big project. In our second meeting, he was super eager to teach me about photonics, a topic which I told him I was interested in (because of its applications in Artificial Intelligence). I learned about phonons, photons, conduction bands, indirect/direct gaps, P-N junction, and so much more in that one hour. To be honest, I don't understand everything, but it still is super interesting.

Elden Ring DLC: Shadow of the Erdtree

I've been waiting for months and I finally got the chance to play. I had so much fun, but I might've spent a little too much time stuck in my room. I beat the DLC in about 40 hours, which was over the course of 12-ish days. There's so much lore to uncover it's actually unbelievable. And the final boss was incredibly satisfying to beat.

The Summer Before College
It's beautiful

Getting a "Job"

My mom wanted me to get a job this summer so that I could "learn the value of money" and all that fun stuff. So I signed up to be a DoorDasher, got in my car, and waited... and waited... and kept waiting for two hours and still got no orders. What a total waste of time! I tried three more days before giving up on it completely.

Instead, my parents were willing to hire me instead. I did some basic housework like gardening, installing a new sprinkler control panel, and other cleaning tasks. I made $15 an hour, so not the best, but also not horrible either.

My mom started talking to church friends about my search for work, and that led to more side job opportunities. I started by cleaning Mrs. Angela's shed and made $60 for 2.5 hours. I think it looks really clean!

The Summer Before College
It used to be completely filled with spiderwebs

Then, I started a little basketball clinic for June and Johann's kids. I think they really enjoyed it. We did basic dribbling drills, shooting, and some fun games like dribble knockout. Kevin and Evelyn joined for a few sessions two and had fun.

I made about $90 for 5 hours, but it was also nice talking to June and Johann about college/career/life stuff afterward. They recommended I take some stats classes and learn the technologies that engineers actually use in industry, rather than just the theory. I think I'm going to take that into account when I pick courses in two days. On the final day, the kids and the parents wrote me thank you notes, with June and Johann strongly suggesting that I join a Christian group in college.

Kevin and Evelyn

My little cousins are back! It was super fun hanging out with them this past week and a half. Kevin is getting alarmingly tall (99.7th percentile), but I still have some time before he surpasses me. The week went by really quickly, but we spent time playing late-night board games, Smash Bros, JCC basketball, and watching Brooklyn 99. We also went to the Hillsdale Mall to shop (Kevin bought a Harry Potter game), and we went again later that week to do an escape room. I think everyone had a really great time.

But today will be the last time we'll see them for a few months. They're moving out to Singapore for a year, but they should move back to Palo Alto after that. Evelyn will be going to Gunn! That's crazy!

Looking Forward

My UCSB orientation is tomorrow so I'll be exploring what they have to offer and picking my dorms and courses. I really hope I get good roommates since it'll be random. Hopefully a double as well.

I still don't really know what electives to take since all the interesting courses aren't offered every quarter and they have so many prerequisites.

Anyway, I guess this is my last real day of summer. By the time we get back home, I'm going straight to UCSB for summer school.

]]>
<![CDATA[Last Week of School]]>https://blog.dylanlu.com/last-week-of-school/6647027977651a456c881c4cTue, 28 May 2024 07:11:52 GMT

So I thought I'd give a quick update on things since I haven't posted in like a month.

I've been really enjoying the last few weeks of school. There's basically no work to do and my grades are locked in already, so there's really nothing that's hard. I finally stopped making that stupid sandwhich that I always each for lunch (everyday Sophomore year) and now I go out to each during 2nd period photo or skipping a few classes.

In terms of coding projects, there's not much activity there to be honest. I'm still learning more about AI, and it'll be a while before I can make some real projects (I'd rather make something technically complex than another boring app). For my Calc final, I made a script to record chords and decompose it into the individual notes using Fourrier Transform. This concept is pretty cool and has a lot of applications; I saw it at Atmosic but I was never really sure what it did (or what frequency domain meant). My CS Capstone final is likely a quick script to turn a song into an image, and have a script to play a song from an image.

College Stuff

I finally had all my recommendation letters and videos sent to UCSB CCS Computing, which is the "graduate" CS school for undergrads. It gives you a much more personalized experience and focuses on performing research alongside regular coursework. It's pretty competitive; people have given up Stanford and Berkeley to get into this, even though I never heard of this before.

Fuey recenlty got off the waitlist for UCSB and I've been trying my best to convince him to come. I don't understand the thought-process of going with UIUC—to me, it just seems like a worse school at a worse location, but I guess it has the specific major that he wants to do.

Last Week of School
It's like a beach resort...

Prom and Ditch Day

Prom was pretty fun. I went with my usual group of friends and we took some pictures at Bol Park. After-party was fun too.

Ditch day was awesome. We went to Poplar Beach and walked like 15 minutes down the coast into an isolated part of the beach (where no one else would find us). There were probably a little under a hundred seniors there sleeping over in tents. Some people started a bonfire and there were games like volleyball and spikeball.

I think everyone was probably drunk or high, but that made it really easy to socialize and just talk to people I don't normally talk to. Hayden threw up in the tent, which made me really paranoid the whole night. Luckily, the tent didn't smell and nothing else happened.

I think in the middle of the night, some Paly kids were on top of the cliff throwing eggs at all of us. A few hit the tent and a few got on my jacket, but I don't think anyone was in the right headspace to care at all.

Some of us were in the "bijillionth dimension," while others were only in the 5th dimension lol. It was pretty funny listening to people talk.

A few days later, a news article appears online: "Gunn High School trashes Poplar Beach". Uh oh.

Basically, it was resolved with a really nice "sorry" letter and some volunteer effort by our Seniors to clean up all the trash and more.

Senior Assassin

I can't believe I was betrayed. For the last 10 or so people in Senior Assassin, we used Life360 to track each other's locations. I saw that Fuey was right outside of Ella's house (to get Mihlaan, who was there too), and so I asked if I could wait with him. We waited and did some driving, and he tells me that there's a faster way: Shree can get us into the house since he's good friends with them. Turns out, Fuey knew that Shree had me, but still it was the only way he could get in. So I guessed he sacrificed me so that he could get his target. Wow.

A week or so later, we're hanging out at the Y, and we decide to go for his other target, Julia. We wait outside her house for a while, but then we see her parked outside of Safeway. Easy kill, we think. When we got there, the windows were open, and Julia looks at us as if she was waiting for us to come. Then, out of nowhere, McKayla pops out of the back seat and shoots Fuey as he approaches. We totally got outplayed there. I guess we were too obviously waiting outside her house, so she decided to lure us out and kill Fuey.

Anyways, Fuey complained that McKayla didn't have her location on, so the kill got reversed. He survived this round, and eventually, ended up winning the entire thing. He made $400.

Upcoming Stuff

Wow, my last day of school was last week. I literally can't believe it; I really enjoyed PAUSD. The graduation ceremony is in a few days, and after that, my friends and I are headed straight to Portugal. No plans for the trip yet, but we have all of our housing and transportation booked. Other than that, I signed up to be a DoorDash driver (my parents wanted me to get a job and this seems the easiest), but I also just sent an application to In-N-Out since they pay way more.

I'm really excited for college. Hopefully I get a double with a great roommate and I can bring my gaming PC. I also want to do some morning runs by the beach, as well as lots of gym days. I think it'll be really fun.

Also, I'm looking forward to all the grad parties. At the one with our close family friends, I got a few really good books. I've already read "Atomic Habits" and "How To Win Friends and Influence People," but I'm looking forward to reading "I Will Teach You To Be Rich" over the summer. Stay posted for some book summaries!

]]>
<![CDATA[The Hard Thing About Hard Things]]>https://blog.dylanlu.com/the-hard-thing-about-hard-things/6542dd3495dd5467248acbe4Tue, 30 Apr 2024 03:57:18 GMT

This is one of my favorite and most relatable books. Not only does he have similar feelings about his high school and company (as a football player and being stressed out all the time), but he also begins each chapter with a rap! This guy is so cool. I wrote about him and his book in my Stanford essays.

To be honest, I read this book 6 months ago and have book slacking off on my book summaries. Also, during my Stanford interview, Yinan asked me specific questions about the book (cuz I told him it inspired me), but I couldn't answer them lol.

Anyway, based on my notes and what I remember, this is what's important.

  • Firing is hard emotionally, but if someone doesn't fit your culture or is not doing what is required/expected, fire them immediately
  • Firing should not be a surprise, but you should take care of them. Leave a good impression for future employees and create good working conditions
  • In layoffs, the CEO should clearly state that it's the company's fault.
  • CEO is a lonely job: no one else has all the information; you can't share the burden by taking the "accepted" answer from other employees because the company will die; no one is born a CEO and must experience failure to succeed later on
  • Take care of your people first, then your shareholders
  • When deciding equity, everyone should be just a little unsatisfied; that's how you know you've done it right
  • Be honest. People see through fake positivity, and it actually makes you look stupid. If you're in trouble, say so
  • Bad news spreads automatically, so there's no point in trying to cover it up. Surprises destroy employee's trust in leadership and hurts morale
  • Take care of HR, because taking care of employees is the only way to create a great company; more important than the product or profit themselves
  • Spend time investing in employee training. It may take a while at first, but in the long run, it's worth it (saving a little time multiplied by 365 days a year)
  • One-on-one meetings are very important, and they should not be forced. Managers should do 85% listening and less talking. If there's a problem, employees need a way to communicate that privately and safely
  • Nobody cares. It doesn't matter if you fail with a great reason; spend all your energy finding the one impossible solution (also in sports psychology speech by Mr. Creighton)
]]>
<![CDATA[Fall In Love With the Problem, Not the Solution]]>https://blog.dylanlu.com/fall-in-love-with-the-problem-not-the-solution/64cb29716272e0524c0f4c1eTue, 30 Apr 2024 03:57:00 GMT

I've given up on writing full-blown summaries. I read this book like a year ago and these notes have just been sitting here.

  • If you're not willing to give up a sport or a hobby, you're not dedicated enough to run a startup. Your investors will not be dedicated enough either
  • Starting with the problem will give you a clear message to tell people and they'll understand it better, rather than "our system does..."
  • If the problem is something daily, you're onto something (we like the "toothbrush model" – twice a day
  • Fail fast. If you aren't willing to fail, you already did
  • The main thing is the main thing; focus all of your energy on your current phase (fundraising, R&D, etc)
  • Find investors that will stick with you through tough times and will support you. Prepare to dance the "hundred noes"
  • Fire fast. "Knowing what you know today, would you hire this person? If not, fire them the next day"
  • Elite teammates will know when someone is out of place. They will leave if you don't fire the bad ones
  • It is okay to fire a cofounder, and sometimes necessary. Don't expect to still be friends though
  • Users don't like change. The early majority need to be convinced to join, and will churn unless they get immediate value
  • You are a one-man sample; don't expect your assumptions to hold true with everyone
  • People who find value will share it with others. Don't expect a user to read anything you provide them
  • If you cannot figure out PMF, you will die
  • Figure out your business model: B2C (prefer don't make them pay upfront, either sell advertising data or go with subscription), B2B, or B2B SaaS (the best, which allows you to get steady annual income)
  • Set the price on the value you create, not on what it costs you to make. If that isn't profitable, change your business model
  • Word of mouth works best for high-frequency apps because people have more opportunities to tell someone else
]]>
<![CDATA[College Decisions]]>https://blog.dylanlu.com/college-decisions/66176ef6d65e55689084b7beThu, 11 Apr 2024 05:47:30 GMT

I'm gonna be completely honest, I'm pretty sad. I see my friends and classmates get into their dream schools like Stanford, Berkeley, MIT, and all that, while I'm here scrolling through Reddit for comments like "it's okay, college rank doesn't actually matter."

I can't say that my results were the worst-case scenario—unlike my friend who got rejected from all 25 CS schools he applied to (except ASU), I have a few solid choices to choose from. But still, it just feels unsatisfying. I've always dreamt of getting into Stanford, opening the decision letter with my parents, and then running across my street screaming "Oh my God!!!"

I guess that'll never happen.

What's Next?

Right now, I think my top two options are UT Austin and UCSB. My dilemma is this: UT's engineering program looks really fun, the buildings are super cool looking, and it has a decent reputation. But at the same time, it's Texas... 90% Texans to be exact. I have no clue whether I'd fit in, and the area just seems to foreign to what I'm used to.

UCSB, on the other hand, seems like a dream school, but it doesn't really have the reputation to make me go "Wow I'm so excited." I know that rankings aren't everything, but it does hurt a little bit thinking about how just 4 months ago, my family totally dismissed that as an option because it's a "party school."

I'm visiting this Saturday and I've emailed an old classmate who does engineering there, so I have some things to look forward to at UCSB, but this decision is just killing me!

Put simply, if I want a more comfortable experience at a smaller engineering program, go to UCSB. If I care about prestige and don't mind being across the country at a big school, go to UT Austin.

Some side things to consider are also that UCSB will let me switch to CS if I want, and I have the option of doing a 5-year master's degree. UT Austin locks me into Cockrell, so no CS classes (other than those provided in the certificate program). Also, no football at UCSB, and the startup scene is probably less vibrant.

In the meantime

But in the meantime, there are still 6 weeks of senior year to enjoy. I definitely did not start a business like planned, but that's lowkey still on the table if I get an idea and put in the effort.

My last adult league basketball game is tomorrow as well, but it was really fun while it lasted. I've made great memories at our post-game dinners and poker sleepovers.

I'm also really interested in AI all of a sudden. I started reading a few books and watching some Stanford AI courses; I'm thinking of starting a small project pretty soon as well. If things go well with my dad's networking, an OpenAI internship would actually be so fire.

Conclusion

I'm gonna be completely honest, I'm really jealous of a lot of people at my school, especially the people who can just apply to Stanford for the hell of it and get in (of course, they've already committed to MIT). I've always thought I was like that, but I guess this is a good shift in perspective. I'll need to work my ass off if I want to get my dream job or pursue grad school; no more letting my pride be an excuse for laziness.

]]>
<![CDATA[Gunn Elimination Recap]]>https://blog.dylanlu.com/gunn-elimination-blog-3/65b89028d0e6474374318b26Thu, 29 Feb 2024 07:09:24 GMT

I've totally been slacking off on my blogging, but let's try to do this before I forget everything.

Elimination ended eight days ago, but it feels much longer than that. I think it's because the kills really started to die down at the end since it's really hard to kill a tryhard. This is the final standings, with Liam Wong winning the game.

Gunn Elimination Recap
Final Standings

Managing the Game

There were a few road bumps here and there, but the game went pretty smoothy overall. Someone even said, and I quote, that it was an "honor to meet the CEO of Elimination." That felt really good.

Forgetting to click save

Somehow, I forgot to click save when I disabled Supabase signups, so over 50 new users signed up on the first day. That was problematic because I was getting reports of people not having targets, and it checked out on the database. This had me panicking, and so I manually set their targets (this is while simultaneously handing out plushies at lunch, and holding my own plushie to be safe).

Luckily, a friend texted about wanting to sign up but not be in the game. That's when I was really surprised because she shouldn't have been able to sign up in the first place, and I realized that it was because I didn't click save (but because of this, I was able to smuggle James into the game without anyone noticing).

Lots of freaking emails

Let's say 2% of the population are little bitches and complain about getting killed without reading the rules (and these Gunn people really love to write elaborate, long essays to defend their stupidity). For the first few days, that's like 14 emails a day, which is totally unmanageable. I sent a message on the first day saying that I would no longer be "reviving" players and that they should read all rules before giving their codes. It got a lot better.

Still, I was getting like 5 emails a day, which is fine but just annoying when I have to make a judgment on each edge case while trying my best to make sure they aren't lying. I gave up on responding to emails about a week.

I hate freshman

Not only did these freshmen have the nerve to find Matchomatics data on my GitHub and call it "hacking," but they also decided to brute-force elimination codes. I really did not think this would be an issue, and I really did not want to implement rate-limiting or some penalty (I'm a very trusting and lazy person I guess). But I guess that kinda backfired.

The freshman who did it actually succeeded after about 6 hours, which not only led to a bunch of frantic emails but also totally increased my server costs. Look at the number of API requests below.

Gunn Elimination Recap
I'm famous guys!

I thought I was running some million-dollar corporation for a second.

I ended up being nice about it, since he emailed me an apology letter explaining how he did it and why. I told him that he could implement rate-limiting for next year's Elimination.

The interviews

Apparently, I'm not a great interviewer. I had very little to say, and when Oracle released their news article I was very scarcely quoted (and I was saying some stupid stuff too). I guess I'll work on that for the future.

Some kid even interviewed me for her English project, but that's like totally a waste of my time bro.

Some Final Elimination Stories

Last year, I'd say my craziest story is when a very dedicated Senior tried to eliminate me. He followed me outside of CS Capstone and tagged me right when I left the N-building stairs; but when I looked up, I still had the roof over me. I then sprinted across to the little theater, weaved through the overhangs to try making it to basketball practice, and asked Sangeet to get my stuff from my car. Luckily, the roof connected all the way to Titan Gym, so I was good for now.

When practice ended, my car was the only one in the parking lot, except for the a suspiciously parked truck next to me. Some guy came out and was like, "yo can you jump my car, I think it died," and I was a little suspicious (but more trusting because my car also died last week too). Suddenly, the guy popped out, I dropped all my stuff, and I bolted back to Bow Gym where there was an overhang. I guess we were in a little stalemate, with him trying to follow me every step I took, and his friends lurking around my car. But somehow, I outmaneuvered him at the last second and sprinted to the car, he might've tagged me in the car, but it didn't matter since the car has a roof too.

He was persistent though, and he got his friends to stand in front and behind my car, preventing me from driving off. We were there for almost 30 minutes, and he was like "yeah I have nothing better to do so we can do this all day." Some of his friends drove over too.

Eventually, I just got tired, and I told him I was letting go of my brakes. And I did. And he moved, but shocked at the idea that I would run him over to escape. When I cleared them, he tried sprinting along side my car, but I accelerated and I was gone.

Someone's little brother

Bro, I'm not gonna write much since I'm getting tired, but if you know I have my plushie in my hand, and you try looking at my from an angle where you can't see it, of course that doesn't count. That's what Nathan's little brother tried doing and it pissed me off. The worse part is that he's a freshman and he felt so entitled, saying shit like "oh you had your fun coding the site, so the other players should be able to have their fun and you're preventing that by not following the rules." Like bro I wrote the rules, and you're literally stupid.

Anyway, later that night I stayed to shoot an hour after practice. When I went out, he popped out behind my car and tagged me, but I was prepared and was holding my plushie. Yay.

A betrayal of sorts

I reshuffled targets at Cheney's house, after our big Paly game win, and my new target was Ethan Zhou. I feel kinda bad, cuz he was trying to help me with the site (even though it was too late), and spent all night making this.

Gunn Elimination Recap
Ethan Zhou's homepage

It looks pretty cool, but it would be too hard to integrate that style for the entire site, and make it work for mobile.

But anyways, I was stupid enough to tell Steve and Chloe that I had him, so they instantly warned him. Steve was too scared to lead me to Ethan during lunch, so we wandered campus for the entire lunch. I didn't find him, until after math, I saw him at the little theater. The theater is it's own island, so there's no wall connecting to the N-building (which is where he had English). Surely, this meant victory.

But he was persistent and just waited there, thinking that he could outlast me.

Gunn Elimination Recap
Waiting patiently to get my kill

After 15 minutes, and after his friend brought out the assignment for him, he dropped his plushie to grab a pencil. I immediately capitalized on the opportunity and got the kill.

A trip to GRT

I definitely shouldn't have made eye contact with Vivian, and definitely should not have been so obvious when trying to tag her. She immediately sat down, so she was safe, and I had to come back later that night to get her during GRT.

After practice, James and I got some Zareens, then went back to Gunn. It's like 9:30 PM at this point, so GRT should be getting out. But someone saw me and snitched, so now the entire GRT is teaming up to try to get Vivian to safety while I'm just waiting for the opportunity to tag her.

I sit while they take their meeting, and it's been like 30 minutes. Some dude spills lychee jelly on my head, then offers me $60 to leave. Of course, I said no because first of all, he's definitely not giving me $60, and secondly, I don't want his money.

Gunn Elimination Recap
GRT Meeting

When it's over, she slides all they way to the back parking lot into her mom's car, and at the last moment when she needs to stand up, five GRT kids shove me. I'm a little embarrassed that these scrawny kids could do that, but I guess I'm as tough as I think I am.

She escaped... or did she? I ran into James' car and we pursued her in a 5-minute car chase, at which point James said that this was going too far and we went home.

I have some funny videos if you (AKA future me) want to look at your camera roll for Feb 9, 2024.

JORTs?

Thanks Fuey.

Gunn Elimination Recap
JORTS

My death

After all the craziness in the last few weeks, the way I died was incredibly anti-climactic. I was talking with some friends outside the brunch line, and... someone tagged me from behind. That's it. That's how it all ended...

Conclusion

Elimination was very fun, and I learned a lot from building the site. In terms of reach, this is a great step in the right direction; I had more users than ever before, and people actually found my site intuitive.

And maybe, just maybe, there might be another chance to win—in our unofficial, water-gun-using Senior Assassin later this semester.

]]>
<![CDATA[Gunn Elimination Blog #2]]>https://blog.dylanlu.com/gunn-elimination-blog-2/65b201ded0e6474374318a93Sat, 27 Jan 2024 21:16:27 GMT

Gunn Elimination starts in 2 days and we have about 650 signups (250 more than last year)! Lately, I've been doing more logistical stuff, like handing out plushies and organizing the rules, but I've also added some new features.

But let's look at the site first.

Final UI Design

Not too different from what I had previously, but I think it looks a little better. Since the game didn't start, a lot of the fields are left blank, so maybe I'll update it later.

Gunn Elimination Blog #2
/app
Gunn Elimination Blog #2
/app/leaderboard
Gunn Elimination Blog #2
/app/rules
Gunn Elimination Blog #2
/app/profile/95030486

Supabase Pro

I didn't want to take any risks since 650 people is a lot to deal with, so I paid for Supabase Pro, which comes with daily backups. Also, it's lowkey a scam since I had to pay an extra $10 to make it look like this.

Gunn Elimination Blog #2
No more "yihigqyfdifpodmnguxr.supabase.co"

But also like it broke for some other people so I may end up not going with the custom domain (so I basically wasted $35!).

Game Messages

I made a new table to make messages since it's important to keep everyone updated. Pretty simple.

Gunn Elimination Blog #2

Calendar and Kill Cutoff

We mostly used last year's rules, but we made the game longer and added some fun rules, like wearing JORTS.

This year, to avoid random people who don't play the game but just hide all week, we decided to implement a kill cutoff. Basically, if you don't have more than 1 kill by the end of the week, you're automatically eliminated. I might do a last-minute removal of this rule if not enough people will be left, but I think it's a cool rule this year.

Gunn Elimination Blog #2
Elimination Calendar 2024

Kill Cutoff Code

Not gonna lie, the code is terrible because I was lazy and used a little ChatGPT. It basically loads all players into a JS array, then filters out people with enough kills to stay alive. Then, we go one by one and delete the remaining people. It literally takes so long to load (like 20 seconds), so I'm worried that something might crash during the game. But hopefully not!

import { error, json } from '@sveltejs/kit';

export const POST = async ({ url, locals: { supabaseAdmin, getSession, getRole }, request }) => {
	const role = await getRole();
	if (role !== 'Admin') {
		throw error(403, { message: 'Unauthorized' });
	}

	const { kill_requirement } = await request.json();

	if (!kill_requirement) throw error(422, 'Invalid kill_requirement');

	// Fetch all players
	const { data: playersData, error: playersError } = await supabaseAdmin
		.from('players')
		.select('*');

	if (!playersData || playersError) throw error(500, 'Error with players table');

	// Filter players with less than one kill
	const playersToUpdate = playersData.filter((player) => player.kill_arr.length < kill_requirement);

	// Update these players
	for (const player of playersToUpdate) {
		const { error: updateError } = await supabaseAdmin
			.from('players')
			.update({ alive: false })
			.eq('id', player.id); // Assuming each player has a unique 'id' field

		if (updateError) {
			throw updateError;
		}
	}

	return json({ message: 'Successfully cutoff players' });
};

/api/game/admin/playercutoff

And while I was testing it out, I had a mini heart attack. I thought I deleted my entire players table (with 500 people at the time). Turns out, I just had a filter when viewing the table.

Gunn Elimination Blog #2
Mini heart attack

More Code Updates

I have a lot of small improvements that I added as well.

Retain Kill Code If Not Logged In

When scanning a QR code, it will open a browser and attempt the kill. But it won't work if you're not logged in. This was bad because then you'd have to log in and then scan the code again.

Basically, if we're not logged in, then we'll redirect to /login?killcode=[kill_code_here]. On the login page, we'll check if there's a code and save it to localstorage.

onMount(() => {
    if (killcode) {
        localStorage.setItem('loginkillcode', killcode);
    }

    loaded = true;
});

Then when we go to the app homepage, we'll check for a killcode in localStorage and try it.

onMount(async () => {
    const loginkillcode = localStorage.getItem('loginkillcode');
    if (loginkillcode) {
        inputKillCode = loginkillcode;
        localStorage.removeItem('loginkillcode');
        await submitCode();
    }
});

Fixing BIG Security Vulnerability

Try finding the issue with this.

import { json, error } from '@sveltejs/kit';

export const POST = async ({ url, locals: { supabaseAdmin, getSession, getRole }, request }) => {

	const { student_id } = await request.json();

	// killedPlayer = the player we're force killing
	// originalPlayer = the player who had this guy as the target

	const { data: killedPlayer } = await supabaseAdmin
		.from('players')
		.select('id')
		.eq('student_id', student_id)
		.single();

	if (!killedPlayer) throw error(500, 'Error fetching player with that student id');

	// Delete the player's entry in the targets table
	const { data: killedPlayerTarget } = await supabaseAdmin
		.from('targets')
		.select('target')
		.eq('id', killedPlayer.id)
		.single();
	if (!killedPlayerTarget) throw error(500, 'Error deleting target');

	// Delete the player's entry in the targets table
	const { error: deleteError } = await supabaseAdmin
		.from('targets')
		.delete()
		.eq('id', killedPlayer.id);
	if (deleteError) throw error(500, 'Error deleting target');

	// Player's target is not alive anymore
	const { error: updateTargetAliveError } = await supabaseAdmin
		.from('players')
		.update({ alive: false })
		.eq('id', killedPlayer.id);
	if (updateTargetAliveError) throw error(500, 'Error updating target alive status');

	// Get the player who had this player
	const { data: originalPlayerTargetData, error: getPlayerError } = await supabaseAdmin
		.from('targets')
		.select('id')
		.eq('target', killedPlayer.id)
		.single();
	if (!originalPlayerTargetData) throw error(500, 'Error fetching the original player target data');

	const { data: originalPlayer } = await supabaseAdmin
		.from('players')
		.select('*')
		.eq('id', originalPlayerTargetData.id)
		.single();
	if (!originalPlayer) throw error(500, 'Error fetching original player');

	const { error: updateError } = await supabaseAdmin
		.from('players')
		.update({ kill_arr: [...originalPlayer.kill_arr, killedPlayer.id] })
		.eq('id', originalPlayer.id);
	if (updateError) throw error(500, 'Error updating player data');

	// Record kill in kill_feed table
	const { error: killFeedError } = await supabaseAdmin
		.from('kill_feed')
		.insert({ player_id: originalPlayer.id, target_id: killedPlayer.id });
	if (killFeedError) throw error(500, 'Error inserting into kill feed');

	// Update player's target to the target's target
	const { error: setNewTargetError } = await supabaseAdmin
		.from('targets')
		.update({ target: killedPlayerTarget.target })
		.eq('id', originalPlayer.id);
	if (setNewTargetError) throw error(500, 'Error setting new target');

	// Redirect to app or return success
	return json({ mesage: 'Successfully force killed player' });
};

/api/game/admin/forcekillplayer

If you're me, then you probably found it. But if you're not, then you have no idea what I'm talking about lol.

If I didn't include this below, then anyone can force-kill players, so long as they know how to do a POST request.

const role = await getRole();
if (role !== 'Admin') {
    throw error(403, { message: 'Unauthorized' });
}

Checking for permission

Obviously that's really bad, so good thing I found it!

Backup Database as CSV

I wrote this before I decided to pay for Supabase Pro, but I think it was a cool thing to learn regardless.

Basically, I had lot's of help from Google and ChatGPT to figure out how to download my table as a CSV file.

import { error } from '@sveltejs/kit';
import JSZip from 'jszip';
import { format } from 'date-fns'; // TODO: make this work with dayjs cuz I don't need two date packages

export const GET = async ({ locals: { supabaseAdmin, getRole } }) => {
	const role = await getRole();
	if (role !== 'Admin') {
		throw error(403, { message: 'Unauthorized' });
	}

	const tables = ['players', 'kill_feed', 'targets'];
	const zip = new JSZip();
	const folderName = format(new Date(), 'yyyy-MM-dd');
	const folder = zip.folder(folderName);

	if (!folder) throw error(500, 'Error creating folder');

	for (const table of tables) {
		const { data, error: tableError } = await supabaseAdmin.from(table).select('*').csv();
		if (tableError) throw error(500, `Error fetching ${table}`);
		folder.file(`${table}.csv`, data);
	}

	const zipBlob = await zip.generateAsync({ type: 'blob' });

	return new Response(zipBlob, {
		status: 200,
		headers: {
			'Content-Disposition': `attachment; filename="${folderName}.zip"`,
			'Content-Type': 'application/zip'
		}
	});
};

/api/game/admin/backuptable

We can then do a get request and download the blobs, or whatever that means.

const exportTables = async () => {
    // Download zip (based on ChatGPT)
    try {
        const response = await fetch($page.url.origin + '/api/game/admin/backuptable');
        if (!response.ok) {
            throw new Error('Network response was not ok');
        }

        const blob = await response.blob();
        const url = window.URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = 'tables.zip';
        document.body.appendChild(a);
        a.click();
        window.URL.revokeObjectURL(url);
        document.body.removeChild(a);
    } catch (error) {
        console.error('Error:', error);
    }
};

Function to Download Zip Files

Get Today's Challenge

Do display the current challenge, I just hard coded a function to return the right string given the date. I used ChatGPT to turn my table into a switch statement, cuz that's a lot of manual labor.

// Lol thanks ChatGPT
export function getTodaysChallenge() {
	const currentDate = new Date();
	const day = currentDate.getDate();
	let rule = '';

	switch (day) {
		case 28:
			rule = 'Targets Assigned 10 PM (Sign ups close)';
			break;
		case 29:
			rule = 'GAME STARTS. 12 AM: To stay safe, players must hold the animal with their right hand';
			break;
		case 30:
			rule = 'To stay safe, players must be holding the animal with both hands';
			break;
		case 31:
			rule = 'Targets Change at 10 PM: To stay safe, players must be holding animal BELOW waist';
			break;
		case 1:
			rule = 'To stay safe, players must be holding animal ABOVE their shoulder';
			break;
		case 2:
			rule = 'To stay safe, players must be under a roof or overhang';
			break;
		case 3:
			rule =
				'Targets Change at 10 PM: Players with less than one kill are automatically eliminated';
			break;
		case 4:
		case 11:
		case 16:
		case 19:
			rule = 'On weekends, players must abide by all rules and must carry a plushie to be safe';
			break;
		case 5:
			rule = 'To stay safe, players must be touching a wall';
			break;
		case 6:
			rule = 'To stay safe, players must be wearing a HAT.';
			break;
		case 7:
			rule = 'Targets Change at 10 PM: To stay safe, players must be wearing JORTS (jean shorts).';
			break;
		case 8:
			rule = 'To stay safe, players must be wearing a wig';
			break;
		case 9:
			rule = 'To stay safe, players must be SITTING OR LAYING DOWN ON THE GROUND.';
			break;
		case 10:
			rule =
				'Targets Change at 10 PM: Players with less than two kills are automatically eliminated';
			break;
		case 12:
			rule = 'To eliminate others, players must have at least one shoe off.';
			break;
		case 13:
			rule = 'To eliminate others, players must be carrying a football in one hand.';
			break;
		case 14:
			rule =
				'Targets Change at 10 PM:. To eliminate others, players must give their target a flower immediately after eliminating them.';
			break;
		case 15:
			rule = 'To eliminate others, players must be wearing a tie around their neck.';
			break;
		case 20:
			rule = 'NO ONE IS SAFE. (can be tagged anytime even w/animal)';
			break;
		default:
			rule = 'On weekends, players must abide by all rules and must carry a plushie to be safe';
			break;
	}
	return rule;
}

Conclusion

That's it for now. I might do another post if something big happens. My friend asked to help improve the UI like yesterday, but I told him it was too late and I didn't want to give him the secret keys since something could accidentally go wrong. I'm hoping the game goes well, and that I can at least make top 10.

Also, we are considering doing an unofficial senior assassin, with water guns and no safety zones. That will be way more fun and crazy in my opinion.

]]>
<![CDATA[Sprint]]>https://blog.dylanlu.com/sprint/64bd5f0ae0a62c21e4b57611Sat, 20 Jan 2024 08:13:44 GMT

If you ever had a big idea you wanted to test, and needed it done fast, this book shows you how. Sprints are all about working with your team to quickly go from planning to prototyping, to live user interactions, and using them can help speed up hard business decisions. You won't need a polished product, just something convincing enough for your tester (even an interactive Figma could work).

When and Why Sprint?

Use sprints when you need to answer an urgent question about your business, product, or customers. They can help you avoid things like waiting 6 months before realizing Bluetooth doesn't work (hmmm I wonder who did that...). Sprints are used in several companies and have led to incredibly cool products (like AirBnB).

Also, a sprint is requires 5 full days of undivided attention. If you can't form a team that can go through this process, it won't be as effective.

Prerequisites

  • Choose an important and urgent challenge
  • Assemble a diverse team of specialized people. Have 1-2 Deciders (leads)
  • Prepare supplies in advance (lots of Post-Its!)

Monday: Map

The first day will be spent crafting a clear question that you'd like to address by the end of the sprint. But first, you'll need to understand your company's long-term goals. Start with a question like this: "Why are we doing this project? Where do we want to be six months, a year, or even five years from now?"

Uncover Underlying Assumptions (morning)

When creating your goal, you were probably quite optimistic about the future. But there are dangerous assumptions that you took to get there. The next step is to turn each assumption into a question, which you will then be answering by the end of the sprint. Think about the following:

  • What questions do we want to answer in this sprint?
  • To meet our long-term goal, what has to be true?
  • Imagine we travel into the future and our project failed. What might have caused this?

Create a Map

The map will show your customers moving through every step of your service or product and will help you narrow your broad challenge into a specific goal later on. It also lays out how everything fits together, so it will be easier to structure your solutions sketches and prototypes later on.

On a giant white board, create your map:

  1. List the actors (on the left). The "actors" are important characters in your story
  2. Write the ending (on the right). It's easier to figure this out than the middle steps
  3. Words and arrows in between. It's not art, keep it functional
  4. Keep it simple. There should be around 5 to 15 steps. Otherwise, it's too complicated
  5. Ask for help. Keep asking your team if the map makes sense

Ask the Experts (afternoon)

Get your team to individually interview people with specialized knowledge about your solution. Information is asymmetrically distributed across the company, and you'll need people who can pick up on easily missed details.

Here's who to talk to:

Strategy: Talk with the "Decider" about questions like "What will make this project a success", "What's our unique advantage or opportunity", and "What's the biggest risk"

Voice of the Customer: Find the person who knows the customer the best and can explain their perspective

How Things Word: Who best understands the mechanics of your product? How does everything fit together?

Previous Efforts: Sometimes, people already thought about a similar problem and may have some experience with attempting to solve them.

How Might We

While listening to the experts, note any interesting concepts and create a "How Might We" note on a Post-it. These are questions that could be interesting to solve, like "HMW - Structure key info for screening patients?". Write in big markets so it forces you to be concise, and so that it can be seen easily.

  1. Write a "How Might We" on a Post-it by yourself
  2. Stick it onto a wall when everyone is done
  3. Vote silently with sticker "dots". Each person gets two dots, while the Decider gets four dots.
  4. Select the ones with multiple votes and use those targets to guide the rest of the sprint

Pick the Target

The final task for Monday is to choose the target for your sprint. Who is the most important customer, and what is the most critical experience for them? The "How Might We" notes can often make this decision obvious, but the Decider is always the one who gets the final say–this is the biggest opportunity to do something great.

If the decider wants help, use a straw poll. Everyone should write their vote on a piece of paper, and after the votes are tallied, there should be a discussion on any big differences in opinion. The decider can now make their call.

Now that you have identified a long-term goal and question to answer, everyone will be ready for the next step: it's time to come up with some solutions.

Tuesday: Sketch

Not gonna lie, I wrote everything above about 4 months ago, and I don't remember the book in as much depth.

The goal for this day is to generate a wide range of potential solutions. You start by reviewing what you did yesterday, and then each person will individually sketch, following a four-step process: notes, ideas, crazy 8s, and solution sketch.

  1. Notes: Have the team walk around the room and take notes to refresh their memories before committing to a solution. Feel free to research specific details from the company's own product. This takes about twenty minutes, and then spend three minutes at the end reviewing everything.
  2. Ideas: Jot rough ideas, fill a sheet of paper with doodles, diagrams, stick figures, etc. Take twenty minutes with this and then review at the end for three minutes.
  3. Crazy 8s: Each person takes their strongest ideas and rapidly sketches eight variations in eight minutes. This promotes potential breakthroughs.
  4. Solution Sketch: Sketch a three-panel of the final solution to be looked at and judged by others. It's the final sketch!

Wednesday: Decide

Today you'll evaluate ideas and decide on the solution that will be prototyped. There's a five-step process.

  1. Art museum: Put the solution sketches on the wall with masking tape
  2. Heat map: Look at all the solutions in silence, and use dot stickers to mark interesting parts
  3. Speed critique: Quickly discuss the highlights of each solution, and use sticky notes to capture big ideas
  4. Straw poll: Each person chooses one solution, and votes for it with a dot sticker
  5. Supervote: The Decider makes the final decision, with more stickers!

Thursday: Prototype

Now it's time to build a prototype that can be tested with real users. It's much more effective and easier to fake it rather than build the real thing. It'll emulate what your product will actually do, without needing the complex implementation and lack of polish.

Here's one way to do this.

  1. Pick the right tools: Often, your usual tools are too slow. Use something like Apple's Keynote that can mimic what you want quickly. I'd probably use Figma.
  2. Divide and conquer: Makers will create individual components, while Stitchers will put them together. Writers make the content reasonable (we hate lorem ipsum).
  3. Stich it together: Make sure fake content is consistent throughout the app
  4. Do a trial run: Do it around 3pm to give you enough time to fix it.

Friday: Test

Now it's time to learn from watching/interviewing users. There should generally be around five interviewees.

Here's how you should run them.

  1. Friendly welcome: People need to feel comfortable to be honest and open, so start with something like "Thanks for coming in today! Your feedback is really important to us"
  2. Context questions: Ask about the customer's background so you get a better idea on who they are and how they'd user your product
  3. Introduce the prototype: "Would you like to see the prototype? I didn't design it so I won't be hurt by your feedback. Also think aloud!"
  4. Tasks and nudges: "What do you expect that will do? What is this for?". Just gauge their reactions.
  5. Quick debrief: "How does this product compare to what you do now? What did you wish was different?"

In general, you should be watching these interviews together and taking notes as a team (on a giant whiteboard). Look for patterns in reactions and see if they answer the questions you came up with on Monday.

The best part is that you can't lose. Either you're on the right track, or you only spent five days exploring a tangent.

Conclusion

Now you can go test your ideas quickly! I won't use this for a while since I don't have a startup nor do I have a huge team. But what I do have is a Stanford interview tomorrow, so I'm going to sleep now and then I'll have a great time talking with this guy!

]]>
<![CDATA[Gunn Matchomatics]]>https://blog.dylanlu.com/gunn-matchomatics/65a0d93b8d052450e0772800Fri, 12 Jan 2024 07:18:42 GMT

Bro, Gunn pays $700 a year for matchomatics. What a freaking scam. I bet I can do better. And I have two days to do it.

(Spoilers: we did it!)

GitHub - ThePickleGawd/matchomatics: Why pay $700?
Why pay $700? Contribute to ThePickleGawd/matchomatics development by creating an account on GitHub.
Gunn Matchomatics

The Goal

We want to turn this:

Gunn Matchomatics
Our own form

Into this.

Gunn Matchomatics
Really $700?

Students fill out a form and get matched with people similar to them, across many different categories. Seems simple enough.

The Setup

I'm using Python since it's good for managing lots of data. Once we have all the responses from the Google Form, we can download it as a .csv file and save that on our computer.

Gunn Matchomatics
Sample data generate by ChatGPT

In matches.py I basically read all this data and do a nested loop to match each person with every other person. All of these matches (along with identifying data such as name, gender, grade) are flattened into an array and stored in a new .csv file.

To find the match-compatibility score, we can use Dylan Lu's magical love-matching algorithm. We give "points" for questions that are answered the same or very closely, and we give extra points for matching "dependent" questions (for example, I answered that I prefer girls with brown hair, and a girl answered they have brown hair).

Gunn Matchomatics
Dylan Lu's Magical Love-Matching Algorithm

Now that we've matched everyone, we'll need to convert the outputted .csv file into something printable and pretty. I made an HTML template with Jinja2, and I use a Python script (csv_to_html.py) to pass all my data into that template to generate hundreds of pages.

The template.html file is basically a giant wrapper that includes the basic boilerplate HTML needed and brings in Tailwind. We take all our data and pass it to a new person.html, which presents it in a pretty page format.

Gunn Matchomatics
template.html
Gunn Matchomatics
person.html with data

Now we can generate hundreds of these and print them out!

Gunn Matchomatics
It's printable!

Conclusion

I'm not asking for $700, but I do want some credit for putting in all this work today and yesterday (see bottom of the previous two pictures!). Tomorrow, we'll need to figure out how to print out all 700+ copies of these...

As always, I'll update this article and let you know what happens in the end.

]]>
<![CDATA[Best Christmas Break Ever?]]>https://blog.dylanlu.com/best-christmas-break-ever/658da45929d18318e4bfd8ceWed, 10 Jan 2024 06:32:59 GMT

My family was driving to my grandparents' house for a Christmas dinner when my dad announced that we needed to make a quick stop at the airport to pick up his old college friend. I was a little skeptical—when was the last time he hung out with a college friend in California? and why can't he get an Uber?—but I decided it wasn't that big of a deal. Then we got there, and I saw who it actually was: my little cousins, aunt, and uncle!

I missed my little cousins and aunt and uncle, so I was really excited and surprised to see them make a last-minute trip all the way from Beijing. My grandparents, on the other hand, burst out in tears. The whole family was together, and everyone was happy.

Before Christmas

I'm not gonna lie, I left my Econ final an hour early because I was incredibly unmotivated to continue the test. I then played Elden Ring for 3 hours when I got home.

Speaking of Elden Ring, that's what I did literally all day for the next days, because I was super sad about something.

But then I got over it. And I started writing my college apps again.

Christmas

Even though my parents made it absolutely clear that we would not get any gifts this year (the iPhone for our birthdays was good enough!), they called my sister and I down in the morning, and I got a 2TB SSD drive! I was genuinely excited, and it felt good knowing that my dad cared enough to surprise me with something I actually wanted.

My uncle (Yen Yen) got me cologne. I never thought about using cologne before, but, in my uncle's words, it's time for me to be a man now. So I started to wear it every day, and I think it smells pretty good!

Best of all, I now had enough Christmas + Birthday money to buy my latest toy: the iPad Pro. Why? Because now I can write all my notes digitally, and I can use it as a second monitor for my Macbook at school. My dad said that was a very gimmicky reason to drop $1k, but as they say, "spend a lot on things you care about, but really save when it's something else." I'm paraphrasing and I don't remember where I read it, but you get the point. Of course, that also meant I spent money on a "paper" screen protector with a special Apple pencil tip, and a really snug magnetic case/stand.

But now that I have an iPad Pro (and have joined the "Macbook Pro, iPhone Pro, Airpods Pro, and iPad Pro" family), I actually use it for things I'd never thought I would. First off, my dad bought a recipe-making app, so I'm learning to cook with it. I've made chicken quesadillas so far (which are so good), and I'm moving my way up to steak eventually. My dad also has Procreate, which is a drawing app. I'm doing this thing where I draw a little bit (almost) everyday, and then see where I end up in a year/several months. Right now, I'm drawing things from Zelda, Dragon Ball Z, and Elden Ring, and I'll hopefully get better as I progress.

To end Christmas, the whole family sang, I played violin (after not touching it for 6+ years), Jocelyn played clarinet, and Evelyn and Kevin played piano. Wai Po also gave us a math challenge for $100, and of course, I won it!

Best Christmas Break Ever?
I'm a Pro
Best Christmas Break Ever?
First Quesadilla

The Day After

We went to Ruby Hill to eat lunch and play golf with Tyler Wong's family. It was really nice getting to play with my grandpa at least once more before his membership ends. I'm still no good at golf, but I'm improving and will try joining the Gunn golf team eventually.

When we got back, I treated my family to duck at this place called Imperial Treasure in downtown Palo Alto. Since we had 10 people, they gave us the VIP seating, which had a remote control spinny table and a private room. The duck was like $200 bro.

Best Christmas Break Ever?
Kevin can drive?
Best Christmas Break Ever?
Duck

Before New Years

Now that I had my fun, it was time to get back on the college application grind. Jiu Jiu and Jiu Ma were nice enough to give feedback on my essays, leading us to an "EE" day—exercise and essay day. Because the day before they left, that's all we did. Literally, from when I woke up at 7 AM to when I slept at 2 AM.

But looking back, EE day relieved a lot of future stress. I finished Harvard and MIT (both basically from scratch), Stanford, Princeton, Carnegie Mellon, and Columbia. I felt more productive that day than in the preceding two months, and the amount of essays I churned showed it. I think stress is a great motivator.

Oh, and I also got a new book: "The Subtle Art of Not Giving a F*ck." But counter-intuitively, it's all about giving the right fucks: "While not giving a fuck may seem simple on the surface, it's a whole new bag of burritos under the hood" (12).

"While not giving a fuck may seem simple on the surface, it's a whole new bag of burritos under the hood"

I love that quote.

Before My Cousins Leave

I almost forgot the biggest thing. We saw an open house about 3 mins drive from here. I think they're buying it! It's a really nice-looking house, and though it's not confirmed yet, it looks like a pretty done deal.

Like I could visit them at their new house when I come back from college. That's probably the most exciting part of the entire break.

New Years

Not gonna lie, I lost track of time and played Elden Ring through the new year. Whoops, but at least I saw Disney World's New Year celebration through FaceTiming my sister.

If you're me, you can look back at my digital journal and see what my 2024 resolutions were, maybe you accomplished them? (which in that case, good job man!) If not, you need more confidence.

Last Moments Before School

By now, I'm basically done with college apps, other than fine-tuning certain areas. That means that each day, I wake up, play Elden Ring/Pokemon SoulSilver (on my iPad with an emulator for the nostalgia of course), go to practice, and play more. I think I was genuinely addicted, checking in like 5 hours a day. I think I'm good now though. Writing this post instead of playing is proof?

And on the final day before school started, I played golf with my friends. That was probably one of my worst performances, but fun nonetheless.

Second Semester Senior

No more stressing about school. I'm free baby!

Best Christmas Break Ever?
]]>