<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Morris on 300.Watts</title><link>https://300watts.me/authors/morris/</link><description>Recent content in Morris on 300.Watts</description><generator>Hugo</generator><language>en</language><managingEditor>morristai01@gmail.com (Morris)</managingEditor><webMaster>morristai01@gmail.com (Morris)</webMaster><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Sun, 10 Mar 2024 10:04:55 +0800</lastBuildDate><atom:link href="https://300watts.me/authors/morris/index.xml" rel="self" type="application/rss+xml"/><item><title>Async in Traits Just Save Us</title><link>https://300watts.me/posts/async-in-traits-just-save-us/</link><pubDate>Sun, 10 Mar 2024 10:04:55 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/async-in-traits-just-save-us/</guid><description>&lt;h2 id="the-challenge-of-implementing-the-future-trait-for-custom-types" class="headerLink"&gt;
 &lt;a href="#the-challenge-of-implementing-the-future-trait-for-custom-types" class="header-mark"&gt;&lt;/a&gt;The Challenge of Implementing the Future Trait for Custom Types&lt;/h2&gt;&lt;p&gt;Developers who venture into crafting their own &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt; implementations in Rust may encounter the intricate task of implementing the &lt;code&gt;Future&lt;/code&gt; trait for their custom types. Rust&amp;rsquo;s approach to &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt; is nuanced, offering a stark contrast to languages like Go, which employ preemptive scheduling. Instead, Rust embraces lazy evaluation and cooperative scheduling, allowing developers to meticulously control the yield points to the executor.
This level of control, however, introduces complexity in implementing the &lt;code&gt;Future&lt;/code&gt; trait for custom types. The intricacies arise because &lt;code&gt;.await&lt;/code&gt; can&amp;rsquo;t be invoked within a &lt;strong&gt;non-async&lt;/strong&gt; function, necessitating the development of a state machine (or similar) for these custom types. This endeavor can be laborious and fraught with potential errors, difficult to maintain, and may prompt developers to opt for &lt;code&gt;BoxFuture&amp;lt;T&amp;gt;&lt;/code&gt;, a choice that could compromise performance.&lt;/p&gt;</description></item><item><title>Rust Profiling Essentials with perf</title><link>https://300watts.me/posts/rust-profiling-essentials-with-perf/</link><pubDate>Mon, 09 Oct 2023 10:04:55 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/rust-profiling-essentials-with-perf/</guid><description>&lt;h2 id="what-is-profiling" class="headerLink"&gt;
 &lt;a href="#what-is-profiling" class="header-mark"&gt;&lt;/a&gt;What is profiling?&lt;/h2&gt;&lt;blockquote&gt;
 &lt;p&gt;A: &lt;strong&gt;Sampling&lt;/strong&gt; the program &lt;strong&gt;at specific times&lt;/strong&gt;, and do some statistics analysis.&lt;/p&gt;

&lt;/blockquote&gt;&lt;p&gt;It can be one of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reading Backtraces&lt;/strong&gt; of the program for every 1000th cycles, and represent in ﬂamegraph.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reading Backtraces&lt;/strong&gt; of the program for every 1000th cache miss, and represent in ﬂamegraph.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reading Backtraces&lt;/strong&gt; of the program for every 10th memory allocation, and represent in ﬂamegraph.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Get return address&lt;/strong&gt; of the program for every 10th memory allocation, and show counts for every line.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="how-to-trigger-a-sample" class="headerLink"&gt;
 &lt;a href="#how-to-trigger-a-sample" class="header-mark"&gt;&lt;/a&gt;How to trigger a sample?&lt;/h2&gt;&lt;p&gt;Kind of triggers:&lt;/p&gt;</description></item><item><title>Serverless with Rust and Protocol Buffers</title><link>https://300watts.me/posts/serverless-with-rust-and-protocol-buffers/</link><pubDate>Wed, 08 Mar 2023 19:43:00 +0000</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/serverless-with-rust-and-protocol-buffers/</guid><description>&lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.2/dist/katex.min.css" integrity="sha384-bYdxxUwYipFNohQlHt0bjN/LCpueqWz13HufFEV1SUatKs1cm4L6fFgCi1jT643X" crossorigin="anonymous"&gt;
