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

http://stackoverflow.com/questions/27614056/osx-boot2docker-hangs-on-waiting-for-vm-and-docker-daemon-to-start#28782567

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.
http://support.ntp.org/bin/view/Servers/NTPPoolServers
sudo vi /etc/ntp.conf

Replace default NTP servers.
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
to
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

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

Check sync status.
ntpstat
unsynchronised
 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 (180.235.254.234) 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

#MySQL
User.find(:all,'RAND()',:limit =>5)
#PostgreSQL,SQLite
User.find(:all,'RANDOM()',:limit =>5)

Wednesday, June 1, 2011

Installing Zen Coding eclipse plugin

Select menu
Help > Install New Software ... > and add http://zen-coding.ru/eclipse/updates/ into location column.
zencoding-url.png

Check Zen Coding for Eclipse and proceed
zencoding-install.png

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

Wednesday, May 25, 2011

jQuery Mobile Page transition without Ajax

Disable all
Add $.mobile.ajaxLinksEnabled = false;
*The order loading javascripts have to be jquery > disable code > jquery mobile .
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6b1.js"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function(){
  $.mobile.ajaxLinksEnabled = false;
});
</script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

Disable specific link
add rel="external" attribute into a tag.
<a link="#" rel="external">Link Text</a>