Shadowsocks Setup and Optimization

Network instability at the office was affecting work, so I set up a Shadowsocks server on my VPS for source code pulls. The steps below work on most Linux distributions and have been tested on Ubuntu 16.04 and 18.04. 2024 Update: The Python version of shadowsocks used in this guide is no longer maintained. The actively maintained implementation is shadowsocks-rust, which offers better performance and support for modern encryption protocols. For a fresh setup, refer to the shadowsocks-rust documentation. The original Python-based steps are preserved below for reference. ...

December 31, 2019 · 3 min · haoxiqiang

Android & Linux Tips Collection #3

Three quick tips: handling the back button in DialogFragment, chmod permission reference, and the underscore problem in SSL hostnames. DialogFragment Back Button Handling DialogFragment has no direct override for the back button. Two approaches were commonly used. Approach 1: Override in onCreateDialog 1 2 3 4 5 6 7 8 9 @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new Dialog(getActivity(), getTheme()){ @Override public void onBackPressed() { // Handle back press here } }; } Approach 2: Via onKeyListener 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 @Override public void onResume() { super.onResume(); Dialog dialog = getDialog(); if (dialog != null) { dialog.setOnKeyListener(this); } } @Override public void onPause() { super.onPause(); Dialog dialog = getDialog(); if (dialog != null) { dialog.setOnKeyListener(null); } } Modern Approach: OnBackPressedDispatcher (AndroidX) For newer versions, use AndroidX’s OnBackPressedDispatcher. Since Fragment 1.6.1, DialogFragment returns a ComponentDialog by default, which has its own OnBackPressedDispatcher: ...

April 5, 2017 · 3 min · haoxiqiang