<?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"><channel><title><![CDATA[Levene's blog]]></title><description><![CDATA[Levene's blog]]></description><link>https://levene.me</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 22:44:52 GMT</lastBuildDate><atom:link href="https://levene.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Streamline Presentation Creation with Markdown and Insou]]></title><description><![CDATA[Creating compelling presentations can be a time-consuming ordeal. Traditional methods can eat up more than 10 hours, with over half of that time spent wrestling with styling and formatting issues. What's worse, these style-related challenges often le...]]></description><link>https://levene.me/streamline-presentation-creation-with-markdown-and-insou</link><guid isPermaLink="true">https://levene.me/streamline-presentation-creation-with-markdown-and-insou</guid><category><![CDATA[markdown]]></category><category><![CDATA[presentations]]></category><category><![CDATA[ppt]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Thu, 28 Sep 2023 09:15:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/V5vqWC9gyEU/upload/73950cf7db453a07585a3f616b4a6a76.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Creating compelling presentations can be a time-consuming ordeal. Traditional methods can eat up more than 10 hours, with over half of that time spent wrestling with styling and formatting issues. What's worse, these style-related challenges often lead to distractions while writing content, resulting in highly inefficient workflows.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695892460235/ee54017b-9932-4bc9-a1e0-950610b80b73.png" alt class="image--center mx-auto" /></p>
<p><strong>The Predicament of Traditional Presentation Design</strong></p>
<p>Traditional presentation design tempts us with endless customization options, promising visually stunning slides. However, it often comes at the expense of productivity and content quality. Valuable hours spent on design could be better invested in refining your message, conducting research, or practicing your presentation.</p>
<p>Moreover, style-related distractions can draw your attention away from content creation. Your audience may become so captivated by slide transitions or color choices that they miss your presentation's core message.</p>
<p><strong>Markdown and Insou: A Game-Changing Solution</strong></p>
<p>Imagine a solution where you can write presentations just as you write documents, focusing solely on content, not style. The quality of a presentation should be determined by its content, not its styling. This is where Markdown and Insou come into play.</p>
<p><strong>The Power of Markdown</strong></p>
<ol>
<li><p><strong>Efficiency:</strong> Markdown streamlines formatting, allowing you to write naturally while automatically applying consistent styling.</p>
</li>
<li><p><strong>Consistency:</strong> Markdown enforces a unified style throughout your presentation, eliminating the need for manual adjustments on each slide.</p>
</li>
<li><p><strong>Content-Centric Approach:</strong> With Markdown, you can invest your energy in crafting a compelling narrative supported by data and visuals.</p>
</li>
</ol>
<p><strong>The Magic of Insou</strong></p>
<ol>
<li><p><strong>Seamless Conversion:</strong> Insou effortlessly transforms your Markdown content into a visually appealing PowerPoint presentation, saving you time and ensuring a polished final product.</p>
</li>
<li><p><strong>Focus on Substance:</strong> With styling handled by Insou, you can dedicate your full attention to developing content that engages and informs your audience.</p>
</li>
</ol>
<p>By embracing Markdown and Insou for presentations, you can shift your focus from the distractions of style to the essence of your message. Your presentations will become more effective, efficient, and engaging, allowing you to make the most of your valuable time.</p>
<p>In conclusion, the challenge of spending excessive time on styling and its adverse impact on content creation is a universal struggle. Markdown and Insou offer a transformative solution by promoting content-centric presentation creation. It's a game-changing approach that allows you to reclaim your time, captivate your audience, and deliver more impactful presentations.</p>
<p>Embrace the future of presentation creation with Markdown and Insou, where content is king, and style is a breeze.</p>
]]></content:encoded></item><item><title><![CDATA[Greatness Inspired by Dreams 😃]]></title><description><![CDATA[In the realm of human endeavors, greatness finds its roots in the soil of dreams. Dreams are the sparks that ignite the fires of determination, resilience, and achievement. They are the cornerstone upon which individuals build their paths to greatnes...]]></description><link>https://levene.me/greatness-inspired-by-dreams</link><guid isPermaLink="true">https://levene.me/greatness-inspired-by-dreams</guid><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Mon, 14 Aug 2023 18:12:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/JrZ1yE1PjQ0/upload/ce86da22264946cf51e80f12df0d5e26.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the realm of human endeavors, greatness finds its roots in the soil of dreams. Dreams are the sparks that ignite the fires of determination, resilience, and achievement. They are the cornerstone upon which individuals build their paths to greatness.</p>
<p>Dreams, those shimmering stars in our imagination, guide us towards uncharted territories. They fuel our passion, urging us to push boundaries and overcome challenges. With each step, we inch closer to turning dreams into reality, etching our names in the annals of history.</p>
<p>But the journey is not without its share of obstacles. The pursuit of greatness demands unwavering commitment. It's a roller-coaster of emotions, ranging from triumph to setback. Yet, these highs and lows are the brushstrokes that paint the portrait of a true achiever. The ability to weather storms and emerge stronger is what sets apart the ordinary from the extraordinary.</p>
<p>The smiley face of determination is a universal symbol. It's a reflection of the spirit that propels dreamers forward. Just like a smile can brighten the darkest of days, a resolute mindset can turn challenges into stepping stones. 💪</p>
<p>Remember, every great accomplishment began as an audacious dream. Think of the Wright brothers, who dared to dream of flying, or Martin Luther King Jr., who envisioned a world free from discrimination. These icons embraced their dreams with open arms, nurturing them with unwavering faith until they became reality.</p>
<p>So, let your dreams be the wind beneath your wings. Embrace challenges, wear setbacks as badges of honor, and always keep that determined smile on your face. For it's through the pursuit of dreams that humanity continues to achieve greatness and leave an indelible mark on the canvas of history. ✨🌟</p>
]]></content:encoded></item><item><title><![CDATA[Google Search Impact]]></title><description><![CDATA[Hhhh, although a little less, but still very happy]]></description><link>https://levene.me/google-search-impact</link><guid isPermaLink="true">https://levene.me/google-search-impact</guid><category><![CDATA[Build In Public]]></category><category><![CDATA[Startups]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Mon, 14 Aug 2023 18:08:45 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1692036442065/2d71b251-91ff-4f65-848c-5142673931ce.png" alt class="image--center mx-auto" /></p>
<p>Hhhh, although a little less, but still very happy</p>
]]></content:encoded></item><item><title><![CDATA[Fix Your Startup Only When It's Broken 🛠️]]></title><description><![CDATA[Starting a business can be a bumpy ride. You might feel the urge to fix every little problem that arises, but it's important to resist the temptation. Focus on what matters most, and fix only what's broken. 🚫👨‍🔧
Here are some tips to avoid early-s...]]></description><link>https://levene.me/fix-your-startup-only-when-its-broken</link><guid isPermaLink="true">https://levene.me/fix-your-startup-only-when-its-broken</guid><category><![CDATA[work]]></category><category><![CDATA[Startups]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Fri, 28 Apr 2023 06:46:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/s76lpjVp4XY/upload/f299f1d9741b3719c335194aeba7c19f.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Starting a business can be a bumpy ride. You might feel the urge to fix every little problem that arises, but it's important to resist the temptation. Focus on what matters most, and fix only what's broken. 🚫👨‍🔧</p>
<p>Here are some tips to avoid early-stage optimization and maximize your startup's success:</p>
<h2 id="heading-build-your-dashboard-early">Build Your Dashboard Early 📊</h2>
<p>It's important to know what's going on in your business. 🕵️‍♀️ By building a dashboard early on, you can track your key performance indicators and make informed decisions based on data. 📈</p>
<h2 id="heading-ab-testing-is-a-trap"><strong>AB Testing is a Trap 🕳️</strong></h2>
<p>Don't waste time on excessive AB testing in the early stages. 🙅‍♂️ It's easy to get caught up in perfecting every little detail, but remember: the goal is to move fast and iterate quickly. 🚀 Focus on the big picture and address major issues as they arise. 🎯</p>
<p>Remember, it's okay to let your startup be a little rough around the edges. Only fix what's broken, and don't waste time on early-stage optimization. 🛠️👌</p>
]]></content:encoded></item><item><title><![CDATA[How to Start Your First Task of the Day?]]></title><link>https://levene.me/how-to-start-your-first-task-of-the-day-1</link><guid isPermaLink="true">https://levene.me/how-to-start-your-first-task-of-the-day-1</guid><category><![CDATA[AI]]></category><category><![CDATA[todoapp]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[#levene]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Wed, 19 Apr 2023 06:29:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1681885668806/a46cdd05-a6a8-4cc3-b10b-77f0e16929a5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681885639713/d5a6f70f-ed25-4235-9ee7-d1baced14518.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[How to Start Your First Task of the Day]]></title><description><![CDATA[The "first task of the day" is crucial to our work efficiency. Selecting a task that is not too difficult but easy to complete quickly can create positive motivation and pave the way for the rest of the day's work.
It is recommended to choose a simpl...]]></description><link>https://levene.me/how-to-start-your-first-task-of-the-day</link><guid isPermaLink="true">https://levene.me/how-to-start-your-first-task-of-the-day</guid><category><![CDATA[work]]></category><category><![CDATA[personal]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Mon, 10 Apr 2023 08:15:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1681114144095/fc58e9fb-615f-407c-b06f-4cc34e255de9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The "first task of the day" is crucial to our work efficiency. Selecting a task that is not too difficult but easy to complete quickly can create positive motivation and pave the way for the rest of the day's work.</p>
<p>It is recommended to choose a simple task to be completed first that meets the following three characteristics:</p>
<ul>
<li><p>Not too difficult but easy to complete.</p>
</li>
<li><p>Can quickly generate the first positive motivation.</p>
</li>
<li><p>Can pave the way for the rest of the day's work.</p>
</li>
</ul>
<p>Take your time to carefully select your first task and give the whole process a sense of ritual. When you arrive at the office in the morning, drink a glass of water and start your day's work.</p>
<p>First, check your To-Do List, select your "starting item" carefully, and complete it within 10 minutes to create a positive feedback loop that uplifts your mood. Then confidently tackle more complex tasks.</p>
<p>Imagine starting your day in a state of confusion and feeling unable to tackle complex tasks. This rhythm can make you more efficient and relaxed.</p>
<p>This way, you can create a positive mindset before starting your day, making it easier to focus, handle work pressure, and achieve job satisfaction and a sense of accomplishment. Remember that the first task of the day may not be your most important task, but it is the key to quickly getting into work mode and building confidence.</p>
<p>In addition, you can consider doing some preparatory work before your first task, such as drinking coffee, doing some stretching exercises, or reading a few interesting articles. These simple actions can help you get into work mode more quickly and improve your attention and focus.</p>
<p>However, choosing a "one-and-done" task is not the best option. Although you may get positive motivation, it's possible that you'll fall into a relaxed mood and choose to take another break, wasting valuable time. Therefore, it's important to carefully choose this task and make sure it is related to other tasks of the day.</p>
<p>Finally, don't forget to set specific goals for yourself every day and review and summarize your work after completing each task. This can help you better understand your work habits and efficiency and gradually improve your work performance.</p>
<p>In summary, although the first task of the day may seem insignificant, it can lay a solid foundation for your entire workday. Choose an easy-to-complete but related task to other tasks of the day.</p>
]]></content:encoded></item><item><title><![CDATA[Go Build (1)]]></title><description><![CDATA[As a developer who mainly uses Golang for development, I would like to write an article to introduce the usage of the go build command and its most commonly used scenarios, as well as provide an example.
Introduction to go build
The go build command ...]]></description><link>https://levene.me/go-build-1</link><guid isPermaLink="true">https://levene.me/go-build-1</guid><category><![CDATA[golang]]></category><category><![CDATA[Go Language]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Tue, 14 Mar 2023 06:50:02 GMT</pubDate><content:encoded><![CDATA[<p>As a developer who mainly uses Golang for development, I would like to write an article to introduce the usage of the <code>go build</code> command and its most commonly used scenarios, as well as provide an example.</p>
<p>Introduction to <code>go build</code></p>
<p>The <code>go build</code> command is a tool that compiles packages and dependencies into an executable file. It's one of the most commonly used commands in the Golang development process.</p>
<p>Usage of <code>go build</code></p>
<p>To use <code>go build</code>, simply navigate to the directory containing the main package file and run the following command:</p>
<pre><code class="lang-go"><span class="hljs-keyword">go</span> build
</code></pre>
<p>This will compile the package and generate an executable file with the same name as the directory containing the main package file.</p>
<p>For example, if the main package file is located in the directory <code>myproject</code>, running <code>go build</code> will create an executable file named <code>myproject</code>.</p>
<p>If you want to specify a different name for the executable file, you can use the <code>-o</code> flag followed by the desired name. For example:</p>
<pre><code class="lang-go"><span class="hljs-keyword">go</span> build -o myexecutable
</code></pre>
<p>This will create an executable file named <code>myexecutable</code>.</p>
<p>If you want to build a specific package or file, you can specify the package or file name after the <code>go build</code> command. For example:</p>
<pre><code class="lang-go"><span class="hljs-keyword">go</span> build mypackage
</code></pre>
<p>This will build the <code>mypackage</code> package.</p>
<p>Commonly used scenarios</p>
<ol>
<li>Building the main package</li>
</ol>
<p>The most common use case for <code>go build</code> is building the main package file. This is done by navigating to the directory containing the main package file and running <code>go build</code>.</p>
<p>For example:</p>
<pre><code class="lang-go">cd myproject
<span class="hljs-keyword">go</span> build
</code></pre>
<p>This will compile the main package file and generate an executable file named <code>myproject</code>.</p>
<ol>
<li>Building a specific package</li>
</ol>
<p>Sometimes, you may only need to build a specific package instead of the entire project. To do this, simply specify the package name after the <code>go build</code> command.</p>
<p>For example:</p>
<pre><code class="lang-go"><span class="hljs-keyword">go</span> build mypackage
</code></pre>
<p>This will compile the <code>mypackage</code> package.</p>
<ol>
<li>Building with specific flags</li>
</ol>
<p>You can also use <code>go build</code> with specific flags to enable or disable certain features during compilation. For example, to build with race detection enabled, you can use the <code>-race</code> flag.</p>
<pre><code class="lang-go"><span class="hljs-keyword">go</span> build -race
</code></pre>
<p>This will enable race detection during compilation.</p>
<p>Example</p>
<p>Let's say we have a simple project with two packages: <code>main</code> and <code>mypackage</code>. The <code>main</code> package imports the <code>mypackage</code> package.</p>
<pre><code class="lang-go">myproject/
  main.<span class="hljs-keyword">go</span>
  mypackage/
    mypackage.<span class="hljs-keyword">go</span>
