CSS3 Transitions

CSS3 transitions allows you to change property values smoothly (from one value to another), over a given duration.

div {
    width: 100px;
    height: 100px;
    background: red;
    -webkit-transition: width 2s; /* For Safari 3.1 to 6.0 */
    transition: width 2s;
}
div:hover {
    width: 300px;
}

Change Several Property Values

div {
    -webkit-transition: width 2s, height 4s; /* Safari */
    transition: width 2s, height 4s;
}

Specify the Speed Curve of the Transition

#div1 {transition-timing-function: linear;}
#div2 {transition-timing-function: ease;}
#div3 {transition-timing-function: ease-in;}
#div4 {transition-timing-function: ease-out;}
#div5 {transition-timing-function: ease-in-out;}

Delay the Transition Effect

div {
    -webkit-transition-delay: 1s; /* Safari */
    transition-delay: 1s;
}

Transition + Transformation

div {
    -webkit-transition: width 2s, height 2s, -webkit-transform 2s; /* Safari */
    transition: width 2s, height 2s, transform 2s;
}

References
http://www.w3schools.com/css/css3_transitions.asp

CSS3 2D Transforms

translate()
The translate() method moves an element from its current position (according to the parameters given for the X-axis and the Y-axis).

div {
    -ms-transform: translate(50px, 100px); /* IE 9 */
    -webkit-transform: translate(50px, 100px); /* Safari */
    transform: translate(50px, 100px);
}

rotate()
The rotate() method rotates an element clockwise or counter-clockwise according to a given degree.

div {
    -ms-transform: rotate(20deg); /* IE 9 */
    -webkit-transform: rotate(20deg); /* Safari */
    transform: rotate(20deg);
}

scale()
The scale() method increases or decreases the size of an element (according to the parameters given for the width and height).

div {
    -ms-transform: scale(2, 3); /* IE 9 */
    -webkit-transform: scale(2, 3); /* Safari */
    transform: scale(2, 3);
}

skewX()
The skewX() method skews an element along the X-axis by the given angle.

div {
    -ms-transform: skewX(20deg); /* IE 9 */
    -webkit-transform: skewX(20deg); /* Safari */
    transform: skewX(20deg);
}

skewY()
skew()
matrix()
The matrix() method combines all the 2D transform methods into one.

References
http://www.w3schools.com/css/css3_2dtransforms.asp

Change DNS on Ubuntu

In /etc/NetworkManager/NetworkManager.conf comment out the line dns=dnsmasq

sudo nano /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq

and restart the NetworkManager service.

sudo restart network-manager

sudo rm -f /etc/resolv.conf # Delete the symbolic link
sudo nano /etc/resolv.conf # Create static file

# Content of static resolv.conf
nameserver 208.67.220.220
nameserver 208.67.220.222

References
http://askubuntu.com/questions/690511/how-to-change-dns-in-ubuntu-15-10

CSS media Query

if screen width is less than 768px use this custom style:

#loginBody {
  width: 600px;
  height: 400px;
  margin-top: 100px;
  border-radius: 25px;
  background: rgb(238, 238, 238);
  background: -moz-linear-gradient(left, rgba(238, 238, 238, 1) 0%, #f8f8f8 100%);
  background: -webkit-linear-gradient(left, rgba(238, 238, 238, 1) 0%, #f8f8f8 100%);
  background: linear-gradient(to right, rgba(238, 238, 238, 1) 0%, #f8f8f8 100%);

  @media screen and (max-width: 768px) {
    width: 300px;
    height: 300px;
  }
}

http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
http://www.w3schools.com/css/css_rwd_mediaqueries.asp
http://www.w3schools.com/css/css3_mediaqueries_ex.asp
http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

how to get the last N records in MongoDB

.sort()

db.foo.find().sort({x:1});

The 1 will sort ascending (oldest to newest) and -1 will sort descending (newest to oldest.)

If you use the auto created _id field it has a date embedded in it … so you can use that to order by …

db.foo.find().sort({_id:1});

That will return back all your documents sorted from oldest to newest.

Natural Order

You can also use a Natural Order mentioned above …

db.foo.find().sort({$natural:1});

Again, using 1 or -1 depending on the order you want.

Use .limit()

Lastly, it’s good practice to add a limit when doing this sort of wide open query so you could do either …

db.foo.find().sort({_id:1}).limit(50);

or

db.foo.find().sort({$natural:1}).limit(50);

References
http://stackoverflow.com/questions/4421207/mongodb-how-to-get-the-last-n-records