<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jie</title>
    <description>The latest articles on DEV Community by Jie (@jma).</description>
    <link>https://dev.to/jma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F73196%2Fd5e9b974-5688-413d-865d-f5e049b00e90.png</url>
      <title>DEV Community: Jie</title>
      <link>https://dev.to/jma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jma"/>
    <language>en</language>
    <item>
      <title>Setup GPG for git on macOS</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Wed, 14 Apr 2021 07:08:09 +0000</pubDate>
      <link>https://dev.to/jma/setup-gpg-for-git-on-macos-3560</link>
      <guid>https://dev.to/jma/setup-gpg-for-git-on-macos-3560</guid>
      <description>&lt;h1&gt;
  
  
  Install gnupg and pinentry-mac
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install gnupg
brew install pinentry-mac
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Generating a GPG key
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key"&gt;Github help&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating key
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --full-generate-key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Checking the key
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --list-secret-keys --keyid-format LONG
/Users/hubot/.gnupg/secring.gpg
------------------------------------
sec   4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
uid                          Hubot 
ssb   4096R/42B317FD4BA89E7A 2016-03-10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Copying the key
&lt;/h2&gt;

&lt;p&gt;In this example, the GPG key ID is &lt;code&gt;3AA5C34371567BD2&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --armor --export 3AA5C34371567BD2 | pbcopy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Load the key for git
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vim .gnupg/gpg-agent.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;add the line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pinentry-program /usr/local/bin/pinentry-mac
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Backup and restore
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg --export-secret-keys KEY_ID &amp;gt; my-private-key.asc
gpg --import my-private-key.asc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>git</category>
      <category>gpg</category>
      <category>mac</category>
    </item>
    <item>
      <title>Multiple gitconfig</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Thu, 03 Sep 2020 06:04:01 +0000</pubDate>
      <link>https://dev.to/jma/multiple-gitconfig-409k</link>
      <guid>https://dev.to/jma/multiple-gitconfig-409k</guid>
      <description>&lt;p&gt;I need to do dev of work on my personal laptop. Usually, I will clone the repository and set a work email for that repository by &lt;code&gt;git config user.email &amp;lt;your@email.com&amp;gt;&lt;/code&gt;. That requests config for each working repositories, and if there are other settings, it requires more actions. And most important, I forget to set up it sometimes.&lt;/p&gt;

&lt;p&gt;Later,  I did search on the internet and found I am actually able to set a separated gitconfig for the specific folder. Below are the steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a separated gitconfig file
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;~/.gitconfig-work&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Add the settings you need into the file, like email/name
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git config -f ~/.gitconfig-work user.email &amp;lt;your@email.com&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we have gitconfig file for working.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set  work folder to use the new config file
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git config --global "includeIf.gitdir:~/work/.path" "~/.gitconfig-work"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then for all repositories inside of work folder, it will use the new config file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bouns
&lt;/h3&gt;

&lt;p&gt;Add &lt;code&gt;isWork&lt;/code&gt; to the new config file&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git config -f ~/.gitconfig-work core.isWork true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And run below command inside of the work folder to see if the config is applied&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git config --get core.isWork || echo false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;credit/reference: https://filipe.kiss.ink/multiple-gpg-keys-git/&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitconfig</category>
    </item>
    <item>
      <title>Panic/recover and goroutine in Golang</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Fri, 12 Jun 2020 06:56:48 +0000</pubDate>
      <link>https://dev.to/jma/panic-recover-and-goroutine-in-golang-18im</link>
      <guid>https://dev.to/jma/panic-recover-and-goroutine-in-golang-18im</guid>
      <description>&lt;p&gt;The panic recover is only alive within the current thread, that means each goroutine need it’s own panic recover&lt;/p&gt;