&lt;p&gt;I&amp;rsquo;ve recently been working on rewriting our small service with Rust for fun. One reason is to see if Rust, as a system programming language, is ready for cloud development in 2023. Another reason is that I wonder how much better it is compared to Python or Java in major cloud and data computing.&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;💡 There is a lot of discussion over which language to use as a serverless service. In my point of view, dynamic languages like Python lack compile-time checks, which can cause more runtime errors than static languages like Rust or Java.&lt;br&gt;
Another reason is that Python and Java need a runtime process (JVM, CPython) to run your actual code, which means they can&amp;rsquo;t run natively like compiled Rust does. However, I&amp;rsquo;m not sure about the performance gap. Furthermore, Rust doesn&amp;rsquo;t require garbage collection, so ideally, a program&amp;rsquo;s heap size should fluctuate less than a garbage-collected language when running. That means Lambda or Function underlying infrastructure controller should be able to handle invocation or scaling more easily.&lt;br&gt;
In terms of language paradigms, in my opinion, compared to traditional OOP, the modern &lt;a href="https://en.wikipedia.org/wiki/ML_%2528programming_language%2529" target="_blank" rel="noopener noreferrer"&gt;ML (meta-language) family&lt;/a&gt; has a better design for scalable cloud services.&lt;/p&gt;</description></item><item><title>Make Kafka Schema Easier</title><link>https://300watts.me/posts/make-kafka-schema-easier/</link><pubDate>Wed, 26 Jan 2022 10:04:55 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/make-kafka-schema-easier/</guid><description>&lt;p&gt;TL;DR: You can find the script on my GitHub repository: &lt;a href="https://github.com/morristai/kschema-table" target="_blank" rel="noopener noreferrer"&gt;kschema-table&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="coordinating-schema-with-data-scientist" class="headerLink"&gt;
 &lt;a href="#coordinating-schema-with-data-scientist" class="header-mark"&gt;&lt;/a&gt;Coordinating schema with Data Scientist&lt;/h2&gt;&lt;p&gt;As a data engineer, you&amp;rsquo;ll need to collaborate closely with data scientists/domain experts to design data schemas. The optimal schema will depend heavily on the business domain and how the product is used. For instance, in a cybersecurity context, threat experts and data scientists would likely be the ones designing the data schema. They may work with infrastructure and data teams to define these schemas in a common format like, for example: Avro IDL (Avro Interface Description Language).&lt;/p&gt;</description></item><item><title>SSH Tunneling Summary</title><link>https://300watts.me/posts/ssh-tunneling-summary/</link><pubDate>Thu, 10 Dec 2020 10:04:55 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/ssh-tunneling-summary/</guid><description>&lt;p&gt;There are three types of SSH port forwarding:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="#local-port-forwarding" rel=""&gt;Local Port Forwarding&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Forwards a connection from the client host to the SSH server host and then to the destination host port.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="#remote-port-forwarding" rel=""&gt;Remote Port Forwarding&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Forwards a port from the server host to the client host and then to the destination host port.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="#dynamic-port-forwarding" rel=""&gt;Dynamic Port Forwarding&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Creates a SOCKS proxy server that allows communication across a range of ports.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="roles" class="headerLink"&gt;
 &lt;a href="#roles" class="header-mark"&gt;&lt;/a&gt;Roles&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Client&lt;/strong&gt;: Any machine where you can &lt;code&gt;ssh&lt;/code&gt; to enable Port Forwarding&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SSH Server&lt;/strong&gt;: A machine that can be SSHed into by &lt;strong&gt;Client&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target Server&lt;/strong&gt;: A machine to which you want to establish a connection, usually to open services on this machine to the outside world.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt;: both &lt;strong&gt;Client&lt;/strong&gt; and &lt;strong&gt;SSH Server&lt;/strong&gt; can be &lt;strong&gt;Target Server&lt;/strong&gt;, it doesn&amp;rsquo;t really need three machines to perform Port Forwarding! However, Dynamic Port Forwarding will not be only one Target Server, but it can be dynamically determined.&lt;/p&gt;</description></item><item><title>Practicing bisect in Go</title><link>https://300watts.me/posts/practicing-bisect-in-go/</link><pubDate>Tue, 05 May 2020 11:46:56 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/practicing-bisect-in-go/</guid><description>&lt;p&gt;In Python, we are used to using &lt;code&gt;bisect&lt;/code&gt; to search for elements in the List. In Go, &lt;code&gt;sort.Search()&lt;/code&gt; can also provide us with the same purpose.
