Skip to content

Instantly share code, notes, and snippets.

View mingliangguo's full-sized avatar

Mingliang mingliangguo

View GitHub Profile
@mingliangguo
mingliangguo / list-gcp-projects.py
Created July 1, 2025 15:25
list gcp projects with cloud resource manager API
import json
import time
from google.auth import default
from googleapiclient.discovery import build
def search_all_projects(scope: str):
credentials, _ = default()
service = build("cloudasset", "v1", credentials=credentials)
@mingliangguo
mingliangguo / grokking_to_leetcode.md
Created May 20, 2022 01:58
Grokking the coding interview equivalent leetcode problems

EDIT: Forked the original list and added suggestions from comments

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

/**
* Expands glob expressions to regular expressions.
*
* @param globExp the glob expression to expand
* @return a string with the regular expression this glob expands to
*/
public static String wildcardToRegexp(String globExp) {
StringBuilder dst = new StringBuilder();
char[] src = globExp.replace("**/*", "**").toCharArray();
int i = 0;
@mingliangguo
mingliangguo / cheatsheet.gradle.md
Last active December 12, 2021 20:29
gradle recipe
gradle wrapper --gradle-version=5.6.4

# publish a subproject to maven local
./gradlew build -x check -x test :sub-project:publishToMavenLocal

check if an extra gradle file exists and apply it

@mingliangguo
mingliangguo / cheat_sheet.c
Last active September 28, 2020 02:24
C cheatsheet #c #array #pointer
# dynamically allocate a 2d array in C
#define maxlinelength 10
char (*lines)[maxlinelength] = malloc( sizeof( char[maxlinelength] ) * numlines ) ;
lines[0][0] = 'A' ;
@mingliangguo
mingliangguo / lambda.java
Last active November 29, 2020 02:23
Java lambda java
int[] nums = new int[]{3, 5, 9, 2, 6};
nums = IntStream.of(nums).boxed().sorted(Comparator.reverseOrder()).mapToInt(i -> i).toArray();
List<Integer> list = new ArrayList<>();
int[] arr = list.stream().mapToInt(i -> i).toArray();
// convert array to string
Arrays.toString(new int[]{1, 2, 3});
@mingliangguo
mingliangguo / xcode-select.sh
Created April 10, 2020 00:55
install xcode-commandline in Mac
# remove current installed xcode developer tool (/Library/Developer/CommandLineTools)
sudo rm -rf $(xcode-select -print-path)
# install xcode-select
xcode-select --install
@mingliangguo
mingliangguo / pr-reviewers.graphql
Created February 27, 2020 20:25
Github GraphQL API to retrieve all reviewers of a user's PRs #graphql #github
query PRReviewers {
user(login:"john-doe") {
pullRequests(first: 100, states: CLOSED) {
totalCount
edges {
node {
... on PullRequest {
repository {
nameWithOwner
}
@mingliangguo
mingliangguo / all-comments.graphql
Last active August 28, 2024 17:24
Github GraphQL API to find all comments by a user #graphql #github
{
user(login: "john-doe") {
commitComments(first: 100) {
nodes {
commit {
repository {
nameWithOwner
}
abbreviatedOid
}