PHP programming
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.
Closure
In JavaScript, we can create closure like this,
[code language=“javascript”] var foo = (() => { let x = 0; return () => { return x++; } })();
for (var i = 0; i < 10; i++) { var x = foo(); console.log(x); } [/code]
But translating above code into C++, it cannot work as expected for the variable, unless the variable is outside the lambda function.
[code language=“cpp”] // In a function int x; // variable here auto foo = [&x]() { x = 0; return [&x]() { return x++; }; }(); for (int i = 0; i < 10; i++) { int x = foo(); cout « x « endl; } [/code]
Prayer Clock GTK3
My first open source project, Prayer Clock, I moved from SourceForge to GitHub recently. Yeah! Everyone should git!!!
And today I just made some changes, and updated to GTK3.
[gallery ids=“1757,1758” type=“rectangular”]
With GTK 3, I removed the title bar. But not yet successfully moving the menu bar to the icon like Evince or Nautilus.
I plan to convert the right hand panel to WebKitGtk. But this will not be the priority yet.
CSV to something
Just revived my old script into a project in GitHub, csv_to_something. 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.
Using SQLite software such as sqliteman and sqlitebrowser, I can create any new table, grouping, sorting etc.
Monty Hall problem and frog riddle
Monty Hall paradox
Probability topic is the fundamental concept of the statistics. And machine learning is closely related to statistics. That is why, understand the probability very important if you are doing research, statistics, and machine learning.
Monty Hall is a very interesting problem. It says, if you are given 3 doors to choose. One of them contains a car (which you want), the other two are goats (which you don’t want). After you made your choice, before opening the door, the host will open the door that you didn’t choose yet contains the goat (he knows which door has the goat). Now, if you are given an opportunity to change your choice to another door (which you didn’t choose earlier), are you going to change?
Switching display/monitor/screen in Linux
Because I am using the Openbox (window manager), and I believe that the laptop Fn+F8 (or whatever combination with Fn) doesn’t work properly on Linux. Because the combination is detected as Super+p (aka Win+p). As a result, I wrote a Perl script to solve the switching display/monitor/screen issue on my laptop.
[code language=“perl”] #!/usr/bin/perl
# This script requires xrandr, and several bash script created by arandr
use strict; use warnings;
ROC, AUC, WTF?
These few days I was spending my whole time to understand this ROC (receiver operating characteristic) curve. In machine learning, ROC is a very common way to evaluate the prediction performance. The AUC (area under curve) of ROC indicates the accuracy of prediction of a classifier.
If you wish to learn more, these two links are the best resources: here and here.
I searched through tutorial and Q and A sites on how to do the plot of ROC and calculating the AUC. The answers were telling me about “cut-off”, “threshold”, or some weird terms. And some answers were telling me to use R package to plot the graph. WTF? I know all of these things. My question was, “How can I plot ROC curve with my classifier?!”
AAC file re-visit
In my previous post, I mentioned about AAC and the ID3 tag. And I mentoined that
I have an AAC audio file (technically M4A) […]
I used Audacious previously, then change to DeadBeef. The main reason I changed was because I kept failing to play AAC audio file. What’s wrong? FFplay can play it, SMPlayer can play it, DeadBeef can play it, Clementine can play it, but Audacious cannot. Audacious has a AAC plugin, it should support AAC format.
Coding and cognitive functions
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.
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 “clean code” is very important.
AAC audio file and ID3 tag
I just found that, if I have an AAC audio file (technically M4A), and if I added the ID3 tag 2 (aka ID3v2), then the audio file will failed to be converted by ffmpeg.
It can be either converted to mp3
- using DeadBeef audio player, or
- remove the ID3v2 tag then convert
So, how to add the metadata like ID3 tag? Use the Kid3 and add the Tag 3 (aka APE tag). This will not affect how ffmpeg to read the file.