<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>HectorGuo's Blog</title>
    <description>A full stack developer, happy to share all the new ideas and methods about Web Development and Web Design.</description>
    <link>//hectorguo.com/</link>
    <atom:link href="//hectorguo.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 04 Feb 2020 18:17:24 +0000</pubDate>
    <lastBuildDate>Tue, 04 Feb 2020 18:17:24 +0000</lastBuildDate>
    <generator>Jekyll v3.8.5</generator>
    
      
      <item>
        <title>Two practices for isolating front-end development from back-end</title>
        <description>&lt;p&gt;It is not uncommon that when a project is initialized, engineering team starts to build front-end and back-end simultaneously. Sometimes, there are some dependencies with each other — UI-side needs data from server-side for validation, Server-side needs an interface for testing. However, we can not do nothing until another side’s ready. Below are two practices I want to share for keeping front-end development separate from back-end.&lt;/p&gt;

&lt;h1 id=&quot;1-host-a-local-server&quot;&gt;1. Host a local server&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214357.png&quot; alt=&quot;JSONPlaceholder&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Before waiting for server-side being ready, we can communicate with back-end team to come to an agreement that how the APIs and data format looks like. With these APIs, we can easily create some fake data and host a local server for testing. I recommend JSONPlaceholder, a powerful tool for faking Online REST API. It supports all HTTP Methods, and after you POST a data to the server, the data will also be stored in your local machine, which looks like a real web services. Moreover, it also provide a remote service which allow you to test without hosting a local server.
In the front-end code, it can be like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Replace this URL when server-side is ready&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;SERVER_URL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;https://jsonplaceholder.typicode.com&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getUsers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`{SERVER_URL}/users`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Use the data&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;getUsers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;// render users to DOM&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;By doing this, you don’t need to change lots of code when the server-side is ready. Just replace the SERVER_URL, the real data will be shown correctly.&lt;/p&gt;

&lt;h1 id=&quot;2-leverage-promise&quot;&gt;2. Leverage Promise&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214414.png&quot; alt=&quot;Promise&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, hosting a local server is not practical for sharing. For example, a Product Manager or Test team need to see the UI-side earlier, you can not expect the PM or test team to install a local server on their machine each by each. Also, it is not easy to host a fake server on the internal development machine which is shared by teams. Therefore, we can fake the data in our codes like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// const SERVER_URL = 'https://realhost';&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getUsers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;// return fetch(`{SERVER_URL}/users`);&lt;/span&gt;
  
  &lt;span class=&quot;c1&quot;&gt;// Fake data in the code&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;first_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;hector&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;last_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;guo&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;first_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;john&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;last_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;lee&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}]&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Use the data&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;getUsers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;// render users to DOM&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In this way, we are leveraging Promise to transfer the sync pattern to async pattern. By doing this, we don’t need a local or remote server to run our UI. Just share a static html file with PMs or test team, they can see the result immediately. After the server-side is ready, all we need to do is just remove / comment the fake data code, and uncomment the fetch from server-side.
If there are more practical practices you want to share, please don’t hesitate to comment.&lt;/p&gt;
</description>
        <pubDate>Sun, 04 Jun 2017 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/isolating-front-end-development/</link>
        <guid isPermaLink="true">//hectorguo.com/en/isolating-front-end-development/</guid>
        
        <category>Front-end</category>
        
        <category>ES6</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>Prototype for improving cooking process on Apple Watch</title>
        <description>&lt;p&gt;We designed a smartwatch prototype for improving cooking process. Its main purpose is to help &lt;a href=&quot;https://www.blueapron.com/&quot;&gt;Blue Apron&lt;/a&gt; attract more users.&lt;/p&gt;

&lt;p&gt;&lt;style&gt;
.embed-wrapper {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 */
	padding-top: 25px;
	height: 0;
}
.embed-wrapper iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
&lt;/style&gt;&lt;/p&gt;

