<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Programming on Blogarious</title>
    <link>https://blogarious.kairopath.net/categories/programming/</link>
    <description>Recent content in Programming on Blogarious</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 30 Sep 2018 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blogarious.kairopath.net/categories/programming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Rename files according to date</title>
      <link>https://blogarious.kairopath.net/posts/2018-09-30-rename-files-according-to-date/</link>
      <pubDate>Sun, 30 Sep 2018 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2018-09-30-rename-files-according-to-date/</guid>
      <description>&lt;p&gt;I recently wrote a Perl script, that renames the files in a directory according to the date, in the format &amp;ldquo;YYYYMMDD ##&amp;rdquo; where &amp;ldquo;##&amp;rdquo; is the running number.&lt;/p&gt;&#xA;&lt;h2 id=&#34;rationale&#34;&gt;Rationale&lt;/h2&gt;&#xA;&lt;p&gt;Because I used to download the photos using the mobile apps like Weibo or Twitter, however the file names are almost random. This made me hard to organize these photos on my computer.&lt;/p&gt;&#xA;&lt;p&gt;The artists (or celebrities) usually share a set of their photos, so when I download these photos, the files should have &lt;code&gt;mtime&lt;/code&gt; (modified time) in the correct order.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Inheritance and composition</title>
      <link>https://blogarious.kairopath.net/posts/2018-06-28-inheritance-and-composition/</link>
      <pubDate>Thu, 28 Jun 2018 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2018-06-28-inheritance-and-composition/</guid>
      <description>&lt;p&gt;The modern JavaScript with the ES6 syntax and the rise of the popularity like ReactJS, functional programming becomes more and more common. When using React, one of the common practice is to use &lt;a href=&#34;https://reactjs.org/docs/composition-vs-inheritance.html&#34;&gt;composition instead of inheritance&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Because I started learning programming when the OOP was the most prevailing paradigm, I was trained to solve the problem by using OOP concepts like polymorphoism, inheritance, encapsulation, etc.&lt;/p&gt;&#xA;&lt;p&gt;I think JS is the most interesting programming language in the modern technology. It supports server-side and client-side development. With the ES6, it supports OOP keywords like &lt;strong&gt;class&lt;/strong&gt; and also using FP (functional programming) syntax like &lt;strong&gt;fat arrow&lt;/strong&gt; (=&amp;gt;).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Coin Flip Conundrum</title>
      <link>https://blogarious.kairopath.net/posts/2018-03-14-coin-flip-conundrum/</link>
      <pubDate>Wed, 14 Mar 2018 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2018-03-14-coin-flip-conundrum/</guid>
      <description>&lt;p&gt;I watched this video,&lt;/p&gt;&#xA;&lt;p&gt;[youtube &lt;a href=&#34;https://www.youtube.com/watch?v=IAiNqQi30-Y&#34;&gt;https://www.youtube.com/watch?v=IAiNqQi30-Y&lt;/a&gt;]&lt;/p&gt;&#xA;&lt;p&gt;Very interesting.&lt;/p&gt;&#xA;&lt;p&gt;So, I managed to prove it through some scripting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://gist.github.com/allencch/36544a84fdb8159756618290209f1750&#34;&gt;https://gist.github.com/allencch/36544a84fdb8159756618290209f1750&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And I get some result like this,&lt;/p&gt;&#xA;&lt;p&gt;[code lang=text] Result: Target: [0, 1] average steps = 3.987 Target: [0, 0] average steps = 5.9505 [/code]&lt;/p&gt;&#xA;&lt;p&gt;P/S: Wrote a robust flip coin script, which can accept the coin tossing sequence with any length. [&lt;a href=&#34;https://gist.github.com/allencch/c71332637c3e9265675b2d5c4f2cfe7e&#34;&gt;here&lt;/a&gt;]&lt;/p&gt;</description>
    </item>
    <item>
      <title>C&#43;&#43; future</title>
      <link>https://blogarious.kairopath.net/posts/2017-08-05-c-future/</link>
      <pubDate>Sat, 05 Aug 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-08-05-c-future/</guid>
      <description>&lt;p&gt;Recently updating my hobby project &lt;a href=&#34;https://github.com/allencch/med&#34;&gt;Med&lt;/a&gt;, memory editor for Linux, still under heavy development with various bugs.&lt;/p&gt;&#xA;&lt;p&gt;In this project, I use several C++1x features (compiled with C++14 standard). Most recent notable feature is multi-threading scanning. In memory scanning, scan through the accessible memory blocks sequentially is slow. Therefore, I need to scan the memory blocks in parallel. To implement this, I have to create multiple threads to scan through the memory blocks.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PHP programming</title>
      <link>https://blogarious.kairopath.net/posts/2017-07-16-php-programming/</link>
      <pubDate>Sun, 16 Jul 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-07-16-php-programming/</guid>
      <description>&lt;p&gt;PHP was a great programming language in web development. It surpasses the VBscript for ASP and Perl for CGI. It is favoured because of the syntax based C and C++. It supports procedural programming paradigm and object-oriented paradigm. A lot of functions resemble C functions such as printf, fprintf, sprintf, fopen, etc. Similarly, it can work directly to the C library such as expat, zlib, libxml2, etc. A lot of great content management systems (CMS) are written in PHP, such as Drupal, Wordpress, Joomla, etc.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Closure</title>
      <link>https://blogarious.kairopath.net/posts/2017-07-12-__trashed/</link>
      <pubDate>Wed, 12 Jul 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-07-12-__trashed/</guid>
      <description>&lt;p&gt;In JavaScript, we can create closure like this,&lt;/p&gt;&#xA;&lt;p&gt;[code language=&amp;ldquo;javascript&amp;rdquo;] var foo = (() =&amp;gt; { let x = 0; return () =&amp;gt; { return x++; } })();&lt;/p&gt;&#xA;&lt;p&gt;for (var i = 0; i &amp;lt; 10; i++) { var x = foo(); console.log(x); } [/code]&lt;/p&gt;&#xA;&lt;p&gt;But translating above code into C++, it cannot work as expected for the variable, unless the variable is outside the lambda function.&lt;/p&gt;&#xA;&lt;p&gt;[code language=&amp;ldquo;cpp&amp;rdquo;] // In a function int x; // variable here auto foo = [&amp;amp;x]() { x = 0; return [&amp;amp;x]() { return x++; }; }(); for (int i = 0; i &amp;lt; 10; i++) { int x = foo(); cout &amp;laquo; x &amp;laquo; endl; } [/code]&lt;/p&gt;</description>
    </item>
    <item>
      <title>CSV to something</title>
      <link>https://blogarious.kairopath.net/posts/2017-06-30-csv-to-something/</link>
      <pubDate>Fri, 30 Jun 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-06-30-csv-to-something/</guid>
      <description>&lt;p&gt;Just revived my old script into a project in GitHub, &lt;a href=&#34;https://github.com/allencch/csv_to_something&#34;&gt;csv_to_something&lt;/a&gt;. An old simple script that was created to manage some student data. Because the students data were collected through Google Forms, so I convert it to CSV, then from CSV to SQLite. So that I can use the SQL to query whatever data I need.&lt;/p&gt;&#xA;&lt;p&gt;Using SQLite software such as &lt;a href=&#34;https://sourceforge.net/projects/sqliteman/&#34;&gt;sqliteman&lt;/a&gt; and &lt;a href=&#34;http://sqlitebrowser.org/&#34;&gt;sqlitebrowser&lt;/a&gt;, I can create any new table, grouping, sorting etc.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Coding and cognitive functions</title>
      <link>https://blogarious.kairopath.net/posts/2017-04-22-coding-and-cognitive-functions/</link>
      <pubDate>Sat, 22 Apr 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-04-22-coding-and-cognitive-functions/</guid>
      <description>&lt;p&gt;When I was doing programming as a hobbyist, I thought that writing source code is to communicate to the computer. Then lately working as software developer, I realised that coding is not just communicating to the computer, it is also communicating with other software developers.&lt;/p&gt;&#xA;&lt;p&gt;When we are working on a big project, working alone is impractical. Then we need to work as a team. Consequently, our coding style needs to be conformed to ease the code review. Because at the end, the code is belong to the team, not an individual. That is why, practicing &amp;ldquo;&lt;strong&gt;clean code&lt;/strong&gt;&amp;rdquo; is very important.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A brief comparison of GTK&#43; and Qt</title>
      <link>https://blogarious.kairopath.net/posts/2017-01-17-a-brief-comparison-of-gtk-and-qt/</link>
      <pubDate>Tue, 17 Jan 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-01-17-a-brief-comparison-of-gtk-and-qt/</guid>
      <description>&lt;p&gt;I used to like C language, because it is a basic of programming, and it is portable, and it is low-level. When writing program with C language, it is just like showing off your advanced programming skill, how you manage the memory, how you manage the pointers and creating the linked list. However, in terms of efficiency, C++ is much more powerful, because of object-oriented and the syntax.&lt;/p&gt;&#xA;&lt;p&gt;Because I like C language, so I chose GTK+ over Qt for long time ago. Not only that, I am also fond of GTK+ desktop environments like GNOME, Xfce4, LXDE, Cinnamon, but not Mate. I feel that KDE is heavy weight.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Heading, anchor, and bookmarking</title>
      <link>https://blogarious.kairopath.net/posts/2017-01-08-heading-anchor-and-bookmarking/</link>
      <pubDate>Sun, 08 Jan 2017 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2017-01-08-heading-anchor-and-bookmarking/</guid>
      <description>&lt;p&gt;Sometimes I read online articles, and these articles are usually long pages and have outlines at the beginning. These outlines are the hyperlinks to the subtopics headings. Technically, you click the outline hyperlink, your browser will browse to the &amp;ldquo;anchor&amp;rdquo;, the URL will append with hash (#). Therefore, it is useful for bookmarking, so that you can share the URL target on the topic to someone else, or re-visit your bookmark.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Lecturer, researcher, hobbyist, and software developer</title>
      <link>https://blogarious.kairopath.net/posts/2016-12-09-lecturer-researcher-hobbyist-and-software-developer/</link>
      <pubDate>Fri, 09 Dec 2016 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2016-12-09-lecturer-researcher-hobbyist-and-software-developer/</guid>
      <description>&lt;p&gt;I am cognitive science student. That is why I learnt AI, computational linguistic, machine learning, expert system, etc. &lt;/p&gt;&#xA;&lt;p&gt;Since I was a researcher on Augmented Reality, then I applied my computing skills. After this, I became a non-computer related lecturer, and spent my time doing programming as a hobbyist. Then later I became computer science lecturer, yet still had to do programming as a hobbyist. Now as a software developer, I know what are the differences of these roles: lecturer, researcher, hobbyist, and a true software developer. &lt;/p&gt;</description>
    </item>
    <item>
      <title>C&#43;&#43; revisit</title>
      <link>https://blogarious.kairopath.net/posts/2016-08-19-c-revisit/</link>
      <pubDate>Fri, 19 Aug 2016 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2016-08-19-c-revisit/</guid>
      <description>&lt;p&gt;I liked C programming, as it is low level and the compiler is widely available. Using C language can demonstrate the understanding of pointer and memory. You can implement a linked list or a hash table by using C. So that you can understand better how the linked list and hash table work.&lt;/p&gt;&#xA;&lt;p&gt;But as long as you want to build some end user applications, C language is never a good choice. Choosing a language for our product is important. We do not develop a web application using low level programming language. It is totally impractical.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Vim</title>
      <link>https://blogarious.kairopath.net/posts/2016-06-18-vim/</link>
      <pubDate>Sat, 18 Jun 2016 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2016-06-18-vim/</guid>
      <description>&lt;p&gt;Because of the new working environment, I cannot use my favourite customised Emacs to work. So, I have to adapt with the new text editor. Luckily, &lt;strong&gt;vim&lt;/strong&gt; is available in the remote server. That means I can use SSH to run the vim. And, even Emacs is available, I feel difficult to customise and install the packages I need, because I don&amp;rsquo;t have experience installing Emacs&amp;rsquo; packages using text-based UI. (But if it is available, I may make a try.)&lt;/p&gt;</description>
    </item>
    <item>
      <title>Multilingual programming</title>
      <link>https://blogarious.kairopath.net/posts/2016-04-21-multilingual-programming/</link>
      <pubDate>Thu, 21 Apr 2016 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2016-04-21-multilingual-programming/</guid>
      <description>&lt;p&gt;Recently I involve in various projects. And they are using different technologies. I am fervent in programming because it conforms to my theological and philosophical perspective.&lt;/p&gt;&#xA;&lt;p&gt;The languages and technology I am currently using: AngularJS and NodeJS, .NET MVC with C# Mono, and Ruby on Rails. Other related technologies: Nginx, AWS, migrations, Bootstrap CSS, etc. Besides that, my background is strong fundamental C, C++, and PHP skills; have good experience on Python; some experiences on Java, Android, Perl, and VB Script.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unit testing and TDD</title>
      <link>https://blogarious.kairopath.net/posts/2016-04-04-unit-testing-and-tdd/</link>
      <pubDate>Mon, 04 Apr 2016 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2016-04-04-unit-testing-and-tdd/</guid>
      <description>&lt;ol&gt;&#xA;&lt;li&gt;I was thinking, WT* is the unit test?&lt;/li&gt;&#xA;&lt;li&gt;Why should I need unit test?&lt;/li&gt;&#xA;&lt;li&gt;Why should I spend my time to prepare the test cases?&lt;/li&gt;&#xA;&lt;li&gt;Why should I spend my time to become a tester instead of a developer?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;For the first question, if searching online, what you get are just bunch of almost useless information. They can let you get high score in exam.&lt;/p&gt;&#xA;&lt;p&gt;For the second question, instead of answering why, I will say, it depends. It depends on the language you are using and the framework that you are using. Let&amp;rsquo;s say you are working on C programming, there is less support of unit testing library. If you are working on Linux kernel development, unit test is difficult to implement. But, if you are developing web application, then unit testing and other testings are highly recommended. Why? Let me go to the next two answers beforehand.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Best ever programmer text editor: Emacs</title>
      <link>https://blogarious.kairopath.net/posts/2016-01-24-best-ever-programmer-text-editor-emacs/</link>
      <pubDate>Sun, 24 Jan 2016 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2016-01-24-best-ever-programmer-text-editor-emacs/</guid>
      <description>&lt;p&gt;I was using jEdit. And once willing to change to, so called modern text editor, Atom Text Editor. Then I did some comparisons among the text editors. At the end, now my primary text editor for coding is Emacs.&lt;/p&gt;&#xA;&lt;p&gt;Emacs requires some time to learn and practise. But at the end, I love it too much. It is so powerful, no other text editor to compare with it. But the primary usage is for coding.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Data structure and algorithm</title>
      <link>https://blogarious.kairopath.net/posts/2015-12-16-data-structure-and-algorithm/</link>
      <pubDate>Wed, 16 Dec 2015 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2015-12-16-data-structure-and-algorithm/</guid>
      <description>&lt;p&gt;As a computer science lecturer (though I am from &lt;a href=&#34;https://en.wikipedia.org/wiki/Cognitive_science&#34;&gt;cognitive science&lt;/a&gt; background, and even labelled as NOT from computer science, 士可杀，不可辱！), I focus on the fundamental knowledge and experience. I focus on C/C++ language on my students, because only have good fundamental knowledge and skills, then they can survive with the evolving technology once they graduated. For example, Flash was popular technology, yet now it is dying. Those who know Flash only, have to learn new technology. Without fundamental skill, how to cope with the new technologies that emerge everyday? &lt;strong&gt;Know the root, then you can get any leaf&lt;/strong&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tab vs space</title>
      <link>https://blogarious.kairopath.net/posts/2015-11-23-tab-vs-space/</link>
      <pubDate>Mon, 23 Nov 2015 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2015-11-23-tab-vs-space/</guid>
      <description>&lt;p&gt;I was using tab for indentation in coding, instead of spaces. Because I feel that one byte of tab is better than four bytes of space. It produces smaller file size.&lt;/p&gt;&#xA;&lt;p&gt;However, the problems become prominent in the following circumstances.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Viewing different languages may require different indentation width. XML and HTML may use 2 characters width, other languages may use 4 characters width. Changing the tab width from the setting frequently is inconvenient.&lt;/li&gt;&#xA;&lt;li&gt;Editing source code with different developers and using different text editors will produce source code with both tab and space indentation. As a result, the indentation becomes inconsistent.&lt;/li&gt;&#xA;&lt;li&gt;Emacs problem. If the Emacs tab width is set to 8 characters, but the source code indentation is 4, this produces both tab and space indentation at the same line, for example, 3 indents (12 characters width) produce 1 tab with 4 spaces. Oh dear, I always show the whitespace and tab marks in the editor. The ugliness disturbs me.&lt;/li&gt;&#xA;&lt;li&gt;Git diff view. If using Git GUI, it will highlight the tab indentation when the pervious line is a space indentation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So, in the cases above, space indentation becomes handy. Though different developers use different text editor may produce different width of space indentation, with space indentation will produce better output than tab indentation.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Statistics and functional programming languages</title>
      <link>https://blogarious.kairopath.net/posts/2015-11-12-statistics-and-functional-programming-languages/</link>
      <pubDate>Thu, 12 Nov 2015 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2015-11-12-statistics-and-functional-programming-languages/</guid>
      <description>&lt;p&gt;Recently, I feel fervent to learn functional programming, because i) (in my opinion), it will become a trend, and ii) the interpreter can be used as an advanced calculator.&lt;/p&gt;&#xA;&lt;p&gt;Since I am teaching Statistics, I want to do some calculation of the normal distribution probability.&lt;/p&gt;&#xA;&lt;p&gt;Before I begin, I need to mention, in order to calculate the normal distribution probability something like P(x &amp;lt; X), this can be done by using a spreadsheet software with NORMDIST() and NORM.INV() for the inverse of the former function.&lt;/p&gt;</description>
    </item>
    <item>
      <title>JavaScript</title>
      <link>https://blogarious.kairopath.net/posts/2015-10-11-javascript/</link>
      <pubDate>Sun, 11 Oct 2015 00:00:00 +0000</pubDate>
      <guid>https://blogarious.kairopath.net/posts/2015-10-11-javascript/</guid>
      <description>&lt;p&gt;Previously I read an &lt;a href=&#34;http://www.linuxjournal.com/content/javascript-all-way-down?page=0,0&#34;&gt;article&lt;/a&gt; regarding JavaScript and &lt;a href=&#34;https://www.tbray.org/ongoing/When/201x/2015/06/05/End-of-HTML&#34;&gt;another&lt;/a&gt; one regarding HTML.&lt;/p&gt;&#xA;&lt;p&gt;JavaScript, it is so wonderful that not only enhances the HTML interaction, (e.g. jQuery), it also makes a revolution of the system architecture design (e.g. AngularJS, ReactJS with Babel). The Babel JavaScript compiler is so amazing that it can transform the JavaScript to EcmaScript 6 with JSX feature. JSX is actually cannot be interpreted by our current web browser, but with the Babel, it makes JSX possible.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
