<?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: Kabocha-Porter</title>
    <description>The latest articles on DEV Community by Kabocha-Porter (@zzehli).</description>
    <link>https://dev.to/zzehli</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%2F566714%2F810d1b7a-a3fa-4d0a-bac3-0e6112903c6b.png</url>
      <title>DEV Community: Kabocha-Porter</title>
      <link>https://dev.to/zzehli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zzehli"/>
    <language>en</language>
    <item>
      <title>window manager (i3wm) screen share solution</title>
      <dc:creator>Kabocha-Porter</dc:creator>
      <pubDate>Tue, 11 May 2021 04:43:39 +0000</pubDate>
      <link>https://dev.to/zzehli/window-manager-i3wm-screen-share-solution-2jm9</link>
      <guid>https://dev.to/zzehli/window-manager-i3wm-screen-share-solution-2jm9</guid>
      <description>&lt;p&gt;With a desktop manager like windows and macOS, you can choose specific windows to share. But that is not an option in windows manager like i3. There is an advanced sharing option on zoom to only share part of the screen. Currently it is not working in my linux distro. So is there a way to work around this without second screen or complicated config?&lt;/p&gt;

&lt;p&gt;Window managers usually have a notion of workspace that refers to windows groupings. You can only show the programs you need in a standalone workspace if you don't want to show your entire desktop. This is essentially equivalent to showing only one windows. In i3wm, all you need is to send the the current window to a certain workspace you are prepared to share. In i3, you can add the following command to you &lt;code&gt;config&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will allow you to send the current window to a designated workspace.&lt;/p&gt;

&lt;p&gt;However, if you have a larger monitor, font size could be a problem. If you want to share cli program, changing the terminal font is the most convenient option. Most terminal have commands for this functionality. In gui program, this should be more straight forward. &lt;/p&gt;

&lt;p&gt;So when you need to share screen, first create an empty workspace, then send the windows to the new workspace, finally adjust the font size for the audience to see more clearly. &lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>Install latex with Tinytex</title>
      <dc:creator>Kabocha-Porter</dc:creator>
      <pubDate>Mon, 10 May 2021 06:11:38 +0000</pubDate>
      <link>https://dev.to/zzehli/install-latex-with-tinytex-1a5c</link>
      <guid>https://dev.to/zzehli/install-latex-with-tinytex-1a5c</guid>
      <description>&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://yihui.org/tinytex/"&gt;Tinytex&lt;/a&gt; is a relative new Latex distribution by Yihui Xie from the R community. The distribution is tiny, less than 100mb, which is a great alternative to TexLive and MikTex for basic users. I this post, I will show how to install Tinytex as a standalone package independent of R for more general latex workflow.&lt;/p&gt;

&lt;p&gt;To install Tinytex on a Linux distribution, run the following command to download and install Tinytex, as indicated in the website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget &lt;span class="nt"&gt;-qO-&lt;/span&gt; &lt;span class="s2"&gt;"https://yihui.org/tinytex/install-bin-unix.sh"&lt;/span&gt; | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will install the application in &lt;code&gt;$HOME/.Tinytex&lt;/code&gt; and add a bunch of symlinks in &lt;code&gt;$HOME/bin&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;random ❱ ls ~/bin
afm2tfm      extractbb     kpsereadlink     mf-nowin  pktogf          updmap
bibtex       fmtutil       kpsestat         mft       pktype          updmap-sys
dvilualatex  fmtutil-sys   kpsewhich        mktexfmt  rungs           updmap-user
dviluatex    fmtutil-user  latex            mktexlsr  simpdftex       xdvipdfmx
dvipdfm      gftodvi       latexmk          mktexmf   teckit_compile  xelatex
dvipdfmx     gftopk        luahbtex         mktexpk   tex             xetex
dvipdft      gftype        lualatex         mktextfm  texhash
dvips        inimf         luaotfload-tool  pdfetex   texlua
ebb          initex        luatex           pdflatex  texluac
etex         kpseaccess    mf               pdftex    tlmgr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you can run any of the above programs in the terminal to see if they are in the PATH. If not, you need to add &lt;code&gt;$HOME/bin&lt;/code&gt; to the PATH. You can add the following line:&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="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/bin"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to one of your config file:&lt;code&gt;~/.profile&lt;/code&gt;, &lt;code&gt;~/.bashrc&lt;/code&gt;, etc. This will append &lt;code&gt;bin&lt;/code&gt; folder to your PATH permanently.&lt;/p&gt;

&lt;p&gt;Evaluate the file to update the change:&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="nb"&gt;source&lt;/span&gt; ~/.profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you should be able to run the programs in &lt;code&gt;bin&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;~ ❱ pdflatex
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded format=pdflatex)
 restricted \write18 enabled.
**^C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Test installation with pdflatex
&lt;/h3&gt;

&lt;p&gt;Now you can compile pdf from &lt;code&gt;tex&lt;/code&gt; files with &lt;code&gt;pdflatex&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can find a sample tex file from the &lt;code&gt;$HOME/.Tinytex&lt;/code&gt; folder, the original sample by Leslie Lamport that comes in every tex distribution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;.TinyTeX ❱ find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"sample2e.tex"&lt;/span&gt;
./texmf-dist/tex/latex/base/sample2e.tex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy this file to desired folder, I use folder named &lt;code&gt;random&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;.TinyTeX ❱ &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; ../
&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"sample2e.tex"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; ../random
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate to the folder that contains the &lt;code&gt;tex&lt;/code&gt; file we just copied, and run &lt;code&gt;pdflatex&lt;/code&gt;, you will enter into an interactive mode that ask for filename to convert. &lt;/p&gt;