As in Python, the target array is sorted before searching.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;Ints&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;After sorting, we use sort.Search(), the first parameter is the search target, and the second is the function of the search condition.
Here we input slice: [1 2 3 4 5 5 6 9], find the 5 closest to the left, and the program returns the index 4.&lt;/p&gt;</description></item><item><title>How to mail the movie list from the remote host</title><link>https://300watts.me/posts/how-to-mail-the-movie-list-from-the-remote-host/</link><pubDate>Fri, 10 Jan 2020 17:04:55 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/how-to-mail-the-movie-list-from-the-remote-host/</guid><description>&lt;p&gt;Sometimes I upload videos for my family but don’t know if they already exist on the computer. At this time, I can think of a way to automatically email the titles of the videos already in the video library to myself for reference on a regular basis.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;span class="lnt"&gt;16
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-zsh" data-lang="zsh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;~/Downloads
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;➤ cat 2021-12-03-movie_list.txt -r :10
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;───────┬────────────────────────────────────────────────────────────────────────────────────────────────
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │ File: 2021-12-03-movie_list.txt
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;───────┼────────────────────────────────────────────────────────────────────────────────────────────────
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;1&lt;/span&gt; │ 2021-12-03 Movie List
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;2&lt;/span&gt; │
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;3&lt;/span&gt; │ CreationTime Name
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;4&lt;/span&gt; │ ------------ ----
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;5&lt;/span&gt; │ 2021/11/13 下午 05:03:45 紅色通緝令
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;6&lt;/span&gt; │ 2021/11/12 下午 04:03:19 高玩殺手
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;7&lt;/span&gt; │ 2021/11/12 下午 04:03:17 007生死交戰
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;8&lt;/span&gt; │ 2021/11/12 下午 03:57:13 芬奇的旅程
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;9&lt;/span&gt; │ 2021/11/12 下午 03:46:12 沙丘
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="m"&gt;10&lt;/span&gt; │ 2021/9/21 下午 03:28:33 最佳销售员
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;───────┴────────────────────────────────────────────────────────────────────────────────────────────────&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="gmail-low-security-settings-must-be-turned-on" class="headerLink"&gt;
 &lt;a href="#gmail-low-security-settings-must-be-turned-on" class="header-mark"&gt;&lt;/a&gt;Gmail low security settings must be turned on&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://myaccount.google.com/" target="_blank" rel="noopener noreferrer"&gt;Account Settings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Security&lt;/code&gt; in the list on the left.&lt;/li&gt;
&lt;li&gt;At the bottom of the low security restriction click &lt;code&gt;Turn on access&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In this way, emails can be sent through the &lt;code&gt;smtp.gmail.com&lt;/code&gt; api.&lt;/p&gt;</description></item><item><title>Common Python and C++11 usage comparison</title><link>https://300watts.me/posts/common-python-and-c-11-usage-comparison/</link><pubDate>Sun, 12 May 2019 11:46:56 +0800</pubDate><author>morristai01@gmail.com (Morris)</author><guid>https://300watts.me/posts/common-python-and-c-11-usage-comparison/</guid><description>&lt;p&gt;&lt;a href="https://gist.github.com/morristai/7c7c42c128177e8f4110cffa97e8fb7f" target="_blank" rel="noopener noreferrer"&gt;My Gist&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="define-variables" class="headerLink"&gt;
 &lt;a href="#define-variables" class="header-mark"&gt;&lt;/a&gt;Define Variables&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Python
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;xxx&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;C++
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;span class="lnt"&gt;5
&lt;/span&gt;&lt;span class="lnt"&gt;6
&lt;/span&gt;&lt;span class="lnt"&gt;7
&lt;/span&gt;&lt;span class="lnt"&gt;8
&lt;/span&gt;&lt;span class="lnt"&gt;9
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;xxx&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// C string (char array)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;xxx&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// C string (pointer)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&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;string&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;xxx&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;xxx&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;xxx&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="variable-scopes" class="headerLink"&gt;
 &lt;a href="#variable-scopes" class="header-mark"&gt;&lt;/a&gt;Variable Scopes&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Python
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;global_var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arg&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;local_var&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;global_var2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;global_var2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;xxx&amp;#39;&lt;/span&gt; &lt;span class="c1"&gt;# global&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;arg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;local_var2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="c1"&gt;# scope: function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# if arg evaluates to True,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# local_var2 is still accessible here.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/p&gt;</description></item></channel></rss>