</code></pre>
<p>Here's what the <code>main.go</code> file looks like:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">"mypackage"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    mypackage.MyFunction()
}
</code></pre>
<p>And here's what the <code>mypackage.go</code> file looks like:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> mypackage

<span class="hljs-keyword">import</span> <span class="hljs-string">"fmt"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">MyFunction</span><span class="hljs-params">()</span></span> {
    fmt.Println(<span class="hljs-string">"Hello, world!"</span>)
}
</code></pre>
<p>To build the entire project, we simply navigate to the <code>myproject</code> directory and run <code>go build</code>.</p>
<pre><code class="lang-go">cd myproject
<span class="hljs-keyword">go</span> build
</code></pre>
<p>This will compile only the <code>mypackage</code> package.</p>
<p>Conclusion</p>
<p>The <code>go build</code> command is a versatile tool that is essential for Golang development. It allows you to compile packages and dependencies into an executable file, as well as specify specific flags and build specific packages. By understanding its usage and scenarios, you can streamline your development</p>
]]></content:encoded></item><item><title><![CDATA[Boost Your Golang Development with These Top VSCode Extensions]]></title><description><![CDATA[As a developer using Golang as the primary language, it's important to have the right tools to streamline your workflow. One of the most popular code editors for Golang is Visual Studio Code (VSCode), which provides a variety of extensions to help yo...]]></description><link>https://levene.me/boost-your-golang-development-with-these-top-vscode-extensions</link><guid isPermaLink="true">https://levene.me/boost-your-golang-development-with-these-top-vscode-extensions</guid><category><![CDATA[Go Language]]></category><category><![CDATA[golang]]></category><category><![CDATA[vscode extensions]]></category><category><![CDATA[vscode]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Tue, 14 Mar 2023 03:44:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678765411724/a0e771d3-9db6-4272-928c-35722ed35b68.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As a developer using Golang as the primary language, it's important to have the right tools to streamline your workflow. One of the most popular code editors for Golang is Visual Studio Code (VSCode), which provides a variety of extensions to help you develop Golang applications more efficiently.</p>
<p>In this article, we'll introduce some of the most commonly used Golang extensions for VSCode, along with examples of how to use them.</p>
<h2 id="heading-go">Go</h2>
<p>The first and most essential extension for Golang development in VSCode is the official Go extension by Microsoft. This extension provides a range of features, including syntax highlighting, code completion, and debugging support.</p>
<p>To install this extension, go to the Extensions tab in VSCode and search for "Go". Once installed, you can start using the extension right away.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678764879727/6fdc3417-052e-45cf-acfe-16f790630a09.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-go-test-explorer">Go Test Explorer</h2>
<p>The Go Test Explorer extension provides an interface for running and debugging Golang tests within VSCode. It displays test results in a hierarchical tree view, making it easy to navigate and view test results.</p>
<p>To install this extension, search for "Go Test Explorer" in the Extensions tab in VSCode. Once installed, you can start using the extension to run tests and view test results.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678764929101/48aa0ac7-db4d-43e9-a833-5cc271d17a00.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-go-auto-struct-tag"><strong>Go Auto Struct Tag</strong></h2>
<p>A Visual Studio Code extension for auto complete the go struct tag when typing. This project is the modified version of <a target="_blank" href="https://github.com/guyanyijiu/go-struct-tag">go-struct-tag by guyanyijiu</a></p>
<p>P.S: I modified this extension to suits my needs so I do not own most of the code,<br />You can visit the original version here <a target="_blank" href="https://github.com/guyanyijiu/go-struct-tag">go-struct-tag by guyanyijiu</a><br />I am open to new ideas, just create an issue or pull requests, Thank You!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678765298031/eaf26098-8d83-42d2-87f2-421c9c2ee429.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-go-outliner">Go Outliner</h1>
<p>Go Outliner adds activity bar icon for code outline (Go projects only) to VS Code. It's also possible to extend main Explorer tab with sub-section by switching (<code>goOutliner.extendExplorerTab</code>) setting option to <code>true</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678765069892/0273a6b4-b26a-4959-b484-7df1ca30fd7c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-godoc">GoDoc</h2>
<p>The GoDoc extension provides a quick and easy way to access documentation for Golang packages and functions. It integrates with VSCode to provide inline documentation as you write code.</p>
<p>To install this extension, search for "GoDoc" in the Extensions tab in VSCode. Once installed, you can start using the extension to access Golang documentation.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678764917095/ed51ff7a-88f5-46da-8817-0d6f8577062a.png" alt class="image--center mx-auto" /></p>
<p>These are just a few examples of the many Golang extensions available for VSCode. By using these extensions, you can significantly improve your Golang development workflow and produce higher quality code.</p>
]]></content:encoded></item><item><title><![CDATA[Start  Golang]]></title><description><![CDATA[Go is an open source programming language developed by Google and designed as a fast, efficient and reliable language. It combines the advantages of languages such as C and Python, making it a very popular programming language.
In this article, we wi...]]></description><link>https://levene.me/start-golang</link><guid isPermaLink="true">https://levene.me/start-golang</guid><category><![CDATA[Go Language]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Tue, 14 Mar 2023 03:29:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/fd9mIBluHkA/upload/46dfbb5885f82532b6a4d37fc74873f4.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Go is an open source programming language developed by Google and designed as a fast, efficient and reliable language. It combines the advantages of languages such as C and Python, making it a very popular programming language.</p>
<p>In this article, we will introduce the basics of the Go programming language.</p>
<h2 id="heading-install-go">Install Go</h2>
<p>Before you start writing Go code, you need to install the Go programming language on your computer. You can download the installer for your operating system from the official website (<a target="_blank" href="https://golang.org/dl/">https://golang.org/dl/</a>). Just follow the instructions of the installer.</p>
<h2 id="heading-write-hello-world-programs">Write Hello World programs</h2>
<p>Let's start with the Hello World program. Open your text editor and enter the following:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">"fmt"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    fmt.Println(<span class="hljs-string">"Hello, World!"</span>)
}
</code></pre>
<p>Save the file and name it hello.go. In the terminal window, change to the directory that contains the file and run the following command:</p>
<pre><code class="lang-go"><span class="hljs-keyword">go</span> run hello.<span class="hljs-keyword">go</span>
</code></pre>
<p>The output should be:</p>
<pre><code class="lang-go">Hello, World!
</code></pre>
<h2 id="heading-variables-and-data-types">Variables and data types</h2>
<p>Variable is one of the most basic building blocks in Go programs. A variable is an identifier used to store a value. In Go, variables must be declared before they can be used. The syntax for declaring variables is as follows:</p>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> variable_name data_type
</code></pre>
<p>Here are some common data types:</p>
<ul>
<li><p>Bool: Boolean, true or false</p>
</li>
<li><p>String: string, such as "hello world"</p>
</li>
<li><p>int: integer, such as 42</p>
</li>
<li><p>Float64: floating-point number, such as 3.14</p>
<p>  The following is a sample program that demonstrates how to declare and use variables:</p>
</li>
</ul>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">"fmt"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    <span class="hljs-keyword">var</span> age <span class="hljs-keyword">int</span> = <span class="hljs-number">28</span>
    <span class="hljs-keyword">var</span> name <span class="hljs-keyword">string</span> = <span class="hljs-string">"Alice"</span>
    <span class="hljs-keyword">var</span> isStudent <span class="hljs-keyword">bool</span> = <span class="hljs-literal">true</span>
    <span class="hljs-keyword">var</span> height <span class="hljs-keyword">float64</span> = <span class="hljs-number">1.65</span>

    fmt.Println(name, <span class="hljs-string">"is"</span>, age, <span class="hljs-string">"years old,"</span>, height, <span class="hljs-string">"meters tall, and is a student:"</span>, isStudent)
}
</code></pre>
<pre><code class="lang-go">Alice is <span class="hljs-number">28</span> years old, <span class="hljs-number">1.65</span> meters tall, and is a student: <span class="hljs-literal">true</span>
</code></pre>
<h2 id="heading-control-flow">Control flow</h2>
<p>When writing a program, control flow statements allow us to execute different blocks of code according to specific conditions. Here are some commonly used control flow statements:</p>
<ul>
<li><p>If/else statement: allows us to execute different blocks of code based on a condition.</p>
</li>
<li><p>for loop: allows us to execute the code block repeatedly until the specified condition is reached.</p>
</li>
<li><p>switch statement: allows us to execute different blocks of code according to different conditions.</p>
<p>  The following is a sample program that demonstrates how to use the f / else statement and for loop:</p>
</li>
</ul>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">"fmt"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    age := <span class="hljs-number">28</span>

    <span class="hljs-keyword">if</span> age &gt;= <span class="hljs-number">18</span> {
        fmt.Println(<span class="hljs-string">"You are an adult"</span>)
    } <span class="hljs-keyword">else</span> {
        fmt.Println(<span class="hljs-string">"You are a child"</span>)
    }

    <span class="hljs-keyword">for</span> i := <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">10</span>; i++ {
        fmt.Println(i)
    }    
}
</code></pre>
<pre><code class="lang-go">You are an adult
<span class="hljs-number">1</span>
<span class="hljs-number">2</span>
<span class="hljs-number">3</span>
<span class="hljs-number">4</span>
<span class="hljs-number">5</span>
<span class="hljs-number">6</span>
<span class="hljs-number">7</span>
<span class="hljs-number">8</span>
<span class="hljs-number">9</span>
<span class="hljs-number">10</span>
</code></pre>
<h2 id="heading-function-in-go">Function In Go</h2>
<p>a function is a reusable block of code that takes some input parameters and returns a result. The following is a sample program that demonstrates how to declare and call a function:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">"fmt"</span>

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">add</span><span class="hljs-params">(a <span class="hljs-keyword">int</span>, b <span class="hljs-keyword">int</span>)</span> <span class="hljs-title">int</span></span> {
    <span class="hljs-keyword">return</span> a + b
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    sum := add(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
    fmt.Println(sum)
}
</code></pre>
<pre><code class="lang-go"><span class="hljs-number">5</span>
</code></pre>
<h2 id="heading-structure">Structure</h2>
<p>A structure is a custom data type that can store different types of data. The following is a sample program that demonstrates how to declare and use structures:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">"fmt"</span>

