Last active
April 4, 2023 21:16
-
-
Save lc/9bfa09ef9bdf593a69f7bbc33dfbd90d to your computer and use it in GitHub Desktop.
Revisions
-
lc revised this gist
Jul 17, 2019 . 1 changed file with 9 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,34 +10,21 @@ import ( func main() { // usage: printf "example.com" | waybackurls | waywords words := make(map[string]struct{}) w := bufio.NewScanner(os.Stdin) for w.Scan() { u, err := url.Parse(w.Text()) if err != nil { continue } for _, t := range strings.Split(u.Path, "/") { if t == "" { continue } words[t] = struct{}{} } } for word, _ := range words { fmt.Println(word) } } -
lc created this gist
Jun 28, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ package main import ( "bufio" "fmt" "net/url" "os" "strings" ) func main() { // usage: printf "example.com" | waybackurls | waywords var words []string w := bufio.NewScanner(os.Stdin) for w.Scan() { u, err := url.Parse(w.Text()) if err != nil { continue } t := strings.Split(u.Path, "/") words = append(words, t...) } final := un(words) for _, word := range final { if word != "" { fmt.Println(word) } } } func un(words []string) []string { known := map[string]bool{} final := []string{} for word := range words { if known[words[word]] { } else { known[words[word]] = true final = append(final, words[word]) } } return final }