Skip to content

Instantly share code, notes, and snippets.

View ky28059's full-sized avatar
πŸ₯°

Kevin Yu ky28059

πŸ₯°
View GitHub Profile
@ky28059
ky28059 / CoolKotlinThings.kt
Created March 4, 2021 08:22
The epic presentation from UC, compiled into a file
import kotlin.collections.HashMap
fun main() {
// Like with Java's public static void main(String[] args),
// kotlin programs are accessed through the main function
// Types
// Kotlin is a strongly typed language, but type declarations are optional when they can be inferred.
// Kotlin also has implicit type casting.
@ky28059
ky28059 / N sets.kt
Last active December 5, 2021 00:43
N sets
fun main() {
println(allCombinations(setOf(1, 2)))
println(allCombinations(
setOf(1, 2, 3),
setOf(4, 5, 6, 7, 8),
setOf(9, 10)
))
println(allCombinations(
setOf("abc", "def", "ghi"),
setOf("aaa", "bbb")

Lambdas

Lambdas in Java are declared similarly as arrow functions in JavaScript, using -> instead of =>. Unlike other variables, lambdas cannot be declared using var; they must provide an explicit target type.

Lambdas are assignable to functional interfaces as defined in java.util.function and threading interfaces like Runnable and Callable<T>; here, we declare a simple lambda using Runnable which prints a message when run:

Runnable lambda = () -> {
    System.out.println("Hello from a lambda expression!");
};

Short circuit evaluation is a type of lazy evaluation where a boolean expression with || or && can return early if the left-hand value suffices to determine the expression's value.

Conceptually, if the left-hand side of an || expression is true, we don't care about the right; no matter what the right-hand side evaluates to, we know the expression will always evaluate to true. Similarly, if the left-hand side of an && expression is false, we don't need to know what the right-hand side evaluates to as we know that the expression will always evaluate to false.

If the left-hand side of an || expression is false (or the right-hand side of an && expression true), the value of

@ky28059
ky28059 / FollowPathCommand.java
Last active April 28, 2022 23:41
A `SwerveSubsystem` shell for GRT 2022-2023.
package frc.robot.commands.swerve;
import java.util.List;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.math.controller.ProfiledPIDController;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.trajectory.Trajectory;
@ky28059
ky28059 / vercel.md
Last active April 21, 2025 21:33
Deploying to Vercel from an organization for free using GitHub actions

This gist was partially inspired by this blog about Next.js Vercel CI with GitHub actions.

The problem

An easy way to deploy and host websites for free is to use GitHub pages. If you've deployed a Next.js project to GitHub pages, you may have used a GitHub action similar to this in the past to automatically redeploy the site when a new commit is pushed:

# gh-pages-merge.yml
name: Deploy to gh-pages on merge
on:
  push:

BuckeyeCTF 2023 β€” typescrip

I like typescript. Do you like typescript?

nc chall.pwnoh.io 13381

We're given a JavaScript server that looks like this:

import { createServer } from "net";
import { Project } from "ts-morph";

iCTF 2023 β€” escape_from_markov

We made a fake flag generator just for this CTF! It can generate flags that look like the real one! Can you find the real flag?

nc 0.cloud.chals.io 34879

We're given a Python server that looks like this:

#!/usr/bin/env python3

import io

iCTF 2023 β€” IslandParty

You open your mailbox and find a strange postcard (invite.bmp). Flipping it around, you squint your eyes and try to decipher the wobbly handwriting:

...

MYSTERIOUS INVITE: 'Generative AI is all the rage this days, so I couldn't pass up the opportunity to use it for this year's invite. Have you heard models like Google's Imagen will include a hidden watermark on AI generated images? I might not have algorithms quite as fancy as Google's, but I've also encoded a little something into this invite--the address! Decode it, and you'll be more than welcome to attend.'

...

MYSTERIOUS INVITE: 'One last piece of advice. All great thing come in three. Three sides to a triangle, three wise monkeys, three lights in a stoplight. Let the number three guide you, and you shall find my island.'

iCTF 2023 β€” CI Ninja

I found this project that uses a state-of-the-art fully automatic patching system. I could not find a way to break it, but I know the flag is in /flag.txt. Do you think you can get it?

nc 0.cloud.chals.io 18519

We connect to a server that looks like this:

image

The server contains the following C program (a simple hello world)