<span class="hljs-keyword">type</span> Person <span class="hljs-keyword">struct</span> {
    name <span class="hljs-keyword">string</span>
    age  <span class="hljs-keyword">int</span>
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    person := Person{name: <span class="hljs-string">"Alice"</span>, age: <span class="hljs-number">28</span>}
    fmt.Println(person.name, <span class="hljs-string">"is"</span>, person.age, <span class="hljs-string">"years old"</span>)
}
</code></pre>
<pre><code class="lang-go">Alice is <span class="hljs-number">28</span> years old
</code></pre>
<h2 id="heading-package">Package</h2>
<p>packages are a way to organize related code. Every Go program must have a package called main, which is the entry point of the program. In addition, you can create your own packages and use them in other programs. The following is a sample program that demonstrates how to create and use packages:</p>
<p>Under the mathutils directory, create a file called add.go that contains the following:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> mathutils

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">Add</span><span class="hljs-params">(a <span class="hljs-keyword">int</span>, b <span class="hljs-keyword">int</span>)</span> <span class="hljs-title">int</span></span> {
    <span class="hljs-keyword">return</span> a + b
}
</code></pre>
<p>In 'main. In the go °file, import the ^ mathutils package and call the functions in it:</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> (
    <span class="hljs-string">"fmt"</span>
    <span class="hljs-string">"mathutils"</span>
)

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
    sum := mathutils.Add(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
    fmt.Println(sum)
}
</code></pre>
<pre><code class="lang-go"><span class="hljs-number">5</span>
</code></pre>
<p>The above is a short introductory tutorial on the Go programming language. If you want to learn more about the Go programming language, check out the official Go documentation (https:l/golang). Orglclocl).</p>
]]></content:encoded></item><item><title><![CDATA[mercury declined my application]]></title><description><![CDATA[This is sad 😥
needs to be tried in other ways.]]></description><link>https://levene.me/mercury-declined-my-application</link><guid isPermaLink="true">https://levene.me/mercury-declined-my-application</guid><category><![CDATA[Startups]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Wed, 08 Mar 2023 03:45:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678247064659/17efa40d-93b8-47be-83f3-55dee57ef72a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678246735074/1f25e761-11b4-4cda-a880-c11a250ebaf0.png" alt class="image--center mx-auto" /></p>
<p>This is sad 😥</p>
<p>needs to be tried in other ways.</p>
]]></content:encoded></item><item><title><![CDATA[What do you think of chatGPT's article?]]></title><description><![CDATA[ChatGPT wrote a promotional article for weedone (https://www.weedone.app) helped me write a promotional article. How would you evaluate this article?

Jack was a marketing manager at a large corporation, and his job required him to juggle multiple pr...]]></description><link>https://levene.me/what-do-you-think-of-chatgpts-article</link><guid isPermaLink="true">https://levene.me/what-do-you-think-of-chatgpts-article</guid><category><![CDATA[chatgpt]]></category><category><![CDATA[Startups]]></category><category><![CDATA[marketing]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Wed, 08 Mar 2023 03:11:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678245039386/b26144a7-2e4e-4df7-803b-250a0e881e4b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>ChatGPT wrote a promotional article for weedone (<a target="_blank" href="https://www.weedone.app">https://www.weedone.app</a>) helped me write a promotional article. How would you evaluate this article?</p>
<hr />
<p>Jack was a marketing manager at a large corporation, and his job required him to juggle multiple projects simultaneously. He was always busy with meetings, emails, and phone calls, and his to-do list seemed to get longer and longer each day.</p>
<p>Jack had a habit of working long hours, often staying at the office until late at night just to try and get everything done. He felt like he was always playing catch-up, and he never had time to focus on the big picture.</p>
<p>The stress of his job started to take a toll on Jack's health. He was constantly tired and irritable, and he had trouble sleeping at night. He started to feel like he was stuck in a never-ending cycle of work, and he couldn't see a way out.</p>
<p>Jack knew that he needed to make a change, but he didn't know where to start. He had tried various productivity methods and tools, but none of them had helped him to manage his workload effectively. He felt like he was drowning in a sea of tasks, and he couldn't see a way to stay afloat.</p>
<p>That's when Jack stumbled upon Weedone. He was intrigued by its simple, week-based approach to task management, and he decided to give it a try.</p>
<p>To his surprise, it worked. Weedone was different. It helped him to prioritize his tasks and focus on what really mattered. He no longer felt overwhelmed by his to-do list, and he was able to achieve more with less effort and stress.</p>
<p>With the extra time that Weedone gave him, Jack started to focus on his personal life. He began going to the gym regularly and taking up hobbies that he had always wanted to try. He found himself with more free time than he had ever had before.</p>
<p>Then, one day, Jack's boss called him into his office. Jack was nervous, wondering if he had done something wrong. But his boss had nothing but good news for him.</p>
<p>"Jack, your productivity has increased significantly," his boss said. "We've decided to promote you to a higher position."</p>
<p>Jack was shocked. He had never expected to be promoted, and he knew that he couldn't have achieved this without the help of Weedone.</p>
<p>From that day forward, Jack continued to use Weedone to stay focused and productive. He recommended it to his colleagues, who soon saw the benefits for themselves.</p>
<p>With Weedone, Jack was able to break free from the cycle of stress and overwhelm. He started to see a way forward, and he felt like he had more control over his life. It was a turning point for him, and he knew that he would never go back to his old ways again.</p>
<p>Weedone helped Jack to see the big picture and prioritize his tasks based on what was really important. He was able to focus on the most critical projects and delegate some of the less important ones to his team. This gave him the breathing room he needed to start taking care of himself, both mentally and physically.</p>
<p>Jack was able to become the master of his time. He was no longer overwhelmed by his to-do list, and he was able to achieve more with less effort and stress. He realized that sometimes, doing less can actually lead to achieving more.</p>
]]></content:encoded></item><item><title><![CDATA[Counting Service]]></title><description><![CDATA[Counting service is a really fundamental service that has a lot of counting needs in business, such as likes, favorites, etc. It requires stable counting, meets long-term planning, and isolates from specific business needs.
Counting elements:

who

c...]]></description><link>https://levene.me/counting-service</link><guid isPermaLink="true">https://levene.me/counting-service</guid><category><![CDATA[Go Language]]></category><category><![CDATA[Rust]]></category><category><![CDATA[backend]]></category><category><![CDATA[architecture]]></category><category><![CDATA[architect]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Thu, 23 Feb 2023 06:34:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677132696534/8d4f2953-f7f3-4356-8aea-a99a0d7d8e6d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Counting service is a really fundamental service that has a lot of counting needs in business, such as likes, favorites, etc. It requires stable counting, meets long-term planning, and isolates from specific business needs.</p>
<p>Counting elements:</p>
<ul>
<li><p>who</p>
</li>
<li><p>counting object id</p>
</li>
<li><p>counting object type</p>
</li>
<li><p>counting increment</p>
</li>
<li><p>create time</p>
</li>
</ul>
<p>A single count is achieved by combining the above elements. Looking at it in the context of business, the counting needs are rough as follows:</p>
<ul>
<li><p>Number of views for an article</p>
</li>
<li><p>Number of likes for a comment or answer</p>
</li>
<li><p>Number of purchases for a product</p>
</li>
<li><p>And so on.</p>
</li>
</ul>
<pre><code class="lang-haskell">enum ContentType {
    ContentType_UNKNOW              = 0;
    ContentType_ARTICLE             = 1;
    ContentType_QUORA               = 2;
    ContentType_TOPIC               = 3;
    ContentType_WINELIST            = 4;
    ContentType_WINECOMMENT         = 5;
    ContentType_TIMELINE            = 6;
}

