Skip to content

Instantly share code, notes, and snippets.

View DragonSSS's full-sized avatar

Wilson Song DragonSSS

View GitHub Profile
@DragonSSS
DragonSSS / add_x_to_git_file.md
Last active March 22, 2020 01:09
Add executable permission to the file in git repo

Add Executable Permission to The File in Git Repo

Intro

If git repo includes the shell scripts which need to be executed on linux server, e.g. Travis CI/Gitlab CI, without running chmod +x on the scripts in CI/CD pipeline yaml files you could add executable permission via git command.

Steps

  1. cd to the location of shell scripts
  2. Check the file permission, output could show the current permission like 100644
@DragonSSS
DragonSSS / reset_mac_audio.md
Created March 26, 2020 20:41
Reset Mac Audio

Reset Mac Audio Daemon Process to Fix Audio Issues

  1. Open terminal
  2. Type following command:
sudo killall coreaudiod
  1. Check Mac audio status
@DragonSSS
DragonSSS / full_k8s_svc_name.md
Last active October 11, 2020 02:33
Find FQDN of k8s/OpenShift Service

Find FQDN of k8s/OpenShift Service

In istio, it recommends to use FQDN for k8s service in virtual service for host parameter. Assumed that you have a service with name svc_name in a namespace, kubectl/oc apply -f with the yaml file:

apiVersion: v1
kind: Pod
metadata:
  name: busybox
spec:
  containers:
 - image: busybox:1.31.1
@DragonSSS
DragonSSS / asymmetric.go
Created July 20, 2020 20:47 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
@DragonSSS
DragonSSS / alien_dictionary.md
Last active August 20, 2020 02:10
LeetCode 269 - Alien Dictionary

LeetCode 269 - Alien Dictionary

There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empty words from the dictionary, where words are sorted lexicographically by the rules of this new language. Derive the order of letters in this language. Example 1: Given the following words in dictionary,

[
  "wrt",
  "wrf",
  "er",
  "ett",
@DragonSSS
DragonSSS / graph_valid_tree.md
Last active September 1, 2020 01:08
LeetCode 261 - Graph Valid Tree

LeetCode 261 - Graph Valid Tree

Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.

For example:

Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true.

Given n = 5 and edges = [[0, 1], [1, 2], [2, 3], [1, 3], [1, 4]], return false.

Note: you can assume that no duplicate edges will appear in edges. Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.

@DragonSSS
DragonSSS / number_of_connected_components_in_an_undirected_graph.md
Last active September 1, 2020 01:09
LeetCode 323 - Number of Connected Components in an Undirected Graph

LeetCode 323 - Number of Connected Components in an Undirected Graph

Givenn nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.

Example 1:

     0          3
     |          |
     1 --- 2    4
@DragonSSS
DragonSSS / meeting_rooms.md
Last active September 7, 2020 04:00
LeetCode 252 - Meeting Rooms

LeetCode 252 - Meeting Rooms

Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.

For example, Given [[0, 30],[5, 10],[15, 20]], return false. For example, Given [[7,10],[2,4]], return true.

Solution:

public class Solution {
 public boolean canAttendMeetings(int[][] intervals) {
@DragonSSS
DragonSSS / meeting_rooms_II.md
Last active September 7, 2020 04:01
LeetCode 253 - Meeting Rooms II

LeetCode 253 - Meeting Rooms

Given an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...](si< ei), find the minimum number of conference rooms required.

Example 1:

Input: [[0, 30],[5, 10],[15, 20]]
Output: 2

Example 2: