<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eric on Medium]]></title>
        <description><![CDATA[Stories by Eric on Medium]]></description>
        <link>https://medium.com/@eric-zx?source=rss-4c2e760bb8ca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vG51vYIRjoUUB-1cHOkheQ@2x.jpeg</url>
            <title>Stories by Eric on Medium</title>
            <link>https://medium.com/@eric-zx?source=rss-4c2e760bb8ca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:45:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eric-zx/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flutter: get started]]></title>
            <link>https://eric-zx.medium.com/flutter-get-started-c064a4250b6e?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/c064a4250b6e</guid>
            <category><![CDATA[begineers]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Sun, 22 Nov 2020 04:11:07 GMT</pubDate>
            <atom:updated>2020-11-22T11:03:29.174Z</atom:updated>
            <content:encoded><![CDATA[<p>Doc URL：<a href="https://flutter.dev/docs/get-started/install/macos">https://flutter.dev/docs/get-started/install/macos</a></p><h3><strong>Download Flutter SDKs</strong></h3><p>Go to flutter official site and download the package suited with your dev platform</p><h3><strong>Add flutter bin to system Path</strong></h3><pre>echo ‘export “[PATH_TO_FLUTTER_PATH_YOU_INSTALLED]/bin”’ &gt;&gt; ~/.bashrc &amp;&amp; source ~/.bashrc</pre><p>and then you can checkout</p><pre>➜  ~ flutter --version<br>Flutter 1.22.4 • channel stable • <a href="https://github.com/flutter/flutter.git">https://github.com/flutter/flutter.git</a><br>Framework • revision 1aafb3a8b9 (8 days ago) • 2020-11-13 09:59:28 -0800<br>Engine • revision 2c956a31c0<br>Tools • Dart 2.10.4</pre><h3><strong>Predownload binary dependencies</strong></h3><p>This will download some necessary binary dependencies for your development ahead your start up.</p><pre>flutter precache</pre><p>It will take millions of years to finish this process….</p><h3><strong>Checkout dependencies for start up</strong></h3><pre>flutter doctor</pre><p>Belows are some requisite for flutter development:</p><ul><li>Dart ( Integrated in flutter after version:1.19.0)</li><li>Android toolchain (SDK will automatically added after Android Stodio is installed)</li><li>Xcode</li><li>CocoaPods (dependencies management ios application, requisite if you need call native ios code)</li></ul><p>Optional IDEA:</p><ul><li>VS Code</li><li>Android Studio</li><li>Intellij IDEA</li></ul><p>If you’re in China, config a proxy</p><pre>export PUB_HOSTED_URL<strong>=</strong>https://pub.flutter-io.cn<br>export FLUTTER_STORAGE_BASE_URL<strong>=</strong>https://storage.flutter-io.cn </pre><p>more image resource, see <a href="https://flutter.cn/community/china"><strong>here</strong></a></p><h3><strong>FQA</strong></h3><ol><li>Have “ruby/config.h” not find while installing cocoaPods</li></ol><pre>fatal error: &#39;ruby/config.h&#39; file not found<br>#include &quot;ruby/config.h&quot;<br>         ^~~~~~~~~~~~~~~<br>/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header &#39;config.h&#39; in framework &#39;ruby&#39; (loaded from &#39;/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks&#39;)<br>1 error generated.</pre><p>that is because,</p><pre><strong>ruby is keg-only, which means it was not symlinked into /usr/local,<br>because macOS already provides this software and installing another version in<br>parallel can cause all kinds of trouble.</strong><br><br>If you need to have ruby first in your PATH run:<br> echo &#39;export PATH=&quot;/usr/local/opt/ruby/bin:$PATH&quot;&#39; &gt;&gt; ~/.bash_profile<br><br><strong><em>For compilers to find ruby you may need to set:<br> export LDFLAGS=&quot;-L/usr/local/opt/ruby/lib&quot;<br> export CPPFLAGS=&quot;-I/usr/local/opt/ruby/include&quot;</em></strong><strong><br></strong><br>For pkg-config to find ruby you may need to set:<br> export PKG_CONFIG_PATH=&quot;/usr/local/opt/ruby/lib/pkgconfig&quot;</pre><p>fix the issue by:</p><pre>export LDFLAGS=&quot;-L/usr/local/opt/ruby/lib&quot;<br>export CPPFLAGS=&quot;-I/usr/local/opt/ruby/include&quot;</pre><p>and then run command</p><pre>sudo gem install cocoapods</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c064a4250b6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PaaS: helm frequently used command]]></title>
            <link>https://eric-zx.medium.com/paas-helm-frequently-used-command-c174814b5ab9?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/c174814b5ab9</guid>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Sat, 07 Nov 2020 13:36:00 GMT</pubDate>
            <atom:updated>2020-11-07T13:36:00.115Z</atom:updated>
            <content:encoded><![CDATA[<h3>List all the releases on your k8s cluster</h3><blockquote>helm list</blockquote><h3>show the history of your releases</h3><blockquote>helm history [release name]</blockquote><h3>rollback to certain verison</h3><blockquote>helm rollback [revision]</blockquote><p>and the revision of each releases can be obtained from “history” command shown aboved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c174814b5ab9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang: convert []type to []interface]]></title>
            <link>https://eric-zx.medium.com/golang-convert-type-to-interface-482de13ed57c?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/482de13ed57c</guid>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 03:54:21 GMT</pubDate>
            <atom:updated>2020-10-18T03:54:21.685Z</atom:updated>
            <content:encoded><![CDATA[<p>Below snippet is not allowed in golang:</p><pre>func foo([]interface{}) { /* do something */ }<br><br>func main() {<br>    var a []string = []string{&quot;hello&quot;, &quot;world&quot;}<br>    foo(a)<br>}</pre><pre>// can&#39;t use a type []string as type[]interface</pre><p>Questing and the ans:</p><p><a href="https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces">Type converting slices of interfaces</a></p><h3>Gist</h3><p><strong>In Go, there is a general rule that syntax should not hide complex/costly operations.</strong> Converting a string to an interface{} is done in O(1) time. Converting a []string to an interface{} is also done in O(1) time since a slice is still one value. However, converting a []string to an []interface{} is O(n) time because each element of the slice must be converted to an interface{}.</p><p>The thing you are missing is that T and interface{} which holds a value of T have different representations in memory so can&#39;t be trivially converted.</p><p>A variable of type T is just its value in memory. There is no associated type information (in Go every variable has a single type known at compile time not at run time). It is represented in memory like this:</p><ul><li>value</li></ul><p>An interface{} holding a variable of type T is represented in memory like this</p><ul><li>pointer to type T</li><li>value</li></ul><blockquote>Converting []T to []interface{} would involve creating a new slice of interface {} values which is a non-trivial operation since the in-memory layout is completely different.</blockquote><h3>Main reason :</h3><p>Convert []type to []interface is a O(n) complexity operation, which needs to be operated explicityly in golang!</p><p>Read more about generics in Golang: <a href="https://blog.golang.org/generics-next-step">https://blog.golang.org/generics-next-step</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=482de13ed57c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang: package all the dependencies]]></title>
            <link>https://eric-zx.medium.com/golang-package-all-the-dependencies-824427f0a90b?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/824427f0a90b</guid>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 03:40:51 GMT</pubDate>
            <atom:updated>2020-10-18T03:40:51.152Z</atom:updated>
            <content:encoded><![CDATA[<p>If you use the go mod to manage your package, you can just use below command to package all the dependencies into vendor:</p><p>go mod vendor</p><p>and you’ll find a vendor diractory in the root of your project.</p><p>After vendered your dependencies, go mod will first check out the vendor dir by default.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=824427f0a90b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book Mark：Mao-Biography]]></title>
            <link>https://eric-zx.medium.com/book-mark-mao-biography-c1b06676d459?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1b06676d459</guid>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Thu, 15 Oct 2020 06:05:27 GMT</pubDate>
            <atom:updated>2020-10-15T06:05:27.360Z</atom:updated>
            <content:encoded><![CDATA[<p>Mao’s opinion towards peasant was deeply influenced by the experience among the Music Mountain. During that periods, he saw the power of peasants party.</p><p>And during the NP and CCP’s United Front period, Mao paid more attention on the affairs in NP, in which he is the minister of Peasants Committe.</p><p>At year 1926, Mao published an article called “Analysis” and he pointed out the peasant class had the majority contribution but also under the myriad oppression of ruling class. He appealed to the peasants to arise and fight in villages to overthrow privileges of feudal patriarchal landlord class.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1b06676d459" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang：a pitfall of JSON encoding]]></title>
            <link>https://eric-zx.medium.com/golang-a-pitfall-of-json-encoding-9088cba9c47a?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/9088cba9c47a</guid>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Wed, 14 Oct 2020 05:21:18 GMT</pubDate>
            <atom:updated>2020-10-14T05:21:18.460Z</atom:updated>
            <content:encoded><![CDATA[<p>For example we have some type like below:</p><pre>type People struct {<br>   Name string<br>   Age int32<br>   Address string<br>   vocation string<br>}<br><br><br><br>func main() {<br>   <em>//instantiate People struct<br>   </em>var people = People{<br>      Name:     &quot;Jack&quot;,<br>      Age:      23,<br>      Address:  &quot;NYC Queen Avenue 23th&quot;,<br>      vocation: &quot;Programmer&quot;,<br>   }<br>   <em>//encode insgtance to []byte<br>   </em>peopleEncode, _ := json.Marshal(people)<br><br><br>   var peopleDecode = People{}<br>   <em>//decode people<br>   </em>json.Unmarshal(peopleEncode, &amp;peopleDecode)<br>   fmt.Println(peopleDecode)<br><br>}</pre><p>After running this snippet, we will find that \`vocation\` field just disappear. It’s because that lower case in struct field is unexported field which means it’s invisible outside the package.</p><p>If we still want this field to encode as normal and keep it from exporting, we can just add some notation behind it.</p><pre>type People struct {<br>   Name string<br>   Age int32<br>   Address string<br>   vocation string `json:&quot;Vocation&quot;`<br>}</pre><p>And that’s it !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9088cba9c47a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refresh Token Based Authentication In ROR]]></title>
            <link>https://eric-zx.medium.com/refresh-token-based-authentication-in-ror-59f737815c48?source=rss-4c2e760bb8ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/59f737815c48</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[programmer]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Eric]]></dc:creator>
            <pubDate>Sun, 15 Jul 2018 10:11:39 GMT</pubDate>
            <atom:updated>2018-07-15T10:13:54.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*fz8IFPlJNXXppc92.jpg" /></figure><h3>what’s i am going on ?</h3><p>Authentication server is a very important part of your whole project , which is responses for user authorization ,role identify and so on. Now days ,token based authentication is becoming more and more prevailing with the thrilling developments of web app and SPA which may have requirements of multi device login and working with scalable RESTful back end.So …no more talking ,let’s start.</p><h3>what is token based authentication?</h3><p>At the early time of Web development , it’s a era of session cookie.To be concise , session cookie authentication is a strategy that browser store the session id of a session in the cookie and take the session cookie alongside each http/https request , then the servers can identify the user by it session id.This authentication strategy works well with conventional website.But people are always discontent, especially when we meet the amazing magic of SPA and WebApp.The conventional cookie based authentication are not convenient any more when it encounter the demands of multi device login ,user role management ,system scalability and security.</p><p>To solve those problems, we need token based authentication.In a word token based authentication is a strategy that client end communicates with the server end by a token which is encrypted by cryptographic algorithem .And a exclusive advantage of it is that we can use token based authentication to enable the third part have the access to protect resource by api.</p><p>There many method to encode your message and yield a token you can use ,but today we will use the JSON Web Token(initial: JWT) . JWT is a standard method to encode and generate a token.It consists of three part: header ,payload and verify signature.<a href="https://jwt.io/introduction/">To get more information about JWT</a>.</p><p>A complete authorize process is show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKuf-dD7kcwIE-QvgYY9sg.png" /></figure><p>Client end need to request Auth Server with account info to get validating and if success Auth Serve will response with a access token for client end.And client end need to take the token alongside its request when touch the protected resources.If the token expired or invalid, Api Server will response with an unauthorized error.</p><p>As a consequence of the stateless feature of JWT, we will encounter some problems when user change their password or logout all sign-in devices.We use algorithem to validate whether a token is valid or invalid, so if the valid token isn’t expired the validate results will always be ok no matter whether the user has logon out or changed password.This is very mortal for some monetary servers and online mall.</p><p>We have many methods to resolve that issue, but all of them are based on storing the generated token into the database ,which can not circumvent to have a database query in each request.Here we meet a dilemma , if we store token into database , this gives it state feature but will lose the performances.Oppositely ,we will lose the security of token based authentication.So how about do some compromise , we can use another token called refresh token ,which can be used to get an access token when it expired.In this way ,we can set the expired time of access token to very short such as 3 to 5 minutes and set the refresh token’s to 14days or longer.Below let’s see some brief schematic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9Bl1bN7tRlR-GdldkpSjw.png" /></figure><p>In this case, client end request the Auth Server to apply authorize , the server end will response a refresh token and access token after validating the account and password.And sequently client will use the access token to request the Api server.As we set the access token life time very short ,after its expired, server will response a unauthorized error to ask the client end to get the access token with previous refresh token.Then client request with refresh token and server verify the refresh token by querying in the database.</p><p>Though with this method ,we still need to persist the token into database ,but we decrease the database query times.To optimize this, we even can use REDIS to improve the database query performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59f737815c48" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>