&lt;p&gt;The panic in this goroutine, wont be caught by the recover, it will panic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Catched panic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, playground"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WaitGroup&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You can't catch me!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wait&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To catch the panic inside of the goroutine, you need code the recover again&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Catched panic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, playground"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WaitGroup&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Now catched `%v`&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}()&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You can't catch me!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wait&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://blog.golang.org/defer-panic-and-recover"&gt;More reading&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Website: &lt;a href="https://jma.dev/?utm_source=devto"&gt;jma.dev&lt;/a&gt; &lt;br&gt;
Weekly tech bookmarks: &lt;a href="https://buttondown.email/func"&gt;funcmarks&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blog</category>
      <category>go</category>
    </item>
    <item>
      <title>nvALT revisit</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Wed, 10 Jun 2020 05:44:15 +0000</pubDate>
      <link>https://dev.to/jma/nvalt-revisit-57h3</link>
      <guid>https://dev.to/jma/nvalt-revisit-57h3</guid>
      <description>&lt;p&gt;I am looking for an app to do random text input on the macOS, and sync through my own and company's laptops. I tried Tot/Drafts, since I removed my iCloud account on the company's laptop, the only modern way is using Dropbox. &lt;/p&gt;

&lt;p&gt;Then I get back the nvALT after I found it supports backlink, but inside of the app itself, by using &lt;code&gt;[[text]]&lt;/code&gt;, you can click it to search the nvALT with &lt;code&gt;text&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gruvbox Dark Color
&lt;/h3&gt;

&lt;p&gt;Based on &lt;a href="https://github.com/morhetz/gruvbox"&gt;Gruvbox color scheme&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Font: &lt;a href="https://developer.apple.com/fonts/"&gt;SF Compact Text&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Search Highlight: &lt;code&gt;#FE8019&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Foreground Text: &lt;code&gt;#EBDBB2&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Background: &lt;code&gt;#282828&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;Website: &lt;a href="https://jma.dev/?utm_source=devto"&gt;jma.dev&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Weekly Tech bookmarks: &lt;a href="https://buttondown.email/func"&gt;funcmarks&lt;/a&gt;&lt;/p&gt;

</description>
      <category>app</category>
      <category>nvalt</category>
      <category>mac</category>
      <category>gruvbox</category>
    </item>
    <item>
      <title>Which browser for what link on macOS</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Fri, 29 May 2020 12:31:48 +0000</pubDate>
      <link>https://dev.to/jma/which-browser-for-what-link-on-macos-3c32</link>
      <guid>https://dev.to/jma/which-browser-for-what-link-on-macos-3c32</guid>
      <description>&lt;p&gt;It’s hard to split work and personal usage on the laptop at all.&lt;/p&gt;

&lt;p&gt;I would like to open work related web pages on Google Chrome, and all others go to Safari&lt;/p&gt;

&lt;p&gt;Before I have a &lt;a href="https://github.com/imjma/keyboard-maestro-macros/blob/master/Open%20in%20Chrome.kmmacros"&gt;Keyboard Maestro Marcos&lt;/a&gt;, I manually copy the address to clipboard and use hotkey to open it in the Google Chrome.&lt;/p&gt;

&lt;p&gt;However, this needs two more steps that are right-clicking or selection, and the hotkey.&lt;/p&gt;

&lt;p&gt;Then I find a few apps that can do the same with just clicking. You need to set the app as the default browser, and once you click the address, the app will help you forward to the specific app by the rule you set up.&lt;/p&gt;

&lt;p&gt;I also made a &lt;a href="https://www.icloud.com/shortcuts/8cc83908682d4d13973c47a1f38023d1"&gt;shortcuts&lt;/a&gt; on iOS that you can use share sheet or clipboard to open the address in Google Chrome iOS.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.choosyosx.com"&gt;Choosy&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The only one supports Google Chrome Profile so far. So if you have multiple profiles in Google Chrome, this is the only choice for you right now. Also, it has a similar popup browser selection like &lt;a href="https://apps.apple.com/au/app/bumpr/id1166066070?mt=12"&gt;Bumpr&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://apps.apple.com/au/app/bumpr/id1166066070?mt=12"&gt;Bumpr&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The UI is the best, especially the popup browser selection, however, once you set up the rule, you could not edit it.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://apps.apple.com/au/app/browser-opener/id1387480496?mt=12"&gt;Browser Opener&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Similar to Choosy, but not support Google Chrome Profile yet&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/johnste/finicky"&gt;Finicky&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Very recently found this open source, you need to write a config file using JavaScript rather than GUI. However, there is a page &lt;a href="https://finicky-kickstart.now.sh/"&gt;finicky kickstart&lt;/a&gt; that helps you generate a basic config file. Also, There is one feature that you can edit the urls before opening.&lt;/p&gt;