&lt;h1 id=&quot;wireframe&quot;&gt;Wireframe&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214317.png&quot; alt=&quot;wireframe1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214332.png&quot; alt=&quot;wireframe2&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;prototype&quot;&gt;Prototype&lt;/h1&gt;

&lt;div class=&quot;embed-wrapper&quot;&gt;
    &lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/Qs-1pmAYj8Q?rel=0&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h1 id=&quot;slides&quot;&gt;Slides&lt;/h1&gt;

&lt;div class=&quot;embed-wrapper&quot;&gt;
    &lt;iframe src=&quot;https://docs.google.com/presentation/d/1kkic9Up8aPIvNg6vKmgycr8_qUV7OSTrIs2iOkemipo/embed?start=false&amp;amp;loop=false&amp;amp;delayms=3000&quot; frameborder=&quot;0&quot; width=&quot;960&quot; height=&quot;569&quot; allowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot; webkitallowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://docs.google.com/presentation/d/1kkic9Up8aPIvNg6vKmgycr8_qUV7OSTrIs2iOkemipo/embed?start=false&amp;amp;loop=false&quot;&gt;Slides Source&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 17 May 2017 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/blue-apron/</link>
        <guid isPermaLink="true">//hectorguo.com/en/blue-apron/</guid>
        
        <category>Smartwatch</category>
        
        <category>Design</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>Architecture and Program Principles</title>
        <description>&lt;p&gt;APP (Architecture and Program Principles)&lt;/p&gt;

&lt;p&gt;Recommended Books:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Clean Code&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The Pragmatic Programmer&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;architecture-section-preview&quot;&gt;Architecture Section Preview&lt;/h1&gt;

&lt;h2 id=&quot;loosely-coupled-systemsoa&quot;&gt;Loosely-Coupled System(SOA)&lt;/h2&gt;
&lt;p&gt;Challenges: how to define the Services and their interaction&lt;/p&gt;

&lt;h2 id=&quot;non-functional-requirements&quot;&gt;Non-functional Requirements&lt;/h2&gt;

&lt;h2 id=&quot;remote-interface-restful-apis&quot;&gt;Remote Interface (RESTful APIs)&lt;/h2&gt;

&lt;h2 id=&quot;asynchronous-systems&quot;&gt;Asynchronous Systems&lt;/h2&gt;
&lt;p&gt;Challenges:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;need rethinking with an event-driven approach&lt;/li&gt;
  &lt;li&gt;cannot rely on remote services even more than before&lt;/li&gt;
  &lt;li&gt;Testing complicated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reactive Concept&lt;/p&gt;

&lt;h2 id=&quot;stateless-decision-systems&quot;&gt;Stateless Decision Systems&lt;/h2&gt;
&lt;p&gt;Approach:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;how to build decision system that can read to a dynamic state of the world&lt;/li&gt;
  &lt;li&gt;how to coordinate a collection of systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;modern-architecture-concepts&quot;&gt;Modern Architecture Concepts&lt;/h2&gt;
&lt;p&gt;Approach:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to make the right tech and arch decisions for a given problems&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;data-pipelines&quot;&gt;Data Pipelines&lt;/h2&gt;
&lt;p&gt;Approach:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How to develop data-driven use cases&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;coding-section-preview&quot;&gt;Coding Section Preview&lt;/h1&gt;

&lt;h2 id=&quot;managing-technical-debt&quot;&gt;Managing Technical Debt&lt;/h2&gt;
&lt;h2 id=&quot;handling-logic-failures&quot;&gt;Handling Logic Failures&lt;/h2&gt;
&lt;p&gt;Log , but how to prevent too much&lt;/p&gt;

&lt;h2 id=&quot;instrumenting-for-verification&quot;&gt;Instrumenting for Verification&lt;/h2&gt;
&lt;p&gt;Approach: how to verify non-functional requirements&lt;/p&gt;

&lt;h2 id=&quot;unit-and-regression-testing-continuous-&quot;&gt;Unit and Regression Testing (Continuous ?)&lt;/h2&gt;
&lt;h2 id=&quot;testing-asynchronous-code&quot;&gt;Testing Asynchronous Code&lt;/h2&gt;

&lt;h3 id=&quot;medical-device-marketplace&quot;&gt;Medical Device Marketplace&lt;/h3&gt;
&lt;p&gt;multi suppliers
multi groups (with different hospitals )
negotiate online&lt;/p&gt;

&lt;p&gt;Players:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;hospitals&lt;/li&gt;
  &lt;li&gt;suppliers&lt;/li&gt;
  &lt;li&gt;manufactures&lt;/li&gt;
  &lt;li&gt;groups&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Concept:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Contract (group, suppliers, negotiation)&lt;/li&gt;
  &lt;li&gt;Price Lists&lt;/li&gt;
  &lt;li&gt;Orders&lt;/li&gt;
  &lt;li&gt;Negotiation&lt;/li&gt;
  &lt;li&gt;Commitment&lt;/li&gt;
  &lt;li&gt;Historic Date (Read, Update, Delete )&lt;/li&gt;
  &lt;li&gt;Returns&lt;/li&gt;
  &lt;li&gt;Payment Terms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Action: CRUD&lt;/p&gt;

&lt;p&gt;Behavior:
Hospital &amp;lt;&amp;gt; Group&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Negotiate Group, Suppliers, Items, Historic Date (optional, maybe first time)&lt;/li&gt;
  &lt;li&gt;Commitment Volumes, historical volumes&lt;/li&gt;
  &lt;li&gt;Volume, items, price when signing contract&lt;/li&gt;
  &lt;li&gt;volume, items, price when paying&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;week-4&quot;&gt;Week 4&lt;/h2&gt;
&lt;h3 id=&quot;4-error-handling-rest&quot;&gt;4. Error Handling, REST&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;bad request (get)&lt;/li&gt;
  &lt;li&gt;depending failure ()&lt;/li&gt;
  &lt;li&gt;internal error (login)&lt;/li&gt;
  &lt;li&gt;Bad code (global)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;http-status-code&quot;&gt;http status code&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;2xx
    &lt;ul&gt;
      &lt;li&gt;200&lt;/li&gt;
      &lt;li&gt;201&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;4xx (Client Side)
    &lt;ul&gt;
      &lt;li&gt;400&lt;/li&gt;
      &lt;li&gt;401&lt;/li&gt;
      &lt;li&gt;403&lt;/li&gt;
      &lt;li&gt;404&lt;/li&gt;
      &lt;li&gt;405&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;5xx (Error)
    &lt;ul&gt;
      &lt;li&gt;500&lt;/li&gt;
      &lt;li&gt;501&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;GET http://server/car/298
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Response:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;statusCode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;404&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;errorCode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1132&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// (reserved not valid)&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;errorMsg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Car is not a valid resource&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Table of error code &amp;amp; message:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Code&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Message&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Properties&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1132&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;{} is not a resource&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;POST /user

Possible error: 
1. Invalid resource (url not exist)
2. Empty Body
3. Invalid Format (XML, JSON)
4. Invaild Attribute
5. Missing Required Attribute
6. Id should not be provided
7. Duplication Attribute
8. Attribute not unique (email address, etc.)
9. Invaild Attribute value (type error)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;instrumentaion&quot;&gt;Instrumentaion&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;Rate limites (day, hour, month)
    &lt;ul&gt;
      &lt;li&gt;log: count API calls by user/api key.&lt;/li&gt;
      &lt;li&gt;check against quota/limit&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Measure Performance (Response, load)
    &lt;ul&gt;
      &lt;li&gt;timestamp&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;throttling
    &lt;ul&gt;
      &lt;li&gt;check for total api call count&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Usage Patterns
    &lt;ul&gt;
      &lt;li&gt;logging&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Logging -&amp;gt; Error&lt;/li&gt;
  &lt;li&gt;Documentation Errors&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;5-persistence-database-api-version-management&quot;&gt;5. Persistence (database), API Version Management&lt;/h3&gt;
&lt;h3 id=&quot;6-scale-performance-security&quot;&gt;6. Scale, Performance, Security&lt;/h3&gt;
&lt;h3 id=&quot;7-async-reactive-programming-data-pipeline&quot;&gt;7. Async, Reactive programming, Data pipeline&lt;/h3&gt;
</description>
        <pubDate>Thu, 22 Sep 2016 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/app-notes/</link>
        <guid isPermaLink="true">//hectorguo.com/en/app-notes/</guid>
        
        <category>app</category>
        
        <category>notes</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
    
      
      <item>
        <title>Universities in United States</title>
        <description>&lt;p&gt;Using Mapbox to visualize the distribution of universities in United States, the data is from Linkedin University Rankings and offical admission sites of universities.&lt;/p&gt;

&lt;p&gt;Data format is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GeoJSON&lt;/code&gt;, you can modify and add other universities on it if you want.&lt;/p&gt;

&lt;p&gt;Welcome to fork it on &lt;a href=&quot;https://github.com/hectorguo/Universities-in-US/&quot;&gt;Github&lt;/a&gt;!&lt;/p&gt;

&lt;link href=&quot;https://api.tiles.mapbox.com/mapbox.js/v2.2.3/mapbox.css&quot; rel=&quot;stylesheet&quot; /&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;/Universities-in-US/style.min.css&quot; /&gt;

&lt;div class=&quot;map-container&quot;&gt;
    &lt;div id=&quot;map&quot;&gt;&lt;/div&gt;
    &lt;nav class=&quot;options&quot;&gt;
        &lt;input type=&quot;checkbox&quot; id=&quot;ivy&quot; checked=&quot;&quot; /&gt;
        &lt;label for=&quot;ivy&quot;&gt;
            &lt;span class=&quot;ivy&quot; title=&quot;常春藤盟校&quot;&gt;Ivy League&lt;/span&gt;
        &lt;/label&gt;
        &lt;h4 title=&quot;Linkedin统计排行&quot;&gt;Linkedin Rank&lt;/h4&gt;
        &lt;ul id=&quot;linkedin&quot;&gt;
            &lt;li&gt;
                &lt;input type=&quot;radio&quot; name=&quot;lk&quot; id=&quot;lk2&quot; value=&quot;dev&quot; /&gt;
                &lt;label for=&quot;lk2&quot;&gt;&lt;span title=&quot;软件开发相关TOP&quot;&gt;Top for DEV&lt;/span&gt;&lt;/label&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;radio&quot; name=&quot;lk&quot; id=&quot;lk3&quot; value=&quot;des&quot; /&gt;
                &lt;label for=&quot;lk3&quot;&gt;&lt;span title=&quot;设计相关TOP&quot;&gt;Top for DES&lt;/span&gt;&lt;/label&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;radio&quot; name=&quot;lk&quot; id=&quot;lk1&quot; value=&quot;none&quot; checked=&quot;&quot; /&gt;
                &lt;label for=&quot;lk1&quot;&gt;&lt;span&gt;Hide&lt;/span&gt;&lt;/label&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
        &lt;h4 title=&quot;托福最低要求&quot;&gt;TOEFL&lt;/h4&gt;
        &lt;ul id=&quot;TOEFL&quot;&gt;
            &lt;li&gt;
                &lt;input type=&quot;checkbox&quot; id=&quot;op1&quot; value=&quot;100&quot; checked=&quot;&quot; /&gt;
                &lt;label for=&quot;op1&quot;&gt;
                    &lt;span&gt;100+&lt;/span&gt;
                &lt;/label&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;checkbox&quot; id=&quot;op2&quot; value=&quot;90&quot; checked=&quot;&quot; /&gt;
                &lt;label for=&quot;op2&quot;&gt;
                    &lt;span&gt;90~100&lt;/span&gt;
                &lt;/label&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;checkbox&quot; id=&quot;op3&quot; value=&quot;80&quot; checked=&quot;&quot; /&gt;
                &lt;label for=&quot;op3&quot;&gt;
                    &lt;span&gt;80~90&lt;/span&gt;
                &lt;/label&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;checkbox&quot; id=&quot;op4&quot; value=&quot;1&quot; checked=&quot;&quot; /&gt;
                &lt;label for=&quot;op4&quot;&gt;
                    &lt;span&gt;0~80&lt;/span&gt;
                &lt;/label&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;input type=&quot;checkbox&quot; id=&quot;op5&quot; value=&quot;-1&quot; checked=&quot;&quot; /&gt;
                &lt;label for=&quot;op5&quot;&gt;
                    &lt;span&gt;No-Spec&lt;/span&gt;
                &lt;/label&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/nav&gt;
