Object oriented programming

java put name before the variable name.

public class test
{
    public static void main(String[] args)
    {
        Picture rocket = new Picture("mariner4.jpg");
        rocket.translate(200, 200);
        rocket.draw();
        Picture planet = new Picture("mars.gif");
        planet.grow(-50, -50);
        planet.draw();
    }
}
public class test
{
    public static void main(String[] args)
    {
        Day birthday = new Day(1951, 5, 26);
        Day lastDay = new Day(2012, 5, 26);
        int daysAlive = lastDay.daysFrom(birthday);
        System.out.println(daysAlive);
    }
}

variable can vary and assignment has no type.

int numberOfPixels = object.methodname(arguments)

public class test
{
    public static void main(String[] args)
    {
        Rectangle box = new Rectangle(60, 90, 20, 30);
        Rectangle box2 = new Rectangle(80, 120, 20, 30);
        box.draw();
        box2.draw();
    }
}
public class test
{
    public static void main(String[] args)
    {
        String river = "Mississippi";
        int numberOfLetters = river.length();
        System.out.println(numberOfLetters);
    }
}

replace method

public class test
{
    public static void main(String[] args)
    {
        String river = "Mississippi";
        String result = river.replaceAll("i","x");
        System.out.println(result);
    }
}

cut space with trim()

String messyString = "Hello, Space!";
        messyString.trim()

AccessorとMutator:「Accessor=アクセスするヤツ」、「Mutator=mutate(訳すと変化させる)」
An accessor method is used to return the value of a private field.
A mutator method is used to set a value of a private field. It follows a naming scheme prefixing the word “set” to the start of the method name.

Implement test program, set actual result and expected result.

Test program

public class test
{
    public static void main(String[] args)
    {
        System.out.println("Hello\nWorld!");
    }
}

print and println

public class test
{
    public static void main(String[] args)
    {
        System.out.print(3);
        System.out.println(4 + 5);
    }
}

compile error

public class test
{
    public static void main(String[] args)
    {
        System.ouch.println(4 + 5);
    }
}

Hadoop

The reason to use big data is it’s too big to store in one machine.Challenges with big data is data is created fast and data from different source in various formats.

Hadoop
Store in HDFS
process with MAPREDUCE

Hadoop ecosystem
pig, hive … select * from
mapreduce, impala, hbase
HDFS <- sqoop, flume Hue, oozie, mahout Cloudera is a distribution of Hadoop(CDH) Hadoop picks three node as random.

jasmine

javascript test library
https://jasmine.github.io/

describe('Address Book', function(){
  it('should be able to add a contact', function(){
    var addressBook = new AddressBook(),
    thisContact = new Contact();

    addressBook.addContact(thisContact);

    expect(addressBook.getContact(0)).toBe(thisContact);
  });
});
describe('Address Book', function(){
  it('should be able to add a contact', function(){
    var addressBook = new AddressBook(),
    thisContact = new Contact();

    addressBook.addContact(thisContact);

    expect(addressBook.getContact(0)).toBe(thisContact);
  });

  it('should be able to delete a contact', function(){
    var addressBook = new AddressBook(),
    thisContact = new Contact();

    addressBook.addContact(thisContact);
    addressBook.deleteContact(0);

    expect(addressBook.getContact(0)).not.toBeDefine();
  });
});

grunt file

/*
 After you have changed the settings at "Your code goes here",
 run this with one of these options:
  "grunt" alone creates a new, completed images directory
  "grunt clean" removes the images directory
  "grunt responsive_images" re-processes images without removing the old ones
*/

module.exports = function(grunt) {

  grunt.initConfig({
    responsive_images: {
      dev: {
        options: {
          engine: 'im',
          sizes: [{
            /*
            Change these:
            
            width: ,
            suffix: ,
            quality:
            */
          }]
        },

        /*
        You don't need to change this part if you don't change
        the directory structure.
        */
        files: [{
          expand: true,
          src: ['*.{gif,jpg,png}'],
          cwd: 'images_src/',
          dest: 'images/'
        }]
      }
    },

    /* Clear out the images directory if it exists */
    clean: {
      dev: {
        src: ['images'],
      },
    },

    /* Generate the images directory if it is missing */
    mkdir: {
      dev: {
        options: {
          create: ['images']
        },
      },
    },

    /* Copy the "fixed" images that don't go through processing into the images/directory */
    copy: {
      dev: {
        files: [{
          expand: true,
          src: 'images_src/fixed/*.{gif,jpg,png}',
          dest: 'images/'
        }]
      },
    },
  });
  
  grunt.loadNpmTasks('grunt-responsive-images');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-mkdir');
  grunt.registerTask('default', ['clean', 'mkdir', 'copy', 'responsive_images']);

};

https://unicode-table.com/en/

compression level

watch out image compression level and natural width.
should be less pixels.

Total bits = pixel x bit per pixel

    body {
      margin: 0;
    }
    img {
      float: left;
      margin-right: 10px;
      width: calc((100% - 20px)/3);
    }
img:last-of-type {
	margin-right: 0;
	}

Vector scales without quality degradation.

$0.naturalWidth
601
$0.naturalWidth
1202

The process of DOM

Characters -> Tokens -> Nodes -> DOM

Request page -> GET html -> page head(build DOM, render) -> search result(build DOM, render)

Characters -> Tokens -> Nodes -> CSSOM
hi tag is faster evaluation than div p tag as dom tree.

JavaScript is parser blocking

Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via npm install –save async, it can also be used directly in the browser.

first canvas

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<canvas id="my_canvas"></canvas>
</body>
<script>
	var canvas = null;
	var context = null;

	setup = function(){

	canvas = document.getElementById("my_canvas");
	context = canvas.getContext('2d');
	canvas.width = 1200;
	canvas.height = 720;
	};
</script>
</html>

flex-box

<style tyle="text/css">
      .container {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
      }
      .box {width: 150px;}
 </style>

column drop, off canvas, layout shifter, mostly fluid

media query

<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" media="screen and (min-width:500px)" href="over500.css">

media query within a style sheet.

@media screen and (min-width: 500px){
	body { color: #F79420; }
}

@media screen and (min-width: 800px){
	body { background-color: blue; }
}

frequently used max-width and min-width

@media screen and (max-width: 500px){
	.yes {
		opacity: 1;
	}
	. no {
		opacity: 0;
	}
}

change background-color with width.

body {
	  	background-color: green;
	  }
  	  @media screen and (max-width: 400px) {
        body {
        background-color: red;
        }
      }
  	  @media screen and (min-width: 600px) {
        body {
        background-color: blue;
        }
      }

developer tool help you to decide media query
%e7%84%a1%e9%a1%8c