&lt;p&gt;Weekly tech bookmarks &lt;a href="https://buttondown.email/func"&gt;funcmarks&lt;/a&gt;&lt;/p&gt;

</description>
      <category>macos</category>
      <category>browser</category>
      <category>app</category>
    </item>
    <item>
      <title>Using Brewfile to automatic setup macOS from scratch</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Fri, 29 May 2020 04:00:51 +0000</pubDate>
      <link>https://dev.to/jma/using-brewfile-to-automatic-setup-macos-from-scratch-4ok1</link>
      <guid>https://dev.to/jma/using-brewfile-to-automatic-setup-macos-from-scratch-4ok1</guid>
      <description>&lt;h2&gt;
  
  
  brew bundle
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/Homebrew/homebrew-bundle"&gt;https://github.com/Homebrew/homebrew-bundle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The bundle is automatically installed once it is used.&lt;/p&gt;

&lt;h2&gt;
  
  
  dump current apps to &lt;code&gt;Brewfile&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew bundle dump
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Import from &lt;code&gt;Brewfile&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Run the cmd from the same folder of &lt;code&gt;Brewfile&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew bundle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I put it in my dotfiles. This &lt;a href="https://github.com/imjma/dotfiles/blob/master/Brewfile"&gt;one&lt;/a&gt; is mine&lt;/p&gt;

</description>
      <category>macos</category>
      <category>automation</category>
      <category>homebrew</category>
      <category>setup</category>
    </item>
    <item>
      <title>Move Hexo to Hugo</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Fri, 24 Apr 2020 06:49:35 +0000</pubDate>
      <link>https://dev.to/jma/move-hexo-to-hugo-1kam</link>
      <guid>https://dev.to/jma/move-hexo-to-hugo-1kam</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ItxB0MMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://jma.im/images/hugo-in-travisci.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ItxB0MMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://jma.im/images/hugo-in-travisci.jpg" alt="Hugo in TravisCI" width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Hugo?
&lt;/h2&gt;

&lt;p&gt;Hugo is a static site generator written in Go. It is optimized for speed, easy use and configurability. Hugo takes a directory with content and templates and renders them into a full html website. Hugo makes use of markdown files with front matter for meta data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hexo vs Hugo
&lt;/h2&gt;

&lt;p&gt;Hexo is also fast and simple, it is a static blog generator, and Hugo is more like for a site not only blog. Hexo is written in Node.js. Since I am a Golang developer now. I think it is good to move to Hugo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prepare Hugo
&lt;/h2&gt;

&lt;p&gt;Check the Hugo official page &lt;a href="https://gohugo.io/tools/migrations/"&gt;Migrate to Hugo&lt;/a&gt; before you do it by yourself.&lt;/p&gt;

&lt;p&gt;Hugo has different content structure than Hexo. &lt;/p&gt;

&lt;p&gt;First of all, remove any unrelated files like themes, submodules, hexo config file...&lt;/p&gt;

&lt;p&gt;for removing submodules from &lt;a href="https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule/36593218#36593218"&gt;https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule/36593218#36593218&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Remove the submodule entry from .git/config&lt;/span&gt;
git submodule deinit &lt;span class="nt"&gt;-f&lt;/span&gt; path/to/submodule

&lt;span class="c"&gt;# Remove the submodule directory from the superproject's .git/modules directory&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; .git/modules/path/to/submodule

&lt;span class="c"&gt;# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule&lt;/span&gt;
git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; path/to/submodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, Install Hugo and run &lt;code&gt;hugo new site --force&lt;/code&gt; in the current folder, it will generate the mandatory files for the site. &lt;/p&gt;

&lt;p&gt;Add theme you like and do configuration.&lt;/p&gt;

&lt;p&gt;Move all posts to the new content folder, I put mine into the &lt;code&gt;content/posts&lt;/code&gt;. Update the front matter of the posts to avoid compile error in the Hugo.&lt;/p&gt;

&lt;p&gt;That’s almost done, it is easy because I moved my site from Jekyll to Hexo, then to Hugo, they all use markdown files and front matter for the post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous Delivery (CD)
&lt;/h2&gt;

&lt;p&gt;I switched from Github to Firebase hosting after I moved from Jekyll to Hexo. Firebase hosting will give you a free SSL. &lt;/p&gt;

