Skip to content

Instantly share code, notes, and snippets.

View digizeph's full-sized avatar
🌟

Mingwei Zhang digizeph

🌟
View GitHub Profile
@digizeph
digizeph / map.sh
Created September 14, 2013 00:20
Mac OS X: Open up Google Maps to show the place you type in as arguments. For example: ./map.sh University of Oregon, Eugene OR, and it will pop up a Chrome browser, open Google Maps, gives you the map of University of Oregon.
#!/bin/bash
open http://maps.google.com/?ll=$(python -c "from geopy import geocoders as gc; from sys import argv;_,lat = gc.GoogleV3().geocode(' '.join(argv[1:])); print '%s,%s'%(lat[0],lat[1])" $@)
@digizeph
digizeph / country-to-emoji.js
Created October 5, 2022 17:32
Country code to emoji conversion function
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
@digizeph
digizeph / 2023-05-25-37468-pfxs.txt
Last active May 25, 2023 17:04
Prefixes announced on May 25th 2023 between 9 to 13 UTC with AS paths matches "37468 3356 16509". Data collected from all public route-views and ripe ris collectors. Used `monocle search --start-ts 2023-05-25T09:00:00Z --end-ts 2023-05-25T13:00:00Z --as-path ".*37468 3356 16509.*" --sqlite-path angola.sqlite3` to generate the data.
130.137.121.0/24
52.20.0.0/14
18.232.0.0/14
52.4.0.0/14
54.80.0.0/14
54.144.0.0/14
54.160.0.0/14
54.156.0.0/14
18.204.0.0/14
130.137.102.0/24
@digizeph
digizeph / pfxs.txt
Created May 25, 2023 17:03
Prefixes announced on May 25th 2023 between 9 to 13 UTC with AS paths matches "37468 3356 16509". Data collected from all public route-views and ripe ris collectors.
130.137.121.0/24
52.20.0.0/14
18.232.0.0/14
52.4.0.0/14
54.80.0.0/14
54.144.0.0/14
54.160.0.0/14
54.156.0.0/14
18.204.0.0/14
130.137.102.0/24
@digizeph
digizeph / pfx2as.rs
Created May 9, 2023 15:50
Parse a RIB dump file into prefix-to-AS mapping HashMap
fn pfx2as(url: &str) -> Result<HashMap<IpNet, HashSet<u32>>> {
let mut data: HashMap<IpNet, HashSet<u32>> = HashMap::new();
for elem in bgpkit_parser::BgpkitParser::new(url)? {
let prefix = elem.prefix.prefix;
let origins = elem
.origin_asns
.unwrap()
.into_iter()
.map(|v| v.asn)
.collect::<Vec<u32>>();
@digizeph
digizeph / PlainGraph.java
Created August 25, 2015 19:14
Simple graph visualization using graphstream library.
package visualization;
import org.graphstream.graph.Graph;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import java.util.Iterator;
public class PlainGraph {
public static void main(String args[]) {
OTC found: 15562 for path 23673:6939:15562
A|1678932008|203.189.128.233|23673|67.221.245.0/24|23673 6939 15562|IGP|203.189.128.233|0|0||NAG||
OTC found: 15562 for path 293:6939:15562
A|1678932008|198.129.33.85|293|67.221.245.0/24|293 6939 15562|IGP|198.129.33.85|0|710||NAG||
OTC found: 15562 for path 11686:6939:15562
A|1678932008|96.4.0.55|11686|67.221.245.0/24|11686 6939 15562|IGP|96.4.0.55|0|0|11686:195|NAG||
OTC found: 15562 for path 18106:6939:15562
@digizeph
digizeph / freebsd-simple-rc.sh
Created December 4, 2017 01:41
Simple template for freebsd rc script
#!/bin/sh
. /etc/rc.subr
name=gobgp
rcvar=gobgp_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
stop_postcmd="${name}_cleanup"
@digizeph
digizeph / emacs-installation.org
Last active September 10, 2022 14:59
Emacs 27 and Doom Emacs Setup Guide

Emacs 27 and Doom Emacs Setup Guide

Goal

Build Emacs 27 from source code and install Doom Emacs

Install Emacs

Checkout sourcecode

@digizeph
digizeph / hegemony-2022-01-01.csv
Created August 3, 2022 00:59
global IHR hegemony score for 2022-01-01
We can't make this file beautiful and searchable because it's too large.
asn,score
41583,0.0000000832982923058288
13744,0.00000016659591938094
15738,0.00000485721161558585
204489,0.0000000832980944379421
40768,0.0000000832980944379421
52989,0.00000145343505139675
46793,0.000000166595179383151
397335,0.000000333193169223315
263348,0.000000333193169223315