Skip to content

Instantly share code, notes, and snippets.

View zengyu714's full-sized avatar

Yu Zeng zengyu714

  • Amazon Web Services
  • Seattle
View GitHub Profile
@zengyu714
zengyu714 / disjoint-set-union.py
Last active September 4, 2019 14:34
Algorithms
class DSU:
"""
Disjoint set union with union-by-rank
"""
def __init__(self, n):
# may need to alter the total number, like (n + 1)
self.parent = list(range(n))
self.rank = [0] * n
# count of dsu
self.count = n
@zengyu714
zengyu714 / setup.sh
Last active November 30, 2021 02:46 — forked from bradp/setup.sh
New Mac Setup Script
# echo "Creating an SSH key for you..."
# ssh-keygen -t rsa
# setup github key following https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
echo "Installing xcode-stuff"
xcode-select --install
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
@zengyu714
zengyu714 / git_rebase.md
Created December 22, 2021 18:05 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

/*
* Copyright 2019 Amazon.com, Inc. or its affiliates.
* Licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,