enum CountingType {
    CountingType_UNKNOW             = 0;
    CountingType_PRAISE             = 1;
    CountingType_LIKE               = 2;
    CountingType_COMMENT            = 3;
    CountingType_VIEW               = 4;
    CountingType_READ               = 5;
    CountingType_FORWORD            = 6;
    CountingType_SHARE              = 7;
    CountingType_DOWN               = 8;
    CountingType_REPORT             = 9;
    CountingType_BUY                = 10;
    CountingType_SALE               = 11;
    CountingType_TSASTE             = 12;
    CountingType_FAVORITE           = 13;
}
</code></pre>
<p>In addition to these, there are also other needs, such as obtaining the recent count list, for example, the last 20 people who viewed an article.</p>
<h2 id="heading-storage-structure">Storage Structure</h2>
<p>To meet the long-term requirements of the system, the storage structure needs to occupy as little space as possible and be highly efficient. Therefore, I have adopted a three-segment storage structure:</p>
<p>Segment 1: time_stamp &amp; increment &amp; counting_type</p>
<p>Segment 2: content_id &amp; member_id</p>
<p>Segment 3: count</p>
<p>Three numbers constitute one counting operation, with each segment represented by an int64 data type. The theoretical size occupation is:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677132139004/e6517ac9-702d-416c-ad75-4ea886d94a10.png" alt class="image--center mx-auto" /></p>
<p>The theoretical storage size for this structure is such that 10GB of storage can hold up to 45 billion counting records, which is quite impressive.</p>
<pre><code class="lang-less"><span class="hljs-selector-tag">2</span>^<span class="hljs-selector-tag">8</span>=<span class="hljs-selector-tag">256</span>
<span class="hljs-selector-tag">2</span>^<span class="hljs-selector-tag">16</span>=<span class="hljs-selector-tag">65535</span>
<span class="hljs-selector-tag">2</span>^<span class="hljs-selector-tag">32</span>=<span class="hljs-selector-tag">40</span> <span class="hljs-selector-tag">Billion</span>
<span class="hljs-selector-tag">---</span>
<span class="hljs-selector-tag">ONE</span>:
+<span class="hljs-selector-tag">---</span>+<span class="hljs-selector-tag">---------------------</span>+<span class="hljs-selector-tag">------------------</span>+<span class="hljs-selector-tag">--------------------</span>+
|   |<span class="hljs-selector-tag">counting_type</span> <span class="hljs-selector-tag">id</span>(<span class="hljs-number">16</span>) | <span class="hljs-selector-tag">increment</span> <span class="hljs-selector-tag">id</span>(<span class="hljs-number">1</span>) | <span class="hljs-selector-tag">timestamp</span>(ms)<span class="hljs-selector-tag">41</span> |
+<span class="hljs-selector-tag">---</span>+<span class="hljs-selector-tag">---------------------</span>+<span class="hljs-selector-tag">------------------</span>+<span class="hljs-selector-tag">--------------------</span>+

<span class="hljs-selector-tag">TWO</span>:
+<span class="hljs-selector-tag">-----------------------------</span>+
| <span class="hljs-selector-tag">content_id</span>(<span class="hljs-number">32</span>) | <span class="hljs-selector-tag">creater</span>(<span class="hljs-number">32</span>)|
+<span class="hljs-selector-tag">-----------------------------</span>+

<span class="hljs-selector-tag">THREE</span>:
+<span class="hljs-selector-tag">-----------------------------</span>+
| <span class="hljs-selector-tag">total</span> (<span class="hljs-number">32</span>)                  | 
+<span class="hljs-selector-tag">-----------------------------</span>+

<span class="hljs-selector-tag">query</span>:
<span class="hljs-selector-attr">[ONE,TWO,THREE]</span>: <span class="hljs-selector-tag">content_id00000000</span> &gt;= <span class="hljs-selector-tag">content_id00000000</span> <span class="hljs-selector-tag">&amp;</span><span class="hljs-selector-tag">&amp;</span> <span class="hljs-selector-tag">content_id</span> &lt; (content_id+<span class="hljs-number">1</span>)<span class="hljs-selector-tag">00000000</span>

