Friday, April 13, 2018

ExecJS::RuntimeError: SyntaxError: Unexpected token punc «(», expected punc «:»

I got this error when deploy Rails app to production server.
This error will be raised if your javasctripts on assets include ES6 syntax.

These steps will fix the probrem.

  1. Update uglifier
    bundle update uglifier
  2. Modify config/environments/production.rb
    config.assets.js_compressor = :uglifier
    config.assets.js_compressor = true)

Tuesday, April 19, 2016

Screen resolutions and image ratios of Android devices

The base resolution(1.0) is mdpi, and ratios of other resolutions are below.
ldpi = 0.75
mdpi = 1.00
hdpi = 1.5
xhdpi = 2.0
xxhdpi = 3.0
xxxhdpi = 4.0

Width for each resolution of an image which width is 100px
ldpi = 75px
mdpi = 100px
hdpi = 150px
xhdpi = 200px
xxhdpi = 300px
xxxhdpi = 400px

Supporting Multiple Screens | Android Developers

Thursday, March 19, 2015

Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?

Docker Compose raise error below.
$ docker-compose up Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
$(docker-machine env MACHINE NAME) solved the problem.
$(docker-machine env dev)

Saturday, March 7, 2015

docker-machine hang at Waiting for VM to start...

I've installed docker-machin on Mac OSX(10.8.5), and it hangs up at  Waiting for VM to start... when start docker machine.
Then I've upgraded Virtual Box to 4.3.24 and rm stacked docker-machine and created a new docker-machine.
That solved the problem

Saturday, September 21, 2013

Install NTP on CentOS

Install NTP
sudo yum install ntp

Start NT
sudo /etc/init.d/ntpd start

Configure NTP servers
Select NTP server which close to your location from area list.
sudo vi /etc/ntp.conf

Replace default NTP servers.

Restart NTP
sudo /etc/init.d/ntp stop sudo /etc/init.d/ntp start

Check sync status.
 time server re-starting
  polling server every 64 s

If just started NTP, it won't start synchronize, it will take 10 or more minutes to start syncronizing.
If successfully synchorised, you will see messages like this.
synchronised to NTP server ( at stratum 3
  time correct to within 30 ms
  polling server every 64 s

Configure automatic run. at booting.
sudo /sbin/chkconfig ntpd on
sudo /sbin/chkconfig --list
ntpd ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Note. NTP uses UDP port 123 to synchronize.
If you have filtered this port, you have to open port 123.
To open this port you can open with the following iptables arguments.
-I INPUT -p udp --dport 123 -j ACCEPT
-I OUTPUT -p udp --sport 123 -j ACCEPT

Thursday, June 2, 2011

Random search in Rails

User.find(:all,'RAND()',:limit =>5)
User.find(:all,'RANDOM()',:limit =>5)

Wednesday, June 1, 2011

Installing Zen Coding eclipse plugin

Select menu
Help > Install New Software ... > and add into location column.

Check Zen Coding for Eclipse and proceed

After instaling finished, type html > Ctrl(command) + E and it will converted <html></html> if installing successfully finished.