React+Material-UI

Posted: July 10, 2019 in Uncategorized

I have been playing around of React recently and found this superb https://material-ui.com/, which provides a lot of widgets for you to add to your React app.

It reminds me of the old days when I first saw Bootstrap. It empowered developers to develop fantastic UI without wasting time with slices from photoshop-only designers. Material-UI with React makes it better.

With React and Material-UI, i managed to revamp my small website over one weekend. Check it out here: http://www.twomoms.sg

Advertisements

The code is working fine in local development, however, when deployed to production, it will return 404 when directly accessing a url managed by React Router.

The reason is because the server doesn’t understand the url and it’s managed by React Router in the client side. The simplest solution is to change your server configuration to redirect all request to index.html.

For example, in Apache .htaccess

RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

This error happened when I configured RoundCube behind AWS ALB.

A lot of answers suggested that RoundCube behind proxy may have this issue. The fix is to make sure $config[‘ip_check’] = false in your config.ini.php.

This exception is thrown when I tried to launch my Android App with DrawerLayout. The App is following the official guide from Google: https://developer.android.com/training/implementing-navigation/nav-drawer. But it doesn’t work.

After a lot of research, I cannot find any workable solution. 

At the end, i noticed another DrawerLayout from different namespace, i.e., android.support.v4.widget.DrawerLayout.  I have seen this namespace from AndroidX and my App has been using AndroidX. I shouldn’t use the old support library namespace any more.

After following the mapping in https://developer.android.com/jetpack/androidx/migrate, i starts to see different exception, which are for other support libraries. 

AAndroidX maps the original support library API packages into the androidx namespace. I shouldn’t mix them together.

Ubuntu cannot start Terminal

Posted: September 27, 2018 in Linux

When I try to start gnome-terminal through xterm, i see this error: Error calling StartServiceByName for org.gnome.Terminal

To fix this issue: $localectl set-locale LANG=”en_US.UTF-8″

Reboot

Socket connections uses file descriptor and it’s limited.

For Ubuntu, you can ulimit -a to see the current limit. (ulimit is not a binary command, so that no need sudo)

To increase the openfile to a maximum limit of 4096, you can ulimit -n 4096.

More than 4096 must edit the system file /etc/security/limits.conf.

In the current terminal, you will need su to make the settings take effect.

After restarting tomcat, the log will return to normal.

To keep it short, for my case, it’s because we have two WARs deployed to the same Tomcat and both are writing to the same file.