&lt;/div&gt;

&lt;h2 id=&quot;data-categories&quot;&gt;Data Categories&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Ivy_League&quot;&gt;Ivy League&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.linkedin.com/edu/rankings/us/graduate-software-engineering?trk=edu-rankings-flt-ctg-dd&quot;&gt;Best graduate universities for software developers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.linkedin.com/edu/rankings/us/graduate-design?trk=edu-rankings-flt-ctg-dd&quot;&gt;Best graduate universities for designers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;TOEFL minimum requirement&lt;/li&gt;
&lt;/ol&gt;

&lt;script src=&quot;https://api.tiles.mapbox.com/mapbox.js/v2.2.3/mapbox.js&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;//hectorguo.com/Universities-in-US/app.blog.min.js&quot;&gt;&lt;/script&gt;

</description>
        <pubDate>Mon, 30 Nov 2015 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/mapbox-starter/</link>
        <guid isPermaLink="true">//hectorguo.com/en/mapbox-starter/</guid>
        
        <category>Visualization</category>
        
        <category>Design</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>Should We Abandon GIF ?</title>
        <description>&lt;p&gt;Recently, I captured an &lt;a href=&quot;http://hectorguo.com/en/iphone-game-controler/&quot;&gt;interesting video&lt;/a&gt; and prepared to share with my friends. I wondered which way I should choose to share it online, uploading to Youtube, or just converting it into a GIF ?  Given that gif is really common and more compatible for a variety of devices than video, so I upload it into &lt;a href=&quot;http://imgur.com/&quot;&gt;Imgur&lt;/a&gt;, the most popular gif distributing platform. Unfortunately, after converting my video into gif, I found the gif format was even much larger than my video. It did astonish me. If gif’s size is larger than a video, why not use video ?  Afterall, it can load faster and cost lower than gif.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I found the gif format was even much larger than my video.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Therefore, I start to search for the best practice in this case. I find that imgur’s website have replaced gif with video for a long time, which is called as &lt;a href=&quot;https://imgur.com/blog/2014/10/09/introducing-gifv/&quot;&gt;GIFV&lt;/a&gt;, using HTML5 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;video&amp;gt;&lt;/code&gt; to load animation images. The advantage of this technology is that a video can be compressed more than a gif does, and it runs more smooth than gif. Because it can be encoded with H264, H265 or VP9, which is an Advanced Video Coding. It sounds interesting. In comparison with gif, I am willing to see how the actual benefit of video is. Let’s convert my video into VP9 format that is the latest coding standard.&lt;/p&gt;

