command line

vagrant@vagrant-ubuntu-trusty-64:~$ pwd
/home/vagrant

show hidden file

vagrant@vagrant-ubuntu-trusty-64:~$ ls -a
.  ..  .bash_logout  .bashrc  .cache  .profile  .ssh

ls -al long command

vagrant@vagrant-ubuntu-trusty-64:~$ ls -al
total 28
drwxr-xr-x 4 vagrant vagrant 4096 Jan 18 12:09 .
drwxr-xr-x 4 root    root    4096 Jan 18 12:08 ..
-rw-r--r-- 1 vagrant vagrant  220 Apr  9  2014 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3637 Apr  9  2014 .bashrc
drwx------ 2 vagrant vagrant 4096 Jan 18 12:09 .cache
-rw-r--r-- 1 vagrant vagrant  675 Apr  9  2014 .profile
drwx------ 2 vagrant vagrant 4096 Jan 18 12:09 .ssh

All file in root directory

Linux

Ubuntu:Ease of use on servers, desktops, laptops
https://www.ubuntu.com/

CentOS
https://www.centos.org/

RedHat:Large enterprise / corporate customers
https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux

CoreOS
https://coreos.com/

getting started ubuntu
>vagrant init ubuntu/trusty64

then, start vagrant up command.
here comes


Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-105-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Wed Jan 18 12:13:23 UTC 2017

  System load:  0.09              Processes:           75
  Usage of /:   3.5% of 39.34GB   Users logged in:     0
  Memory usage: 26%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.53.10

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Google app engine

Set Up Development Environment
Editor – Sublime Text

Python 2.7 – check your version by running python -V and if it’s not 2.7.

Git – download git from it’s official site.

SDK – download and install Google App Engine SDK for Python
https://cloud.google.com/appengine/downloads

def sumUp(n):
	total = 0
	for x in range(n):
		total += x
	return total
sumUp = timer.timedFunction(sumUp)
import endpoints
from protorpc import message
from protorpc import message_types
from protorpc import remote

REQUEST_CONTAINER = endpoints.ResourceContainer(
	message_types.VoidMessage,
	name=messages.StringField(1),
)

package = 'Hello'

class Hello(messages.Message):
	"""String that stores a message."""
	greeting = messages.StringField(1)

@endpoints.api(name='helloworldendpoints', version='v1')
class HelloWorldApi(remote.Service):
	"""Helloworld API v1."""

	@endpoints.method(message_types.VoidMessage, Hello,
		path = "sayHello", http_method='GET', name = "sayHello")
	def say_hello(self, request):
		return Hello(greeting="Hello World")

	@endpoints.method(REQUEST_CONTAINER, Hello,
		path = "sayHelloByName", http_method='GET', name = "sayHelloByName")
	def say_hello_by_name(self, request):
		greet = "Hello {}".format(request.name)
		return Hello(greeting=greet)

APPLICATION = endpoints.api_server([HelloWorldApi])

Field Classes
https://cloud.google.com/appengine/docs/python/tools/protorpc/messages/fieldclasses

API Explore
https://developers.google.com/apis-explorer/#p/

translate api

{
  "data": {
    "translations": [
      {
        "translatedText": "Hallo Welt"
      },
      {
        "translatedText": "Mein Name ist Jeff"
      }
    ]
  }
}
from google.appengine.ext import ndb

class Recipe(ndb.Model):
	name = StringProperty()
	ingredients = StringProperty(repeated=True)
	instructions = TextProperty()
	vegetarian = BooleanProperty()
	servings = IntegerProperty()

css trigger

css trigger
https://csstriggers.com/

var isSetup = setupVariables(e);
if(isSetup){
	setInterval(captureFrame.bind(self), 4);
}
else {
	setTimeout(function(){
		setupVariables(e);

		setInterval(captureFrame.bind(self), 4);
	}, 100);
}
var captureFrame = function(){
	canvas.drawImage(cameraVideo, sx /scaleFactor, sy/scaleFactor, sWidth/scaleFactor,
		sHeight/scaleFactor, dx, dy, dWidth, dHeight);

		drawOverlay(dWidth, dHeight, scaleFactor);

		if(self.onframe) self.onframe();

		coordinatesHaveChanged = false;
};