<span class="hljs-selector-attr">[[ONE,TWO,THREE]</span>,<span class="hljs-selector-attr">[ONE,TWO,THREE]</span>,<span class="hljs-selector-attr">[ONE,TWO,THREE]</span>]
</code></pre>
<h2 id="heading-data-structure">Data Structure</h2>
<p>To add some fun to the code, I have chosen a team from a movie as the name for the data structure and assigned roles based on their character traits.</p>
<pre><code class="lang-go"><span class="hljs-keyword">type</span> (

    MetaItem <span class="hljs-keyword">struct</span> {
        hOne   *HuBayi
        sTwo   *Shirley
        wThree WangKaiXuan
        hsw    []<span class="hljs-keyword">int64</span>
        H      <span class="hljs-keyword">int64</span>
        S      <span class="hljs-keyword">int64</span>
        W      <span class="hljs-keyword">int64</span>
    }

    <span class="hljs-comment">// HuBayi: Team Core - The one in charge of every action: "Captain"</span>
    HuBayi <span class="hljs-keyword">struct</span> {
        time_stamp    <span class="hljs-keyword">int64</span>
        increment     <span class="hljs-keyword">bool</span>
        counting_type <span class="hljs-keyword">int64</span>
    }

    <span class="hljs-comment">// Shirley: Attentive and meticulous, responsible for intelligence work - "Spy" (or "Intelligence Officer") - records who the target is.</span>
    Shirley <span class="hljs-keyword">struct</span> {
        content_id <span class="hljs-keyword">int64</span>
        member_id  <span class="hljs-keyword">int64</span>
    }

    <span class="hljs-comment">// WangKaiXuan: Greedy and responsible for managing assets and recording the total count - "Treasurer".</span>
    WangKaiXuan <span class="hljs-keyword">int64</span>
)
</code></pre>
<p>About the order of these three segments, there is a small trick that will be revealed in the querying section later.</p>
<p>Data Structure Construction:</p>
<pre><code class="lang-go">

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">NewMetaItem</span><span class="hljs-params">(h *HuBayi, s *Shirley, w WangKaiXuan)</span> *<span class="hljs-title">MetaItem</span></span> {
    meta := &amp;MetaItem{
        hOne:   h,
        sTwo:   s,
        wThree: w,
    }

    meta.Setup()
    <span class="hljs-keyword">return</span> meta
}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-params">(this *MetaItem)</span> <span class="hljs-title">Setup</span><span class="hljs-params">()</span></span> {

    this.H = this.hOne.Value()
    this.S = this.sTwo.Value()
    this.W = <span class="hljs-keyword">int64</span>(this.wThree)
}
</code></pre>
<p>As an example, let's use the character "Hu Bayi":</p>
<pre><code class="lang-go"><span class="hljs-comment">/*
+---+---------------------+------------------+--------------------+
|0 |counting_type id(16) | increment id(1)   |  timestamp(ms)41  |
+---+--------------------+-------------------+--------------------+
*/</span>
<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-params">(this *HuBayi)</span> <span class="hljs-title">Value</span><span class="hljs-params">()</span> <span class="hljs-title">int64</span></span> {

    <span class="hljs-keyword">var</span> incrementInt <span class="hljs-keyword">int64</span>
    <span class="hljs-keyword">if</span> this.increment {
        incrementInt = <span class="hljs-number">1</span>
    } <span class="hljs-keyword">else</span> {
        incrementInt = <span class="hljs-number">0</span>
    }

    <span class="hljs-keyword">return</span> this.counting_type&lt;&lt;CountingTypeShift |
        incrementInt&lt;&lt;IncrmentShift |
        (this.time_stamp - twepoch)

}

<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-params">(this *HuBayi)</span> <span class="hljs-title">Parse</span><span class="hljs-params">(value <span class="hljs-keyword">int64</span>)</span> <span class="hljs-params">(<span class="hljs-keyword">int64</span>, <span class="hljs-keyword">int64</span>, <span class="hljs-keyword">int64</span>)</span></span> {

    time_stamp := (value &amp; MaxTimestamp) + twepoch

    increment := (value &gt;&gt; IncrmentShift) &amp; MaxIncrment

    counting_type := (value &gt;&gt; CountingTypeShift) &amp; MaxCountingType

    <span class="hljs-keyword">return</span> counting_type, increment, time_stamp
}
</code></pre>
<h2 id="heading-scalability">Scalability</h2>
<ul>
<li><p>16 bits are reserved for counting_type, which completely satisfies any future expansion requirements.</p>
</li>
<li><p>To achieve maximum scalability, all timestamps do not start from 1997, but rather from a recent time, theoretically allowing the system to operate for another 20 years.</p>
</li>
</ul>
<h2 id="heading-querying">Querying</h2>
<p>To query the total count, we only need to retrieve the last counting record, as Wang Kaixuan always records the final result after each counting operation. Here is an explanation of how to perform the query:</p>
<pre><code class="lang-go">+---+---------------------+------------------+--------------------+
|   |counting_type id(<span class="hljs-number">16</span>) | increment id(<span class="hljs-number">1</span>)   |  timestamp(ms)<span class="hljs-number">41</span>  |
+---+--------------------+-------------------+--------------------+

TWO:
+-----------------------------+
| content_id(<span class="hljs-number">32</span>) | creater(<span class="hljs-number">32</span>)|
+-----------------------------+
</code></pre>
<p>As mentioned earlier, we can convert the query operation into a comparison operation, which is much more efficient than string-matching operations.</p>
<p>By sorting the counting records by timestamp and keeping track of the latest count for each content_id and counting_type, we can quickly obtain the total count for each counting_type. Then, we can simply sum up all the latest counts to get the total count.</p>
<p>Since the fields in the CountingRecord struct are all integers, we can use comparison operators to compare them, which is much faster than string-matching operations.</p>
<pre><code class="lang-go">
content_id_select := content_id &lt;&lt; model.ContentIdIdShift
content_id_select_max := (content_id + <span class="hljs-number">1</span>) &lt;&lt; model.ContentIdIdShift

err = this.withDBContext(<span class="hljs-function"><span class="hljs-keyword">func</span><span class="hljs-params">(c *mgo.Collection)</span> <span class="hljs-title">error</span></span> {

    <span class="hljs-keyword">var</span> err error
    query := bson.M{}

    query[<span class="hljs-string">"s"</span>] = bson.M{
        <span class="hljs-string">"$gte"</span>: content_id_select,
        <span class="hljs-string">"$lt"</span>:  content_id_select_max,
    }

    err = c.Find(query).Sort(<span class="hljs-string">"-_id"</span>).One(&amp;it)
    <span class="hljs-keyword">return</span> err

}, this.dbSession,
    getDBName(content_type),
    getCollectionName(counting_type))
