Traffic Throttling on Linux

I guess I should document this since I spent some time to get this to work.

In short, to rate limit a box to 30MB/s
tc qdisc add dev eth1 root tbf rate 30mbps burst 10kb latency 70ms mtu 100000

The reason why we set mtu to 10000 is because of this.

To delete this rule:
tc qdisc del dev eth1 root

And to view current setting:
tc -s qdisc ls dev eth1

Garmin 310XT sync w/ Linux

Thanks to pyusbGarmin-Forerunner-610-Extractor and GcpUploader, I am finally able to sync my Garmin 310XT watch with Garmin connect on my Linux box.

Garmin-Forerunner-610-Extractor downloads all the activity files from the watch, then calls callback scripts under $XDG_CONFIG_HOME(usually ~/.config)/garmin-extractor/scripts. In this case, it calls a script that uses gcpuploader to upload to Garmin Connect.

Don’t be fooled by the name, Garmin-Forerunner-610-Extractor actually supports a lot of Garmin devices that use ANT+:

  • Garmin Forerunner 60
  • Garmin Forerunner 405CX
  • Garmin Forerunner 310XT
  • Garmin Forerunner 610
  • Garmin Forerunner 910XT
  • Garmin FR70
  • Garmin Swim

Here is what I did (on Archlinux, other distro should be similar):

sudo pacman -S python2-pip #install pip for python2
sudo pip2 install pyusb --pre #need version newer than 1.0a2
sudo pip2 install GcpUploader #install GcpUploader

git clone [email protected]:Tigge/Garmin-Forerunner-610-Extractor.git
cd Garmin-Forerunner-610-Extractor

# since we run as root, so the config needs to be under /root
sudo cp scripts/40-upload_to_garmin_connect.py /root/.config/garmin-extractor/scripts
sudo chmod a+x /root/.config/garmin-extractor/scripts/40-upload_to_garmin_connect.py

Also needs to change the path to gupload in the script:

# CHANGE ME:
gupload = "/usr/bin/gupload.py"

Add garmin connect credentials in /root/.guploadrc

[Credentials]
username=yourgarminuser
password=yourgarminpass

Finally, run garmin.py to sync!

sudo python2 garmin.py

Bonus: I also find trapiriik.com can sync between Garmin connect, Runkeeper, Strava, endomondo activities. One button push, sync all of them. Or for $2 a year, it can auto sync between accounts. Pretty good deal 🙂

 

Git bisect

最近很少有这种突然眼前一亮的时候,今天有点例外。凑着光棍节的热闹,来介绍一下Git bisect。

事情是这样的,S同学下班之前做了一个commit,break了pipeline。等我们发现的时候已经是n个小时之后,也不知道是哪个commit出的问题。这是一个很常见的问题,常见的做法就是git log然后一个个去checkout。Git bisect就是一个替代人肉搜索的一个命令。

git bisect start #start
git bisect bad #current branch is bad
git bisect good <SHA-1> #some old commit that is good

然后就是

git bisect good

或者

git bisect bad

来告诉git这个commit是否是好的,n个回合之后,就能找出罪魁祸首了。