&lt;h2 id=&quot;install-ffmpeg&quot;&gt;Install FFMPEG&lt;/h2&gt;
&lt;p&gt;Af first, we have to install the encoder of VP9 to finish our task. Here is the &lt;a href=&quot;https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu&quot;&gt;offical guide&lt;/a&gt;. But it is really hard to install because of lots of dependencies. And here is the easiest way I think to install all of them by using &lt;a href=&quot;http://brew.sh/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Homebrew&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brew install ffmpeg --with-libvpx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And if you don’t have installed &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Homebrew&lt;/code&gt; yet, here is the quick way:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ruby -e &quot;$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;convert-video-to-vp9-format&quot;&gt;Convert video to VP9 format&lt;/h2&gt;
&lt;p&gt;I admit that there are lots of options in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ffmpeg&lt;/code&gt; command. If you just want to see the result, here is the common use:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Convert a.mp4 to output.webm without audio channel
ffmpeg -i a.mp4 -c:v libvpx-vp9 -threads 8 -speed 1 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -an -strict experimental output.webm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-i a.mp4&lt;/code&gt; means to get the source &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a.mp4&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-c:v libvpx-vp9&lt;/code&gt; means to encode video with vp9&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-threads 8 -speed 1 -tile-columns 6 -frame-parallel 1&lt;/code&gt; all these options are used to optimize efficiency of encoding and decoding&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-an&lt;/code&gt; means to eliminate the audio channel (to eliminate video channel, you can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-vn&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-strict experimental&lt;/code&gt; means to use experimental encoder that has not been supported such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libopus&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more information about them, you can visit &lt;a href=&quot;http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide&quot;&gt;vp9-encoding-guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;comparison&quot;&gt;Comparison&lt;/h2&gt;
&lt;p&gt;After a few hours, I have successfully converted my videos to VP9 format. Here is the size comparison between VP9 video and gif.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214152.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here is a comparison between VP9 format and H264 format:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214205.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You can see, the quality of video aren’t reduced even though the size of VP9 is 67% less than that of H264.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214219.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/6d0af205gw1eyccgin81oj21960yeana.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;p&gt;After viewing the result above, I think it is time to abandon GIF, even though it is really convenient to share on the web platform. Maybe you don’t notice that most of media websites (Twitter, Facebook, Imgur, gyfcat, etc.) have used video instead of gif already.&lt;/p&gt;

&lt;p&gt;After this practice, the reason why I can still view a HD video on Youtube even in a poor speed may have been found by myself. 😊&lt;/p&gt;
</description>
        <pubDate>Tue, 24 Nov 2015 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/should-we-abandon-gif/</link>
        <guid isPermaLink="true">//hectorguo.com/en/should-we-abandon-gif/</guid>
        
        <category>Media-Tech</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>iOS App - Decision Terminator</title>
        <description>&lt;p&gt;This is a mobile app to help people make a decision - just shake your phone and will get a random result. It is based on &lt;a href=&quot;https://www.polymer-project.org&quot;&gt;Google Polymer&lt;/a&gt; and &lt;a href=&quot;https://cordova.apache.org/&quot;&gt;Cordova&lt;/a&gt;, which can support most of mobile platforms. It is under development.&lt;/p&gt;

&lt;h2 id=&quot;demo&quot;&gt;Demo&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/6d0af205jw1ez49j8zqq7j20o40j0jt5.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/6d0af205jw1ez491jpcwwg208w0fsn9f.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Scan the QR code below, experience Beta Version.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/20190608214124.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;iOS and Android version are coming!&lt;/p&gt;

</description>
        <pubDate>Fri, 13 Nov 2015 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/ios-app-random/</link>
        <guid isPermaLink="true">//hectorguo.com/en/ios-app-random/</guid>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>Red Packet Design</title>
        <description>&lt;p&gt;The monitor of my university class is going married. So some of my classmates prepared a gift for him.&lt;/p&gt;

&lt;p&gt;In order to give him a surprise, I designed a red packet embed in avatars of our classmates who have donated money to our monitor. (If I just put our classmates’ names on it, it is not cool at all.)
I believe that it will become a valuable memory of his whole life.&lt;/p&gt;

&lt;h2 id=&quot;the-finished-product&quot;&gt;The Finished Product&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/6d0af205jw1eycjj44ljxj20qo0zktf7.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-design-draft&quot;&gt;The Design Draft&lt;/h2&gt;

&lt;h3 id=&quot;principles-of-design&quot;&gt;Principles of Design&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Consistency&lt;/li&gt;
  &lt;li&gt;Alignment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/hectorguo/blog-imgs/master/img/6d0af205jw1ewlhqcipiij217r1gikhf.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 25 Oct 2015 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/red-package/</link>
        <guid isPermaLink="true">//hectorguo.com/en/red-package/</guid>
        
        <category>Design</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>Responsive Lists Layout - Three CSS solutions</title>
        <description>&lt;p&gt;Recently, I just need to make a lists layout to adapt for PC and mobile devices.
Through viewing some design websites, I get three css solutions to make it.&lt;/p&gt;

&lt;p&gt;Requirement:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Every item has to be aligned center and their width and height have to be equal&lt;/li&gt;
  &lt;li&gt;The layout can be auto wrapped according to the width of different devices&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three CSS Solutions:&lt;/p&gt;

&lt;h3 id=&quot;1-float&quot;&gt;1. Float&lt;/h3&gt;

&lt;p&gt;It is the most common solution, but many websites avoid to use them because of unstable height of content that might cause text overflow.
But there is a tricky solution that can avoid this issue. We just need to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:after&lt;/code&gt; to add an extra blank content without float to make sure the height can be controlled.
Here is the solution.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;c&quot;&gt;/*float layout*/&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.float&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1200px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.float&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;:after&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;both&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;visibility&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.float-item&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;2-inline-block&quot;&gt;2. Inline-block&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Inline-block&lt;/code&gt; is simple to add, but one of the shortages is that there will be an backspace between items. Given the extra margin between items, we cannot keep an ideal space between items, even though the extra space is not obvious.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;c&quot;&gt;/*inline-block*/&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.inline-b&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1200px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.inline-b-item&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inline-block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;3-flexbox&quot;&gt;3. Flexbox&lt;/h3&gt;

&lt;p&gt;Flexbox is a new feature of CSS3, and it makes the layout of pages more flexible. Given the complexity of this feature, no more descripion about it will be shown here. If you want to know more about it, please view &lt;a href=&quot;https://css-tricks.com/snippets/css/a-guide-to-flexbox/&quot;&gt;CSS-Tricks&lt;/a&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;c&quot;&gt;/*Flexbox*/&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.flex&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;list-style&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-webkit-box&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-moz-box&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-ms-flexbox&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-webkit-flex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;nl&quot;&gt;-webkit-flex-flow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;justify-content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;space-around&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Here is the demo of three solutions.&lt;/p&gt;

&lt;p data-height=&quot;653&quot; data-theme-id=&quot;20354&quot; data-slug-hash=&quot;BoZEyW&quot; data-default-tab=&quot;result&quot; data-user=&quot;hectorguo&quot; class=&quot;codepen&quot;&gt;See the Pen &lt;a href=&quot;http://codepen.io/hectorguo/pen/BoZEyW/&quot;&gt;Responsive List Layout (Flexbox vs Float vs Inline-Block)&lt;/a&gt; by Hector Guo (&lt;a href=&quot;http://codepen.io/hectorguo&quot;&gt;@hectorguo&lt;/a&gt;) on &lt;a href=&quot;http://codepen.io&quot;&gt;CodePen&lt;/a&gt;.&lt;/p&gt;
&lt;script async=&quot;&quot; src=&quot;//assets.codepen.io/assets/embed/ei.js&quot;&gt;&lt;/script&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
      &lt;th&gt;Compatibility&lt;/th&gt;
      &lt;th&gt;Reference&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Float&lt;/td&gt;
      &lt;td&gt;Common use, adapted for lists layout with lots of items.&lt;/td&gt;
      &lt;td&gt;Any device&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;dribbble.com&quot;&gt;dribble&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inline-block&lt;/td&gt;
      &lt;td&gt;adapted for some cases that do not care much about the margin&lt;/td&gt;
      &lt;td&gt;IE8+&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Flexbox&lt;/td&gt;
      &lt;td&gt;Different device, different exclusive design. More flexible solution. Emphasis on center alignment.&lt;/td&gt;
      &lt;td&gt;IE10+（IE10 partial support with prefix: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-ms-&lt;/code&gt;）&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://css-tricks.com/snippets/css/a-guide-to-flexbox/&quot;&gt;CSS-tricks&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

</description>
        <pubDate>Sun, 25 Oct 2015 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/list-layout-css/</link>
        <guid isPermaLink="true">//hectorguo.com/en/list-layout-css/</guid>
        
        <category>CSS</category>
        
        <category>Front-end</category>
        
        
        <category>en</category>
        
      </item>
      
    
      
      <item>
        <title>CSS: Font Setting to Adapt for Multi Platforms</title>
        <description>&lt;p&gt;Apple just publish its new systems iOS 9 and OS X EI Capitan recently. With these new systems, a new kind of font are also published, which called &lt;a href=&quot;https://developer.apple.com/videos/wwdc/2015/?id=804&quot;&gt;San Francisco&lt;/a&gt;. It looks like more light and readable than &lt;a href=&quot;https://en.wikipedia.org/wiki/Helvetica&quot;&gt;Helvetica&lt;/a&gt;, so I decide to use it on my website. However, I realize that the declaration on my style is:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&quot;Helvetica Neue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Helvetica&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With this style, you can not render this page in new font. I just search for the solution, and find a trick on &lt;a href=&quot;https://www.webkit.org/blog/3709/using-the-system-font-in-web-content/&quot;&gt;Webkit site&lt;/a&gt;, you can just add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-apple-system&lt;/code&gt; in front of other font declaration:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-apple-system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;Helvetica Neue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Helvetica&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With this generic family name, the browser will render web pages with the system default font automaticlly. However, this name just adapt for Apple browser or web view. If you want to use it in Chrome or another browser, it is suggested to do the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;-apple-system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&quot;.SFNSDisplay-Regular&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&quot;Helvetica Neue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Helvetica&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It is said that:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.SFNSDisplay-Regular&lt;/code&gt; is the private font name for the regular face of San Francisco in the current beta release (remember, it can change at any time!)
The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;system&lt;/code&gt; generic family name doesn’t currently exist, but I’d encourage browser manufacturers to adopt this technique. It would be helpful for coders on all platforms.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Therefore, I suggest that we can also add some other family name to adapt for Windows and Android. The following is my final style:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;-apple-system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;Helvetica Neue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Helvetica&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;Lucida Grande&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;Open Sans&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;Microsoft YaHei&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;Open Sans&quot;&lt;/code&gt; works for Android and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;Microsoft YaHei&quot;&lt;/code&gt; works for Windows. Even though it isn’t a perfect solution, it works fine in Windows, Android and Apple platform after I use my devices to check if it shows correctly.&lt;/p&gt;

&lt;p&gt;BTW, I recommend a tool called &lt;a href=&quot;http://chengyinliu.com/whatfont.html&quot;&gt;Whatfont&lt;/a&gt; to help you identify what kind of font it is on a web page.&lt;/p&gt;

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;
&lt;p&gt;[1] &lt;a href=&quot;http://furbo.org/2015/07/09/i-left-my-system-fonts-in-san-francisco/&quot;&gt;I Left My System Fonts in San Francisco&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[2] &lt;a href=&quot;https://www.webkit.org/blog/3709/using-the-system-font-in-web-content/&quot;&gt;Using the System Font in Web Content&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 17 Sep 2015 00:00:00 +0000</pubDate>
        <link>//hectorguo.com/en/font-family-setting/</link>
        <guid isPermaLink="true">//hectorguo.com/en/font-family-setting/</guid>
        
        <category>CSS</category>
        
        <category>Front-end</category>
        
        
        <category>en</category>
        
      </item>
      
    
  </channel>
</rss>