</code></pre>
<p>To find the desired record, we can use the content_id_select and content_id_select_max fields to define a range and then search for the maximum count within that range. Similarly, other query operations can be performed using this approach, such as finding the most recent likes list, whether a user has liked a certain content, the time of the like, and so on. Here is an example of how to find the maximum count within a range:</p>
<p>Sort the counting records by timestamp in descending order.</p>
<p>Iterate through the records and keep track of the latest count for each content_id and counting_type within the range defined by content_id_select and content_id_select_max.</p>
<p>Return the maximum count within the range.</p>
<p>This approach allows us to efficiently search for records within a specific range without the need to iterate through all the records, which would be much slower.</p>
<h2 id="heading-database">Database</h2>
<p>That's correct. Since the system is designed using a general approach, it can be implemented on various databases including MongoDB, and the performance should not differ significantly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677133559029/78f49621-25bd-483b-8b45-c0fb69094c43.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-index">Index</h2>
<p>it's a good idea to create an index on the "h", "s", and "id" fields since they are used in the queries to identify specific records. By creating an index, the database can quickly locate the relevant records and avoid scanning through the entire collection. This can significantly improve the performance of the queries.</p>
<h2 id="heading-performance">Performance</h2>
<p>Real-time retrieval of billions of records in a single table</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677132471529/0e6f2dc3-d5df-466c-97f8-61a6ee9cab4c.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677132486792/c4a09149-edb6-4a9a-a0d8-70883e8b005c.png" alt class="image--center mx-auto" /></p>
<p>This system has low space consumption and high read/write performance, with a small amount of code. It has been running in production for many years.</p>
<p>End</p>
]]></content:encoded></item><item><title><![CDATA[Get rid of the intermediate state]]></title><description><![CDATA["Is the code done yet?" "It's 80% done, like playing a game. This is the final level before the boss battle!"

"Did you finish testing the functions?" "I've tested most of them, but there are still a dozen test cases to go. It's like doing a quiz, yo...]]></description><link>https://levene.me/get-rid-of-the-intermediate-state</link><guid isPermaLink="true">https://levene.me/get-rid-of-the-intermediate-state</guid><category><![CDATA[manager]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Sat, 18 Feb 2023 09:09:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/lLhOvcRXcbY/upload/d19aa226d1c98658258a6b86013cc7a6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<ol>
<li><p>"Is the code done yet?" "It's 80% done, like playing a game. This is the final level before the boss battle!"</p>
</li>
<li><p>"Did you finish testing the functions?" "I've tested most of them, but there are still a dozen test cases to go. It's like doing a quiz, you've got 80% right, but you still need to work on the last few tricky questions."</p>
</li>
<li><p>"Is the PRD done yet?" "It's an internal review now; like a foodie tasting a dish, our Prd needs to go through multiple rounds of refinement to achieve the perfect flavor."</p>
</li>
</ol>
<h2 id="heading-the-intermediate-state-of-omnipotence">The intermediate state of "omnipotence."</h2>
<p>The intermediate status is a mysterious and versatile state that anyone can create. For example, a design may be in an evaluation state, where the invention is not yet complete, but it seems to be finished. So who is primarily responsible for this state, the designer or the reviewer? This is why evaluation states usually have two situations:</p>
<ol>
<li><p>The evaluation period is very long, even exceeding the design time.</p>
</li>
<li><p>The evaluation becomes formalistic, and the problems leak into later processes, causing high costs to fix.</p>
</li>
</ol>
<p>Anyone can create countless intermediate states, and they can usually make sense at first glance, but upon closer inspection, they are all wrong. But do we have the energy to deal with a massive number of intermediate states? A large amount of excellent creativity is used here; it is simply a breeding ground for creativity. Therefore, please block this path, cut off these "smart" ideas, and do something stupid instead.</p>
<p>Therefore, please get rid of intermediate states and make a clear definition of what is to be delivered, first by establishing the Definition of Done (DoD).</p>
<ul>
<li><p>The DoD of a specific feature, for example, this feature has been developed and is in a deployable state, verified by the product owner.</p>
</li>
<li><p>The DoD of an iteration, for example, all planned features of this iteration have been completed.</p>
</li>
<li><p>The DoD of a release, for example the entire software is in a releasable state, and the release plan has been defined.</p>
</li>
</ul>
<p>Once we establish a clear DoD in our collaboration, we can even solidify it through processes to efficiently and effectively complete our work.</p>
<h2 id="heading-delivery">Delivery</h2>
<p>This is the first issue to communicate because delivering stable software that meets business requirements is the fundamental responsibility of a technical person.</p>
<p>Most collaboration problems are caused by the need for a clear Definition of Done (DoD). Different parties have different understandings of what "Done" means, and they use various intermediate states to cope with the situation, which leads to inefficiency and wasted time in the end.</p>
<h3 id="heading-function-development-completed"><strong>Function development completed</strong></h3>
<p>It means that the developer has gone through the requirements analysis, solution design, code implementation, and unit testing and has passed the acceptance test by the testing personnel, ensuring that the code is in a deployable state and the relevant documents have been completed.</p>
<h3 id="heading-code-writing-completed"><strong>Code writing completed</strong></h3>
<p>It means that the developer has written the functional code, the unit test code, and the integration test code, and the tests have passed. The code has also passed the code style check and the test coverage check.</p>
<p>Therefore, when referring to "function development completed" or "code writing completed" in subsequent communication, please refer to the above requirements. If you are unsure about what "Done" means in your work, please immediately confirm with relevant colleagues.</p>
<p>The above delivery information was taken from the department's culture document, which provides a clear and minimal definition of "Done." When a team member changes the status of their work, everyone in the team knows exactly what it means.</p>
<p>Remember:</p>
<p><strong>There's only completed and not completed, and 99% of the time, there's no difference between the two.</strong></p>
]]></content:encoded></item><item><title><![CDATA[Chicken or egg first?]]></title><description><![CDATA[First, this is not a scientific article but an analysis of how to solve problems encountered in life and work. Let's take a look at the following issues:

If we can hire top talents, our business will develop better and faster; if our company develop...]]></description><link>https://levene.me/chicken-or-egg-first</link><guid isPermaLink="true">https://levene.me/chicken-or-egg-first</guid><category><![CDATA[manager]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Sat, 18 Feb 2023 05:22:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/DoqtEEn8SOo/upload/fc735313259c93cfe67e34a9d2e2ec19.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>First, this is not a scientific article but an analysis of how to solve problems encountered in life and work. Let's take a look at the following issues:</p>
<blockquote>
<p>If we can hire top talents, our business will develop better and faster; if our company develops better and quicker, we can hire top talents.</p>
<p>Build a great corporate culture like Google and provide the world's best products and services; use the best products and services to build a great corporate culture.</p>
<p>We want to have a membership model, but the benefits we can offer members are not enough at the moment; we need to prepare businesses that could provide potential membership benefits, but the membership model is still not on the agenda.</p>
<p>If we have more time, we can deliver better products; if we have already delivered better outcomes, we can get more time.</p>
<p>The team's average level is low, and we must be hands-on to ensure reliable quality delivery, but the team's growth rate is slow. If we are not hands-on, we cannot meet the quality requirements.</p>
<p>Unit testing can ensure quality, but it requires more time. The guru says unit testing can reduce project time and bring immense benefits.</p>
<p>We want to learn and improve ourselves, but our lives and work have taken up much time.</p>
<p>We want to do trendy and cool businesses, but that is a double-edged sword.</p>
</blockquote>
<p>There are many problems in life and work, with no clear answer to whether to have the chicken or the egg first. <strong>It's a real problem.</strong></p>
<p><strong><mark>But really, it doesn't matter which comes first. It's about what you want.</mark></strong></p>
<p>Startups want to do a good job on their business while building excellent mechanisms like Google.</p>
<p>If the business is a little better, they can hire better people. If the team is better, the company can take off.</p>
<p>They want to do a membership model like Netflix, but the benefits for members are too few for their current businesses.</p>
<p>If they had more time, they could deliver better products.</p>
<p>There are countless contradictions and deadlocks in work and life.</p>
<p>Being trendy and relaxed is a double-edged sword.</p>
<p>It doesn't matter whether you have the chicken or the egg first. Just take a small step forward and run it carefully. The first step is to assume that one of the two exists. Then it's simple:</p>
<ul>
<li><p>Know what to do (use what you have to do it)</p>
</li>
<li><p>Identify the problem (lack of the other thing)</p>
</li>
<li><p>Plan the path and execute y = f (x)</p>
</li>
<li><p>Wait for the results</p>
</li>
</ul>
<p>Take a small step, <strong>choose one</strong>, and don't hesitate or waver. Many people are not firm enough in their actions.</p>
<p>Math teachers teach us a standard method when solving problems: assume N, then M, so O. Assume X, then Y, so Z.</p>
<h2 id="heading-the-method-of-assumption">The Method of Assumption</h2>
<p>Let's look at a math problem for elementary school students:</p>
<p>Example: The perimeter of a rectangle is 36 centimeters. If the length and width are increased by 3 centimeters each, how many square centimeters larger is the new rectangle compared to the original one?</p>
<p>Using the usual problem-solving method, we need to find the difference between the two areas, but we can't determine it based on the conditions given. If we assume that the length and width of the rectangle are 10 centimeters and 8 centimeters, respectively, and each is increased by 3 centimeters, that is (10+3) centimeters and (8+3) centimeters, we can calculate:</p>
<p>Original rectangle area: 10 × 8 = 80 (square centimeters)</p>
<p>New rectangle area: (10+3) × (8+3)</p>
<p>I remember getting stuck in a rut in school, always doubting whether those assumptions were even accurate. It made me fall behind and waste so much time before finally figuring out the answers.</p>
<p>But in the end, after checking with my classmates, we found that the solution was almost identical to what we had discussed earlier.</p>
<p>Although the question was simple, the lesson was profound: there are always more ways to solve a problem than obstacles, so keep looking until you find it.</p>
<p>Confidence isn't just about confidently talking about what you know; it's about having a positive attitude and a problem-solving approach to the unknown.</p>
<p>In the world of startups, there are problems, but most can be boiled down to one thing: <strong><mark>the initial beautiful vision and numerous advantages can't be delivered.</mark></strong> Promising too much can confuse people and make them feel like everything is possible, but nothing is good enough. This goes for investors and bosses and even more so for users. Keep the features simple and easy to understand. Simplicity is the right way to start.</p>
<h2 id="heading-heres-a-breakdown-of-how-to-execute-it">Here's a breakdown of how to execute it:</h2>
<ul>
<li><p>First, assume that you have the chicken or the egg and evaluate whether the risks are entirely unsolvable.</p>
</li>
<li><p>Based on the assumptions, assign different parts and set growth vectors.</p>
</li>
<li><p>Each part will make good progress.</p>
</li>
<li><p>Risks and problems will converge, showing a decrease in entropy.</p>
</li>
<li><p>Find all resources to solve the converged problems.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[The Dreaded 'x' Is Come Again🙁]]></title><description><![CDATA[Good = f (Bad)

Let's start with layoffs.
Facing a layoff can be a daunting task for any team.
There are many issues to tackle, such as adjusting schedules, changing plans and goals, dealing with team morale, etc. It can be overwhelming when many tea...]]></description><link>https://levene.me/the-dreaded-x-is-come-again</link><guid isPermaLink="true">https://levene.me/the-dreaded-x-is-come-again</guid><category><![CDATA[manager]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Fri, 17 Feb 2023 05:27:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676611428714/1e31517a-7cb8-42ca-abe5-8f100fd53efe.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Good = f (Bad)</p>
</blockquote>
<p>Let's start with layoffs.</p>
<p>Facing a layoff can be a daunting task for any team.</p>
<p>There are many issues to tackle, such as adjusting schedules, changing plans and goals, dealing with team morale, etc. It can be overwhelming when many team members experience this situation for the first time. As the department leader, you must remain level-headed and handle several areas of responsibility, including:</p>
<ul>
<li><p>Business progress adjustments</p>
</li>
<li><p>Communicating with parallel departments about collaboration issues</p>
</li>
<li><p>Plans Defining the scale and pace of layoffs Calming down team members</p>
</li>
<li><p>Find out various unexpected hidden difficulties, and more With so many things to take care of</p>
</li>
<li><p>the department head must first understand their responsibilities.</p>
</li>
</ul>
<h2 id="heading-turn-bad-things-into-good-things">Turn "Bad" Things into "Good" Things</h2>
<p>This is a regular thing. When business performance is poor, the company may need to reduce headcount. This type of thing happens all the time; it is just that it is the first time you have experienced it.</p>
<p>During this process, everyone will face their thoughts. It is essential to think forward and take the next step. The only thing that is not important is self-pitying in negative emotions.</p>
<p>Layoffs themselves are not brutal, and layoffs should not be the goal. The goal should be that every person becomes more robust after the layoff, the team becomes more muscular, and the business becomes more robust.</p>
<p>The basic principle is turning a "bad" thing into a "good" one.</p>
<h2 id="heading-the-dreaded-x">The Dreaded 'x'</h2>
<p>During this process, it was found that a considerable number of team members fell into negative emotions. This includes those who have to leave and those who have to stay.</p>
<p>Complaining, fear and negativity can all influence each other. Negative emotions are naturally highly contagious.</p>
<blockquote>
<p>"Good things don't go out, but bad things spread for miles."</p>
</blockquote>
<p>One of the most important reasons is that they are involved parties. We can think about this problem using a work-based approach.</p>
<p>We can define this situation as variable "x," and we need to turn this negative variable "x" into a positive variable "y" through the function:</p>
<blockquote>
<p>y = f (x) ==&gt; Good = f (Bad)</p>
</blockquote>
<p>Then, we can analyze the factors that affect "x" and it will be easier to conclude with "y"</p>
<p>The company should maintain continuous delivery capability, and the progress and plan adjustments should be communicated promptly, accurately, and transparently to all stakeholders to ensure everyone is on the same page.</p>
<p>For everyone, learning how to face "x" with the right mindset is their most significant opportunity for growth.</p>
<p>Everyone will face countless difficulties and challenges in life and work, and learning how to face problems is the most difficult part. Many team members have grown in different ways through this process, such as:</p>
<ul>
<li><p>Improving their skills and competitiveness</p>
</li>
<li><p>Ensuring that everything is business-oriented and ensuring business growth for everyone's safety. Actively dealing with problems rather than complaining.</p>
</li>
</ul>
<p>In conclusion, this is an excellent way to handle most negative things individuals encounter.</p>
<p>Define each difficulty you face as "x," and then write the logic of "Good = f (Bad)."</p>
<p>This method can help turn negative things into positive ones.</p>
<h2 id="heading-finally">Finally</h2>
<p>"The basic principle is to turn a 'bad' thing into a 'good' thing. It is appropriate to turn a good thing into a good thing, foolish to turn a good thing into a bad thing, and mediocre to turn a bad thing into a bad thing.</p>
<p>A person's value lies in turning a bad thing into a good one, which is also the fundamental difference from others."</p>
]]></content:encoded></item><item><title><![CDATA[Chatgpt came up with slogans for me🧐]]></title><description><![CDATA[Chatgpt came up with three slogans for weedone, and I'm thinking about which one to use.

“Get things done with less effort - prioritize what matters with our app.”
“Make progress where it matters - simplify your to-do list with our app.”
“Focus on w...]]></description><link>https://levene.me/chatgpt-came-up-with-slogans-for-me</link><guid isPermaLink="true">https://levene.me/chatgpt-came-up-with-slogans-for-me</guid><category><![CDATA[marketing]]></category><category><![CDATA[chatgpt]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Wed, 15 Feb 2023 03:39:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/drwpcjkvxuU/upload/2ccb9e492d88fccd71b8502c4449e59f.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Chatgpt came up with three slogans for weedone, and I'm thinking about which one to use.</p>
<blockquote>
<p>“Get things done with less effort - prioritize what matters with our app.”</p>
<p>“Make progress where it matters - simplify your to-do list with our app.”</p>
<p>“Focus on what truly counts - achieve more by doing less with our to-do app.”</p>
</blockquote>
<p>Pretty good.</p>
]]></content:encoded></item><item><title><![CDATA[About 👋🏻]]></title><description><![CDATA[I'm a software engineer who is preparing to start a business, I build weedone and insou(will coming soon), and I will share my entrepreneurial process here in the future. I will record the process. The future is promising, let's go!🪴]]></description><link>https://levene.me/about</link><guid isPermaLink="true">https://levene.me/about</guid><category><![CDATA[aboutme]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Sat, 11 Feb 2023 06:38:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/NJTj9jvNo0U/upload/a1abe5f2a50a1126ad63ca18cb059d8d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I'm a software engineer who is preparing to start a business, I build <a target="_blank" href="https://weedone.app">weedone</a> and insou(will coming soon), and I will share my entrepreneurial process here in the future. I will record the process. The future is promising, let's go!🪴</p>
]]></content:encoded></item><item><title><![CDATA[Build Parser Using Rust 🛁]]></title><description><![CDATA[I released an INI parser implemented in Go on GitHub. Now, I aim to implement a parser using Rust and take the tag function in Bear, my favorite note-taking software, as an example. The tag function in Bear is both powerful and easy to use, and I bel...]]></description><link>https://levene.me/build-parser-using-rust</link><guid isPermaLink="true">https://levene.me/build-parser-using-rust</guid><category><![CDATA[Rust]]></category><category><![CDATA[Go Language]]></category><category><![CDATA[Developer]]></category><category><![CDATA[praser]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Fri, 10 Feb 2023 02:11:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1675995000864/4488cb4c-80d0-46bd-8c74-61a3821ed69c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I released an INI parser implemented in Go on GitHub. Now, I aim to implement a parser using Rust and take the tag function in Bear, my favorite note-taking software, as an example. The tag function in Bear is both powerful and easy to use, and I believe it will serve as a great example for this project.</p>
<p>the tags in Bear APP are denoted by double hash symbols (<code>##</code>). However, we have made a change to the way tags are defined. And any content immediately followed by a single hash symbol (#) will be treated as a tag and will end directly with a space.</p>
<p>For the parser, still do some preliminary introduction, in fact, the steps are as follows:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1675993805892/a7f6975c-0d2f-418f-b8d9-fb482a26573c.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>Source Code -&gt; Lexer -&gt; Token -&gt; Parser -&gt; Abstract Syntax Tree</p>
</blockquote>
<p>so, let's begin to build a parser with Rust</p>
<h2 id="heading-token">Token</h2>
<p>In Go language, Token is generally defined as String, and like this</p>
<pre><code class="lang-go">
<span class="hljs-keyword">type</span> TokenType <span class="hljs-keyword">string</span>

<span class="hljs-keyword">const</span> (
    TokenTypeILLEGAL = <span class="hljs-string">"ILLEGAL"</span>
    TokenTypeEOF     = <span class="hljs-string">"EOF"</span>
    Ident            = <span class="hljs-string">"Ident"</span>
    TokenTypeCOMMENT  = <span class="hljs-string">"#"</span>
    TokenTypeCOMMENT2 = <span class="hljs-string">";"</span>
    TokenTypeASSIGN   = <span class="hljs-string">"="</span>
    TokenTypeLBRACKET = <span class="hljs-string">"["</span>
    TokenTypeRBRACKET = <span class="hljs-string">"]"</span>
    RETURN = <span class="hljs-string">"RETURN"</span>
)
</code></pre>
<p>share a powerful feature of the Rust programming language - enumerations. The capability of Rust enumerations goes beyond what we previously understood. Not only can they have different data types, but they can also associate data.</p>
<p>This opens up new possibilities for defining objects such as tokens. In Rust, we can define a Token like this:</p>
<pre><code class="lang-rust"><span class="hljs-meta">#[derive(PartialEq, Debug, Clone)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">enum</span> <span class="hljs-title">Token</span></span> {
    ILLEGAL,
    EOF,
    INDENT(<span class="hljs-built_in">Vec</span>&lt;<span class="hljs-built_in">char</span>&gt;),

    SHARP(<span class="hljs-built_in">char</span>), <span class="hljs-comment">// #</span>
    Colon(<span class="hljs-built_in">char</span>), <span class="hljs-comment">// ,</span>
    MINUS(<span class="hljs-built_in">char</span>), <span class="hljs-comment">// -</span>
}
</code></pre>
<h2 id="heading-lexer">Lexer</h2>
<p>The next thing to implement is the lexical analyzer.</p>
<pre><code class="lang-rust"><span class="hljs-keyword">use</span> super::token;
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Lexer</span></span> {
    input: <span class="hljs-built_in">Vec</span>&lt;<span class="hljs-built_in">char</span>&gt;,         
    <span class="hljs-keyword">pub</span> position: <span class="hljs-built_in">usize</span>,      
    <span class="hljs-keyword">pub</span> read_position: <span class="hljs-built_in">usize</span>, 
    <span class="hljs-keyword">pub</span> ch: <span class="hljs-built_in">char</span>,             
}

