Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jacygao's full-sized avatar
🎯
Focusing

Jacy Gao jacygao

🎯
Focusing
View GitHub Profile
@jacygao
jacygao / index.html
Created April 5, 2023 09:23
Pure CSS 'organic-looking' EKG Animation
<div class="container">
<div class="grid">
<div class="col-10_sm-12">PATIENT ID #1888450</div>
<div class="col-2_sm-12">12/04/18 20:15</div>
</div>
</div>
<div class="container">
package main
import "fmt"
func main() {
s1 := "abcdefg%!~~"
s2 := "ac%dgf!b~e~"
fmt.Println(isPermutation(s1, s2))
}
Authentciation aka AuthN proves an user or an application who they say they are, traditionally through username and password, or in modern days with biometrics or MFA.
Authorisation aka AuthZ comes after Authentication which determines the proven identity what it is allowed to do on a scope of resources.
@jacygao
jacygao / maximum-depth-of-n-ary-tree.java
Created November 8, 2020 10:31
Given a n-ary tree, find its maximum depth.
class Solution {
public int maxDepth(Node root) {
if (root == null) {
return 0;
}
return dfs(root);
}
public int dfs(Node n) {
int maxChild = 0;
@jacygao
jacygao / BinaryTreeLevelOrderTraversal.java
Last active November 6, 2020 12:39
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level)
class Solution {
public List<List<Integer>> levelOrder(TreeNode root) {
List<List<Integer>> out = new ArrayList<List<Integer>>();
dfs(root, out, -1);
return out;
}
public void dfs(TreeNode node, List<List<Integer>> out, int dep) {
dep++;
if(node != null) {
@jacygao
jacygao / go-test.bash
Created September 21, 2020 04:37
Go Code Coverage
#!/bin/bash
MIN_COVER=67.5
go test ./... -coverprofile cover.out
CODE_COVER=$( go tool cover -func=cover.out | tail -1 | sed '/^$/d;s/[[:blank:]]//g' | sed 's/total:(statements)//g' | sed 's/%//g' )
rm -rf cover.out
if [[ "${CODE_COVER}" < "${MIN_COVER}" ]]
then
echo "*** CODE COVERAGE CHECK FAILED, EXEPECTED ${MIN_COVER}%, GOT ${CODE_COVER}% ***"