gulp serve command

[vagrant@localhost qrcode]$ gulp serve
[21:54:17] Using gulpfile ~/webapp/app/qrcode/gulpfile.js
[21:54:17] Starting 'styles'...
[21:54:18] styles all files 26.07 kB
[21:54:18] Finished 'styles' after 1.46 s
[21:54:18] Starting 'serve'...
[21:54:19] Finished 'serve' after 505 ms
[WSK] Local URL: http://localhost:3000
[WSK] External URL: http://10.0.2.15:3000
[WSK] Serving files from: .tmp
[WSK] Serving files from: app

callback

function loadImage(src, parent, callback){
	var img = document.createElement('img');
	img.src = src;
	img.onload = callback;
	parent.appendChild(img);
};
var sequence = get('example.json')
.then(doSomething)
.then(doSomethingElse);

Syntax

var promise = new Promise(function(resolve[, reject]){
	var value = doSomething();
	if (thingWorked){
		resolve(value);
	} else if (somethingWentWrong){
		reject();
	}
}).then(function(value) {
	return nextTing(value);
}).catch(rejectFunction);

net cat command

Netcat is a utility that’s used for sending and receiving messages over a network connection. Netcat is known as the Swiss Army knife of networking tools, and we’ll be using it to communicate directly with a server.

# sudo yum install nc nmap
[vagrant@localhost]$ nc google.com 80
GET / HTTP/1.1

HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: http://www.google.co.jp/?gfe_rd=cr&ei=vdh5WPnNOK3K8gfgs5d4
Content-Length: 259
Date: Sat, 14 Jan 2017 07:52:29 GMT


302 Moved

302 Moved

The document has moved here.
[vagrant@localhost ruby3]$ nc example.com 80
HEAD / HTTP/1.1
Host: example.com

HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Sat, 14 Jan 2017 07:55:51 GMT
Etag: "359670651+gzip"
Expires: Sat, 21 Jan 2017 07:55:51 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (rhv/818F)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 606
[vagrant@localhost ruby3]$ nc example.com 80
OPTIONS / HTTP/1.1
Host: example.com

HTTP/1.1 200 OK
Allow: OPTIONS, GET, HEAD, POST
Cache-Control: max-age=604800
Date: Sat, 14 Jan 2017 07:59:08 GMT
Expires: Sat, 21 Jan 2017 07:59:08 GMT
Server: EOS (lax004/280C)
x-ec-custom-error: 1
Content-Length: 0

HTTP/2 was developed by the IETF’s HTTP Working Group, which maintains the HTTP protocol. It’s made up of a number of HTTP implementers, users, network operators and HTTP experts.

Note that while our mailing list is hosted on the W3C site, this is not a W3C effort. Tim Berners-Lee and the W3C TAG are kept up-to-date with the WG’s progress, however.

A large number of people have contributed to the effort, but the most active participants include engineers from “big” projects like Firefox, Chrome, Twitter, Microsoft’s HTTP stack, Curl and Akamai, as well as a number of HTTP implementers in languages like Python, Ruby and NodeJS.

To learn more about participating in the IETF, see the Tao of the IETF; you can also get a sense of who’s contributing to the specification on Github’s contributor graph, and who’s implementing on our implementation list

HTTP request

HTTP /pictures/kitty.jpg /HTTP/1.1
HTTP /pictures/kitty.jpg /HTTP/2.0

header section below

HTTP /pictures/kitty.jpg /HTTP/2.0
Host: www.google.com
User-Agent: Mizilla/5.0
Connection: keep-alive
Accept: text/html
If-None-Match: fd87e6789

HTTP Response
—-
HTTP/1.1 200 OK
Content-Length: 16824 (※how many byte server send)
Server: Apache
Content-Type: text/html
Date: Wed, 06 Apr 2016
Etag: fd87e6789

binary data

http