<span class="hljs-keyword">impl</span> Lexer {
    <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>(input: <span class="hljs-built_in">Vec</span>&lt;<span class="hljs-built_in">char</span>&gt;) -&gt; <span class="hljs-keyword">Self</span> {
        <span class="hljs-keyword">Self</span> {
            input: input,
            position: <span class="hljs-number">0</span>,
            read_position: <span class="hljs-number">0</span>,
            ch: <span class="hljs-string">'0'</span>,
        }
    }
}
</code></pre>
<p>reading Tokens in Rust - using a finite state machine. This approach involves continuously reading the next character until the corresponding identifier is found. If the identifier is not found, the process continues until a match is found or until the end of the input is reached.</p>
<p>If you are interested, please refer to <a target="_blank" href="https://en.wikipedia.org/wiki/Finite-state_machine">Finite-state machine-Wikipedia</a></p>
<pre><code class="lang-rust">
<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">read_char</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>) {
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">self</span>.read_position &gt;= <span class="hljs-keyword">self</span>.input.len() {
        <span class="hljs-keyword">self</span>.ch = <span class="hljs-string">'0'</span>;
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">self</span>.ch = <span class="hljs-keyword">self</span>.input[<span class="hljs-keyword">self</span>.read_position];
    }
    <span class="hljs-keyword">self</span>.position = <span class="hljs-keyword">self</span>.read_position;
    <span class="hljs-keyword">self</span>.read_position = <span class="hljs-keyword">self</span>.read_position + <span class="hljs-number">1</span>;
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">peek_char</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>, offset: <span class="hljs-built_in">usize</span>) -&gt; <span class="hljs-built_in">char</span> {
    <span class="hljs-keyword">let</span> position = <span class="hljs-keyword">self</span>.read_position + offset;

    <span class="hljs-keyword">if</span> position &gt;= <span class="hljs-keyword">self</span>.input.len() {
        <span class="hljs-keyword">return</span> <span class="hljs-string">'0'</span>;
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">self</span>.input[position];
    }
}