&lt;p&gt;Enter the filename: &lt;code&gt;sample2e.tex&lt;/code&gt;, the program will compile and output a pdf file from the &lt;code&gt;tex&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;random ❱ pdflatex
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded format=pdflatex)
 restricted \write18 enabled.
**sample2e.tex
(./sample2e.tex
LaTeX2e &amp;lt;2020-10-01&amp;gt; patch level 4
L3 programming layer &amp;lt;2021-05-07&amp;gt;
(/home/zach/.TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/home/zach/.TinyTeX/texmf-dist/tex/latex/base/size10.clo))
(/home/zach/.TinyTeX/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
No file sample2e.aux.
(/home/zach/.TinyTeX/texmf-dist/tex/latex/base/omscmr.fd) [1{/home/zach/.TinyTe
X/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] [2] [3] (./sample2e.aux) ) &amp;lt;/h
ome/zach/.TinyTeX/texmf-var/fonts/pk/ljfour/jknappen/ec/tcrm1000.600pk&amp;gt;&amp;lt;/home/z
ach/.TinyTeX/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb&amp;gt;&amp;lt;/home/zach/.
TinyTeX/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb&amp;gt;&amp;lt;/home/zach/.TinyT
eX/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/te
xmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-di
st/fonts/type1/public/amsfonts/cm/cmr10.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fon
ts/type1/public/amsfonts/cm/cmr12.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/typ
e1/public/amsfonts/cm/cmr17.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/type1/pub
lic/amsfonts/cm/cmr6.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/type1/public/ams
fonts/cm/cmr7.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/type1/public/amsfonts/c
m/cmr8.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy1
0.pfb&amp;gt;&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb&amp;gt;
&amp;lt;/home/zach/.TinyTeX/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb&amp;gt;
Output written on sample2e.pdf (3 pages, 137025 bytes).
Transcript written on sample2e.log.
random ❱ ls
sample2e.aux  sample2e.log  sample2e.pdf  sample2e.tex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you should be use any editor with tex integration to run and compile latex!&lt;/p&gt;

&lt;h3&gt;
  
  
  Integrate Tinytex with R
&lt;/h3&gt;

&lt;p&gt;After set up the distribution. You can also let R use the package. To do so, you need to install &lt;code&gt;tinytex&lt;/code&gt; package in R. The package should automatically recognize your tinytex distribution. To verify, use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#is tiny tex installed
tinytex::is_tinytex()
#verify its directory
tinytex::tinytex_root()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as described &lt;a href="https://community.rstudio.com/t/integrate-standalone-installation-of-tinytex-with-r/104299/2?u=kabocha-porter"&gt;here&lt;/a&gt;. Note that &lt;code&gt;tinytex&lt;/code&gt; package does not install the latex distribution automatically. You need to run &lt;code&gt;tinytex::install_tinytex()&lt;/code&gt; if you need a fresh installation.&lt;/p&gt;

&lt;p&gt;Further steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Link tinytex to your existing package manager so that it will recognize the various packages that is included in tinytex instead of download new ones if your future packages depend on it&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>linux</category>
      <category>markdown</category>
    </item>
    <item>
      <title>Run Leetcode locally in Python and C++</title>
      <dc:creator>Kabocha-Porter</dc:creator>
      <pubDate>Mon, 25 Jan 2021 02:43:50 +0000</pubDate>
      <link>https://dev.to/zzehli/run-leetcode-locally-in-python-and-c-2jn4</link>
      <guid>https://dev.to/zzehli/run-leetcode-locally-in-python-and-c-2jn4</guid>
      <description>&lt;p&gt;Being able to run tests locally is very important. Leetcode server can be slow and the editor sub-optimal. Writing your code locally is more efficient and you can keep an archive of your test and problems for future references. &lt;/p&gt;

&lt;p&gt;To test your code locally, you need to understand the concept of class. Leetcode questions are set up in a way that your solution function is a method in the solution class. Regardless of the language you use, to call your solution method, you need to create an object of the solution class and call you solution function through that object. &lt;/p&gt;

&lt;p&gt;Here is an example in python, suppose this is a file called sol.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="c1"&gt;#your implementation
&lt;/span&gt;
&lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;longestPalindrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"abbbaccc"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can run the python in the terminal to see your solution&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python sol.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that sometimes the dependencies can be more complicated, you would need to import libraries for your code to work. Following is a c++ example, where you need to import a few libraries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;unordered_map&amp;gt;
#include &amp;lt;string&amp;gt; 
&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;lengthOfLongestSubstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;"your solution here"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="n"&gt;Solution&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lengthOfLongestSubstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"abcdcdefghcde"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lengthOfLongestSubstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lengthOfLongestSubstring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"aaaaaa"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;"out put "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the code, compile and run the file(sol.cpp) in terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;g++ sol.cpp
./a.out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>cpp</category>
      <category>python</category>
    </item>
  </channel>
</rss>
