Recover Root after OTA on [OnePlus]

This is a note to myself:

After OTA, reboot to Recovery Mode, either 1) Power + Volume Down when phone is off, or 2) Developer Options > Advanced Reboot > Reboot to Recovery. Then Install SuperSu zip again.

No data loss. Profit!

 

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 🙂

 

Kindle wifi w/ Mac Airport Sharing

My Kindle has some problem with my company wifi because Kindle does not support certificates. So i decide to give Mac Internet Sharing a try. No luck, Kindle says ‘Cannot connect’. After researching online, the problem seems to be clear (from mobileread.com):

The problem is that the kindle aways uses 0 in the “number of seconds since boot” field of the dhcp request packet, and the mac has a filter of 4. So it ignores the DHCP request from the kindle (and the xbox, and the Nintendo).

It suggests to edit /etc/bootpd.plist and change reply_threshold_seconds to 0. But that file gets reset every time you starts and stops the sharing. So the easier solution is just to use static ip instead:

Setting >> wifi >> select your SSID >>..wait..>> Wi-fi Error dialog >> Set Up >> Advanced >> Advanced Options:

Connection Type: Static
IP Address:      10.0.2.xx (anything from 2 to 254)
Subnet Mask:     255.255.255.0
Router:          10.0.2.1
DNS:             10.0.2.1

>> Connect!

Cheers.

How to Access Host machine via SSH in Virtualbox

There are sufficient articles teaching ppl how to access guest machine via ssh in virtualbox, while it takes me time to figure out the reverse way. It is very important since i dont that trust virtual machine and i hope to do the one-way backup of my work in the host.

Well, here is the answer. If using NAT, the ip address 10.0.2.2 is the host machine.

Note: remember to add “sshd: 127.0.0.1” in /etc/hosts.allow otherwise the sshd gives u “ssh_exchange_identification: connection closed by remote host” error.