fetch("http://www.example.com", {
	"method": "GET ",
	"headers": {

	}
});
fetch("password.txt", {
	"method": "PUT",
	"headers": {
		"exercise": "fetch rocks!"
	}
});

Heroku account

get start Heroku account
Heroku

Heroku CLI
https://devcenter.heroku.com/articles/heroku-cli

To verify your CLI installation use the heroku –version command.

heroku-cli/5.6.12-1708b34 (windows-386) go1.7.4

heroku create

> heroku create
Creating app... done, radiant-dawn-72472
https://radiant-dawn-72472.herokuapp.com/ | https://git.heroku.com/radiant-dawn-72472.git

To ensure you have properly created this remote, run the git remote -v command, you should see something output that reveals the two remotes listed, origin and heroku.

> git remote -v
heroku  https://git.heroku.com/radiant-dawn-72472.git (fetch)
heroku  https://git.heroku.com/radiant-dawn-72472.git (push)
origin  https://github.com/udacity/galeria.git (fetch)
origin  https://github.com/udacity/galeria.git (push)

Once you have your application deployed, Heroku will provide you with a URL you can visit to see your site. After this you can run heroku open. This will open up a browser window and navigate to the deployed application URL.

https://dashboard.heroku.com/apps

If you want to change the URL of your application in the future you can do this by logging into your Heroku Dashboard. Many other actions are also available on the dashboard.

Deployment pipeline
development->staging->production

Heroku will allow you one “dyno” or single command container for free. This means that on a free tier Heroku account, you can run one command on the container and you will not be charged for it.

bundle install

[vagrant@localhost ruby3]$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/.
Using json 1.8.3
Installing multi_xml 0.5.5
Installing rack 1.6.4
Installing tilt 2.0.2
Using bundler 1.13.6
Installing httparty 0.13.7
Using rack-protection 1.5.3
Using sinatra 1.4.7
Bundle complete! 3 Gemfile dependencies, 8 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from httparty:
When you HTTParty, you must party hard!
get '/product' do
	...
	@products = []
	LOCATIONS.each do |location|
	 @product.push DATA.select { |product| product['location'] == location }.sample
end
<% @product.each do |product| %>
<a href='/products/location<%= product&#91;location&#93; %>'>
<div class='product'>
	<div class='thumb'>
		<img src='<%= product&#91;'url'&#93; %>'>
	</div>
	<div class='caption'>
		<%= product&#91;'location'&#93; != 'us' ? product&#91;'location'&#93;.capitalize : product&#91;'location'&#93;.upcase %>
		</div>
	</div>
</a>
<% end %>
get '/products/location/:location' do
	DATA = HTTParty.get('https://fomotograph-api.udacity.com/products.json')['photos']
	@products = DATA.select{ |product| product['location'] == params[:location]}
	erb "<!DOCTYPE html>..."
end


get '/products/:id' do
	DATA = HTTPartyp.get('https://hogehoge/products.json')['photos']
	@product = DATA.select{ |prod| prod['id'] == params[:id].to_i }.first
	erb "<!DOCTYPE html> ..."
end	
class Product

	url = 'https://fomotograph-api.com/product.json'
	DATA = HTTParty.get(url)['photos']
end
require 'HTTParty'
require 'json'

class Product

	url = 'https://fomotograph-api.com/product.json'
	DATA = HTTParty.get(url)['photos']

	def initialize(product_data = {})
	@id = product_data['id']
	@title = product_data['title']
	@location = product_data['location']
	@summary = product_data['summary']
	@url = product_data['url']
	@price = product_data['price']
	end

	def self.all
		DATA.map { |product| new(product) }
	end

	def self.sample_locations
		@products = []
		LOCATIONS.each do |location|
		@products.push self.all.select { |product| product.location == location }.sample_locations
		end
		return @product
	end

	def self.find_by_location(location)
		self.all.select { |product| product.location == location }
	end
end
{
	"id"=>27, "title"=>"worlds end", "summary"=>"travel tothe end ...",
	"location"=>"scotland", "price"=>37, "url"=>"/images/scotland/worlds-end.jpg"
}

controller

get '/products' do
	@products = Product.all
	erb :products
end