<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">next_token</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>) -&gt; token::Token {
    <span class="hljs-keyword">let</span> tok: token::Token;
    <span class="hljs-keyword">self</span>.skip_whitespace();

    <span class="hljs-keyword">match</span> <span class="hljs-keyword">self</span>.ch {
        <span class="hljs-string">'#'</span> =&gt; {
            tok = token::Token::SHARP(<span class="hljs-keyword">self</span>.ch);
        }
        <span class="hljs-string">'0'</span> =&gt; {
            tok = token::Token::EOF;
        }
        _ =&gt; {
            <span class="hljs-keyword">let</span> ident = <span class="hljs-keyword">self</span>.read_statements();
            <span class="hljs-keyword">if</span> ident.len() &gt; <span class="hljs-number">0</span> {
                tok = token::Token::INDENT(ident);
            } <span class="hljs-keyword">else</span> {
                <span class="hljs-keyword">return</span> token::Token::ILLEGAL;
            }
        }
    }

    <span class="hljs-keyword">self</span>.read_char();
    tok
}
</code></pre>
<p>Our focus is on identifying the tags within the content, and as a result, we do not need to fully identify and optimize other content.</p>
<p>We will be running this example as a lexical analyzer, which is responsible for breaking down the input into Tokens.</p>
<p>In the previous implementation of our Go INI parser, we used a Parser to recognize the Tokens and turn them into an abstract syntax tree. However, for the purposes of this example, we will not be constructing an abstract syntax tree.</p>
<h2 id="heading-parser">Parser</h2>
<p>build a parser</p>
<pre><code class="lang-rust"><span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Parser</span></span> {
    <span class="hljs-keyword">pub</span> lexer: Lexer,
    peek_token: Token,
    <span class="hljs-keyword">pub</span> input: <span class="hljs-built_in">Vec</span>&lt;<span class="hljs-built_in">char</span>&gt;,
    tokens: <span class="hljs-built_in">Vec</span>&lt;Token&gt;,  <span class="hljs-comment">// 将token存入Vec即可</span>
}

<span class="hljs-keyword">impl</span> Parser {
    <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>(input: <span class="hljs-built_in">Vec</span>&lt;<span class="hljs-built_in">char</span>&gt;) -&gt; Parser {
        <span class="hljs-keyword">let</span> l = Lexer::new(input.clone());
        Parser {
            lexer: l,
            input,
        }
    }
}
</code></pre>
<pre><code class="lang-rust"><span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">parse_documment</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>) -&gt; <span class="hljs-built_in">Result</span>&lt;Document, ParseError&gt; {
    <span class="hljs-keyword">self</span>.current_token = <span class="hljs-keyword">self</span>.lexer.next_token();
    <span class="hljs-keyword">self</span>.peek_token = <span class="hljs-keyword">self</span>.lexer.next_token();

    <span class="hljs-keyword">self</span>.tokens.push(<span class="hljs-keyword">self</span>.current_token.clone());

    <span class="hljs-keyword">while</span> <span class="hljs-keyword">self</span>.current_token != Token::EOF {
        <span class="hljs-keyword">self</span>.next_token();
        <span class="hljs-keyword">self</span>.tokens.push(<span class="hljs-keyword">self</span>.current_token.clone());
    }
    <span class="hljs-keyword">self</span>.transform_to_document();
}
</code></pre>
<pre><code class="lang-rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">transform_to_document</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>) -&gt; <span class="hljs-built_in">Result</span>&lt;Document, ParseError&gt; {
    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> document = Document {
        ..<span class="hljs-built_in">Default</span>::default()
    };
    <span class="hljs-keyword">self</span>.read_token();
    <span class="hljs-keyword">loop</span> {
        <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> offset = <span class="hljs-number">0</span>;
        <span class="hljs-keyword">match</span> &amp;<span class="hljs-keyword">self</span>.current_token {
            Token::SHARP(_) =&gt; {
                <span class="hljs-keyword">let</span> peek_token = <span class="hljs-keyword">self</span>.peek_token_next1();
                <span class="hljs-keyword">match</span> peek_token {
                    Token::Statement(chs) =&gt; {
                        <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> tag = Tag::default();
                        tag.id = chs.into_iter().collect();
                        document.tags.push(tag);
                        offset = offset + <span class="hljs-number">1</span>;
                    }
                    _ =&gt; {}
                }
            }

            Token::Statement(ident) =&gt; {
                <span class="hljs-keyword">let</span> state_ident: <span class="hljs-built_in">String</span> = ident.into_iter().collect();
                <span class="hljs-keyword">if</span> document.name == <span class="hljs-string">""</span> {
                    document.name = <span class="hljs-built_in">format!</span>(<span class="hljs-string">"{}"</span>, state_ident);
                } <span class="hljs-keyword">else</span> {
                    document.name = <span class="hljs-built_in">format!</span>(<span class="hljs-string">"{} {}"</span>, document.name, state_ident);
                };
            }
            Token::EOF =&gt; {
                <span class="hljs-keyword">break</span>;
            }
            _ =&gt; {
                <span class="hljs-keyword">return</span> <span class="hljs-literal">Err</span>(ParseError);
            }
        }

        <span class="hljs-keyword">self</span>.read_position = <span class="hljs-keyword">self</span>.read_position + offset;
        <span class="hljs-keyword">self</span>.position = <span class="hljs-keyword">self</span>.read_position;
        <span class="hljs-keyword">self</span>.read_token();
    }

    <span class="hljs-literal">Ok</span>(document)
}
</code></pre>
<p>Ok, testing it...</p>
<pre><code class="lang-rust"><span class="hljs-meta">#[test]</span>
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">test_parse_note</span></span>() {
    <span class="hljs-keyword">let</span> case = <span class="hljs-string">"#tag/tag1 this is a note hahaha. #tag1/tag22"</span>
    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> parser = Parser::new(case.chars().collect());
    <span class="hljs-keyword">let</span> document = parser.parse_documment().unwrap();
    <span class="hljs-built_in">println!</span>(<span class="hljs-string">"{:?}"</span>, document);
}
</code></pre>
<p>Result:</p>
<pre><code class="lang-plaintext">Document { id: "", name: "this is a note hahaha.", craete_time: 0, tags: [Tag { id: "tag/tag1", parent: "", icon: "" }, Tag { id: "tag1/tag22", parent: "", icon: "" }] }
</code></pre>
<p>finished the task successfully.🏄‍♀️</p>
]]></content:encoded></item><item><title><![CDATA[Why should important things be done first?🤔]]></title><description><![CDATA[There are several reasons why important tasks should be prioritized and done first:

Time management: By tackling important tasks first, you can ensure that you have enough time to complete them before moving on to other tasks that may not be as urge...]]></description><link>https://levene.me/why-should-important-things-be-done-first</link><guid isPermaLink="true">https://levene.me/why-should-important-things-be-done-first</guid><category><![CDATA[todo]]></category><category><![CDATA[weedone]]></category><dc:creator><![CDATA[levene]]></dc:creator><pubDate>Thu, 09 Feb 2023 05:55:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/G1lkLnq-OV8/upload/34af6060523fde54ae9cd657ac254390.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There are several reasons why important tasks should be prioritized and done first:</p>
<ol>
<li><p>Time management: By tackling important tasks first, you can ensure that you have enough time to complete them before moving on to other tasks that may not be as urgent.</p>
</li>
<li><p>Increased productivity: Focusing on the most important tasks first can help you achieve your goals more efficiently and effectively.</p>
</li>
<li><p>Stress reduction: Doing important tasks first can reduce stress and anxiety, as you will have a sense of accomplishment and be able to cross items off your to-do list.</p>
</li>
<li><p>Improved focus: Starting with important tasks helps you maintain focus and concentration, making it easier to complete the task at hand.</p>
</li>
<li><p>Better results: By focusing on the most important tasks, you are more likely to produce higher quality work and achieve better results.</p>
</li>
<li><p>Increased motivation: Completing important tasks can provide a sense of satisfaction and boost your motivation to keep working towards your goals.</p>
</li>
<li><p>Avoid procrastination: By doing important tasks first, you reduce the chance of procrastination and avoid the negative effects that come with it, such as increased stress and decreased productivity.</p>
</li>
<li><p>Better planning: Prioritizing important tasks helps you plan your day or week more effectively, ensuring that you are using your time and resources in the most efficient manner possible.</p>
</li>
<li><p>Improved time management: By doing important tasks first, you are more likely to finish your work within the given time frame, reducing the chances of having to stay late or work on weekends.</p>
</li>
<li><p>By prioritizing important tasks and doing them first, you can improve your productivity, focus, and overall success in both your personal and professional life.</p>
</li>
</ol>
<p>Overall, prioritizing important tasks and doing them first can help you be more productive, reduce stress, and achieve your goals more efficiently.</p>
]]></content:encoded></item></channel></rss>