Skip to content

Instantly share code, notes, and snippets.

View mingliangguo's full-sized avatar

Mingliang mingliangguo

View GitHub Profile
@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 February 27, 2020 20:21
Github GraphQL API to find all comments by a user #graphql #github
{
user(login: "john-doe") {
commitComments(first: 100) {
nodes {
commit {
repository {
nameWithOwner
}
abbreviatedOid
}
@mingliangguo
mingliangguo / log4j2-config.md
Created December 2, 2019 00:05
lo4j2 configuration

log4j2 configuration

Configuration automatic reload

When configured from a File, Log4j has the ability to automatically detect changes to the configuration file and reconfigure itself. If the monitorInterval attribute is specified on the configuration element and is set to a non-zero value then the file will be checked the next time a log event is evaluated and/or logged and the monitorInterval has elapsed since the last check. The example below shows how to configure the attribute so that the configuration file will be checked for changes only after at least 30 seconds have elapsed. The minimum interval is 5 seconds.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30">
...