What if your screen suddenly change to lower resolution, here is the short script to set it back.

Sometimes, it happens that your external monitor is quite old, and the system couldn’t recognize your monitor and flash it back to 1024×768. How do you fix it?

Create a .sh file that can run sequence of commands and put it at any place you want.

This case, my monitor supports max 1440×900 at 60Hz, so I create a file, say xrandr.sh, run this file on terminal and your nice resolution will be back:

sudo xrandr –newmode “1440x900_60.00” 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
sudo xrandr –addmode VGA-1 1440x900_60.00
xrandr –output VGA-1 –mode 1440x900_60.00

Change the frame of the CUBE AMS

  1. The new frame AMS 110 Race: 255 EUR
  2. 180mm disc brake: 13.28 EUR
  3. Bushing for the rear suspension 39.88*8: 19.38 EUR
  4. Bottom bracket BB92: 21.43 EUR
  5. Cables + housings: 10 EUR
  6. ABUS lock 6400/85mm: 73.80 EUR
  7. Pinhead lock system: 65.03 EUR
  8. Spacer: 1 EUR

Old bike: 450 EUR

Total cost for the new setup:  459.19 EUR

Total spending: 909.19 EUR

Things can be reused in the future bike: locks: 138.83 EUR

Alternative option is to buy a new bike of 300 EUR. However, at this price, I cannot find a decent bike.

Conclusions: Total waste of money! Damm! :(( Anyway, I enjoy fixing the bike.

Add a package in emacs when couldn’t find in local package-install list

The following has been tested to work on an emacs -Q session:

  1. Launch emacs -Q
  2. Add the below in the scratch buffer:
    (require 'package)
    (add-to-list 'package-archives
     '("melpa" . "http://melpa.org/packages/") t)
  3. Evaluate the buffer (M-x eval-buffer)
  4. Do M-x package-install RET auto-complete RET
    The package will install.

How to install Nvidia driver for dual graphic card laptop (Sony SVS)

There are some steps you have to do before installing the driver of nvidia for your card.

1. Check if your Ubuntu is running with the dedicated graphic card or internal graphic card.
– System setting -> Details

– Run this command lspci | grep VGA in Terminal to see if your laptop support dual

$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 640M LE] (rev a1)

2. To avoid the loop login after install  the nvidia driver. Run these:

$ sudo apt install mokutil
$ sudo mokutil --disable-validation

This problem was caused due to secure boot and EFI_SECURE_BOOT_SIG_ENFORCE in linux kernel 4.4.0-20 and later.

3. Check the latest nvidia driver with this command, pick the one that recommended:

$ sudo ubuntu-drivers devices
[sudo] password for cuongtd: 
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
model : GK107M [GeForce GT 640M LE]
modalias : pci:v000010DEd00000FD3sv0000104Dsd0000909Cbc03sc00i00
vendor : NVIDIA Corporation
driver : nvidia-304 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
driver : nvidia-375 - distro non-free recommended
driver : nvidia-340 - distro non-free

4. See that nvidia-375 is recommended , we install it

$ sudo apt-get install nvidia-375

5. After finish, type this to go to Nvidia setting:

$ nvidia-settings

At the tab PRIME Profiles, choose Nvidia and restart the computer, or just login to register the changes.

6. Check the usage of your GPU with this command (or go to nvidia setting to see it)

$ nvidia-settings -q GPUUtilization -q useddedicatedgpumemory

7. To quickly change between Intel and Nvidia profiles, install prime-indicator to have an icon in the task bar

$ sudo add-apt-repository ppa:nilarimogard/webupd8
$ sudo apt-get update
$ sudo apt-get install prime-indicator

This allows changing profile on-fly, however it requires a log-out to make the change.

At the moment, these is what I did, I’ve tried it and the rendering was faster than before, you may try out with the command glxgears to check the FPS:

$ glxgears

The results were 60 FPS for Intel card, and 8000 FPS for Nvidia card.


SOLVED: Duplicate icons in the Ubuntu Launcher

  1. Launch the application
  2. Fire up a terminal and run xprop WM_CLASS. Click the application window.
  3. You’ll get some output like WM_CLASS(STRING) = "Navigator", "Firefox". Choose one of the classes, eg Firefox in this example
  4. Add the class as the value of StartupWMClass in the .desktop file. For example, StartupWMClass=Firefox
  5. Save the .desktop file, close the application and re-open it. There should now only be 1 icon in the launcher

From https://askubuntu.com/questions/403766/duplicate-icons-for-manully-created-gnome-launcher-items

FAQ: Homotopy continuation method

From: http://math.stackexchange.com/questions/127774/using-homotopy-to-solve-system-of-nonlinear-equations


1. Do I have the right idea about Homotopy or am I talking in gibberish? Homotopy methods are good numerical methods which can be used to solve nonlinear systems (Algebraic or differential) of equations. The idea is to defort the given system f(x)=0 to be another system H(x,t)=tf(x)+(1-t)g(x) where g(x) has a known solution and t is a parameter in the closed interval [0, 1]. This new system is called homotopy or deformation of f(x). Here f(x) and g(x) are called homotopic because H(x,0)=g(x) and H(x,1)=f(x). Starting from the known solution of g(x)=0 at t=0, we can trace the zero curve (path) until t=1 where the answer is x* is the desired solution.

2. Does Homotopy give all the roots? Homotopy methods will give different roots based on the selection of the initial solution (the solution of G(x)=0 at t=0). One root will be obtained for each initial solution.

3. If so, when I plug in some value of x, does H(x,t) give the closest root or some random roots like N-R? The closet root can be obtained depends on the smoothness of the path. I mean as small as you chosen the value of ∆t, you will get the good solution of the given system.

4. What is a good rule of thumb for choosing G(x) ? G(x) can be chosen by for any formula with condition G(x) can be easily solved to get the initial solution. For example, you can choose G(x)=F(x)-F(x0) for any arbitrary value of x0. In this case the homotopy H(x,t)=F(x)+(t-1)F(x0) is called Newton homotopy. Also, you can put G(x)=x-x0 and the obtained homotopy in this case is called fixed point homotopy. I created my own homotopies like constant homotopy and identity homotopy and I found that the are work to find a good solution for the given system.

5. Is there other iterative methods out there that are better or more efficient than N-R or Homotopy? Until now, the homotopy methods can be considered as the best methods to solve nonlinear algebraic systems because they are global methods (always converge) where for any arbitrary solution x0, we can get a solution. In N-R method, the initial solution has to be close to the desired solution to be convergent otherwise will be divergent.