&lt;h3&gt;
  
  
  TravisCI
&lt;/h3&gt;

&lt;p&gt;I use &lt;a href="https://travis-ci.com"&gt;Travis CI&lt;/a&gt; to build pages and deploy to Firebase hosting. You can check mine &lt;a href="https://github.com/imjma/blog/blob/master/.travis.yml"&gt;&lt;code&gt;.travis.yml&lt;/code&gt; &lt;/a&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Firebase hosting
&lt;/h3&gt;

&lt;p&gt;You need a token to deploy to Firebase hosting from ci, following the doc &lt;a href="https://firebase.google.com/docs/cli#cli-ci-systems"&gt;Firebase CLI reference&lt;/a&gt;. Then Add the token to &lt;a href="https://travis-ci.com"&gt;Travis CI&lt;/a&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  Last
&lt;/h2&gt;

&lt;p&gt;So now, once TravisCI detects your master branch of repository has been changed, it will trigger the build in TravisCI, and build the static site and publish to firebase hosting.&lt;/p&gt;

</description>
      <category>blog</category>
      <category>firebase</category>
      <category>hugo</category>
    </item>
    <item>
      <title>Poker StraightFlush</title>
      <dc:creator>Jie</dc:creator>
      <pubDate>Fri, 01 Sep 2017 14:51:22 +0000</pubDate>
      <link>https://dev.to/jma/poker-straightflush-1jan</link>
      <guid>https://dev.to/jma/poker-straightflush-1jan</guid>
      <description>&lt;p&gt;First of all, PHP Code Example. (PHP ≥ 7)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function isStriaghtFlush($d) {
    $b = $f = 0;
    $m = ['a'=&amp;gt;1,1=&amp;gt;10,'j'=&amp;gt;11,'q'=&amp;gt;12,'k'=&amp;gt;13];
    foreach ($d as $a) {
        $p = substr($a,-1);
        $b |= 1&amp;lt;&amp;lt;(($m[$a[0]])??$a[0]);
        $f = ($f===0||$f===$p) ? $p : 1;
    }
    $b = ($b &amp;lt;&amp;lt; 3) | ($b &amp;gt;&amp;gt; 10);
    foreach (range(0,13) as $i) {
        if ((($b &amp;gt;&amp;gt; $i) &amp;amp; 31) == 31){
            return [true, $f!=1];
        }
    }
    return [false, false];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explain:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;A&lt;/code&gt; can be straight of &lt;code&gt;A, 2, 3, 4, 5&lt;/code&gt; and &lt;code&gt;10, J, Q, K A&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;There are total 14 ranks, when getting rank &lt;code&gt;n&lt;/code&gt; from the &lt;code&gt;$d&lt;/code&gt;, we set 1 of the &lt;code&gt;n&lt;/code&gt; element in bitwise map.&lt;/p&gt;

&lt;p&gt;If we could find any 5 continuously 1 in the bitwise map, then it’s straight. also if all faces are same, then it’s straight flush.&lt;/p&gt;

&lt;p&gt;Example, cards: &lt;code&gt;10, J, Q, K, A&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;read &lt;code&gt;10&lt;/code&gt;, bitwise map: &lt;code&gt;0,0,0,1,0,0,0,0,0,0,0,0,0,0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;read &lt;code&gt;J&lt;/code&gt;, bitwise map: &lt;code&gt;0,0,1,1,0,0,0,0,0,0,0,0,0,0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;read &lt;code&gt;Q&lt;/code&gt;, bitwise map: &lt;code&gt;0,1,1,1,0,0,0,0,0,0,0,0,0,0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;read &lt;code&gt;K&lt;/code&gt;, bitwise map: &lt;code&gt;1,1,1,1,0,0,0,0,0,0,0,0,0,0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;read &lt;code&gt;A&lt;/code&gt;, bitwise map: &lt;code&gt;1,1,1,1,0,0,0,0,0,0,0,0,1,0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;shift left 3 of bitwise map to &lt;code&gt;1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;shift right 10 of bitwise map to &lt;code&gt;1,1,1,1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OR this two bitwise maps and get a new map &lt;code&gt;1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then we have 5 continuously 1, it’s straight.&lt;/p&gt;

</description>
      <category>dev</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
