Last active
April 16, 2026 13:57
-
-
Save ishideo/52fe1a57282bf2e369cdab8e9850d8a1 to your computer and use it in GitHub Desktop.
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 characters
| #!/usr/bin/env bash | |
| bb -e ' | |
| (let [ips (str/split-lines (slurp "ip.tsv")) | |
| table (map #(str/split % #"\t") (str/split-lines (slurp "ip_domain.tsv"))) | |
| idx (into {} (map (juxt first second) table))] | |
| (doseq [ip ips] | |
| (println (get idx ip))))' |
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 characters
| #!/usr/bin/env bash | |
| parallel -j1 'bb -e " | |
| (let [ip \"{}\"] | |
| (->> (slurp \"ip_domain.tsv\") | |
| str/split-lines | |
| (map #(str/split % #\"\\t\")) | |
| (filter #(= ip (first %))) | |
| (map #(nth % 1)) | |
| (run! println)))"' :::: ip.tsv |
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 characters
| #!/usr/bin/env bash | |
| cat ip_domain.tsv | bb -e ' | |
| (->> (slurp *in*) | |
| str/split-lines | |
| (map #(str/split % #"\t")) | |
| (into {} (map (juxt first second))) | |
| prn)' \ | |
| | bb -e ' | |
| (let [idx (edn/read-string (slurp *in*))] | |
| (doseq [ip (str/split-lines (slurp "ip.tsv"))] | |
| (println (get idx ip))))' |
Author
#!/usr/bin/env bash
bb -e '
(->> (slurp "ip_domain")
str/split-lines
(map #(str/split % #"\t"))
(into {} (map (juxt first #(nth % 1))))
prn)' \
| bb -e '
(let [idx (edn/read-string (slurp *in*))]
(doseq [ip (str/split-lines (slurp "ip.tsv"))]
(println (get idx ip))))'
Author
#!/usr/bin/env bash
clojure -M -e '
(->> (slurp "ip_domain.tsv")
clojure.string/split-lines
(map #(clojure.string/split % #"\t"))
(into {} (map (juxt first #(nth % 1))))
prn)' \
| clojure -M -e '
(let [idx (clojure.edn/read-string (slurp *in*))]
(doseq [ip (clojure.string/split-lines (slurp "ip.tsv"))]
(println (get idx ip))))'
Author
#!/usr/bin/env python
import sys
def read_lines(filepath: str) -> list[str]:
with open(filepath) as f:
return f.read().splitlines()
def build_index(table_path: str) -> dict[str, str]:
lines = read_lines(table_path)
return dict(
row[0], row[1]
for line in lines
if len(row := line.split("\t")) >= 2
)
def lookup(ips: list[str], index: dict[str, str]) -> list[str]:
return [index.get(ip, "") for ip in ips]
def main():
ips = read_lines("ip.tsv")
index = build_index("ip_domain.tsv")
results = lookup(ips, index)
print("\n".join(results))
if __name__ == "__main__":
main()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.