tag:blogger.com,1999:blog-59640082019366246792024-03-14T04:09:47.628+07:00An Endless Xploration....to be more human every single day in this hopefully meaningful life...Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.comBlogger221125tag:blogger.com,1999:blog-5964008201936624679.post-53688499677526351092021-09-24T20:49:00.004+07:002021-09-24T20:49:33.648+07:00Gnome Terminal failed to run after upgrading default Python 3 interpreter to Python 3.7 in Ubuntu 18.04Ubuntu 18.04 comes with Python 3.6 by default. You might be inclined to do a sid-by-side installation with Python 3.7 as explained at: https://blog.globaletraining.com/2020/06/09/how-to-upgrade-to-python-3-7-on-ubuntu-18-x/ Then you might try to switch the default Python3 interpreter from Python 3.6 to Python 3.7 by using $ sudo update-alternatives --config python3 . However, this could result inDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-89864891817911271162021-09-12T14:13:00.029+07:002022-01-14T21:53:24.958+07:00Installing TensorRT 7.2.1, cuDNN 8.0.4 and Cuda 11.0 update 1 in Ubuntu 18.04 (x86_64)Make sure you have up-to-date Nvidia display driver. You need v4.50.x or newer for Cuda 11 to work (I'm using v4.70.x). You can update it using standard Ubuntu repository or via Nvidia Ubuntu ppa if it's not yet up-to-date, as explained over at: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux. In my case, I'm using standard Ubuntu repository without Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-35144831049779134312021-09-05T20:33:00.003+07:002021-09-05T20:34:37.787+07:00Fixing Failure to Load Video in OpenCV-Python on LinuxThe failure to load video in OpenCV-Python usually happened with older Linux distributions. In my case, it happened in Ubuntu 18.04. The failure in video loading can be detected in python code similar to this:import cv2..cap = cv2.VideoCapture(video_file_path)if cap.isOpened(): print("Video file loaded successfully") else: print("Failed to load video!") &Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-68020463940067104112021-09-05T19:26:00.002+07:002021-09-05T19:26:38.989+07:00Fixing "RTL8822CE wireless adapter doesn't work" on Ubuntu 18.04 RTL8822CE wifi adapter doesn't work out of the box in Ubuntu 18.04 due to missing firmware, not because the driver is not included in Ubuntu 18.04. The fix requires you to be able to download the required firmware from kernel.org and copying the firmware to your Ubuntu 18.04 firmware directory. To do that, first, you have to make sure the machine have an internet connection before youDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-43768448822187533592021-09-05T19:13:00.004+07:002021-09-05T19:14:36.140+07:00Fixing "ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory" in Ubuntu 18.04 If you're using Nvidia CUDA 10.1.243 in your software development, either directly or indirectly and encountered: "ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory", it's caused by incorrect location of the said library. Nvidia have moved the location of the library form cuda-10.1 direcctory to cuda-10.2 directory. I know, this is rather insane. But Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-87474858438900529092020-09-14T04:57:00.003+07:002020-09-14T04:59:52.912+07:00Fixing: "matplotlib error - no module named tkinter" in Windows 10 If you are using python 3.x in Windows 10 and encoutered this error: "matplotlib error - no module named tkinter", it's very possible that you didn't install the Tcl/Tk module when installing Python to your machine. The tkinter module comes from Tcl/Tk. Fear not, you don't need to uninstall and reinstall Python to fix it. You only need to modify your Python installation to install the missing TclDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-92117835889998810462020-09-07T17:44:00.000+07:002020-09-07T17:44:42.466+07:00Removing "Still" Frames from Video Files with Ffmpeg Ffmpeg is a very versatile tool for video pre-processing and post-processing. One of its most useful feature is removing frames which doesn't have a lot of changes in it, i.e. relatively static background. The parameter to use for this purposes is the mpdecimate flag, the presentation timeframe (setpts)flag might also be used for synchronization purposes. In my case, the command I usedDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-28356377581475911912020-08-23T10:15:00.000+07:002020-08-23T10:15:07.047+07:00Implementing C struct-like Data Structure in Python (Requires Python 3.6+) The solution to implement C struct-like data structure in Python is explained in: https://stackoverflow.com/questions/35988/c-like-structures-in-python. You need the presence of dataclass python class to create a syntactically and semantically similar data structure to C struct. This class is implemented in Python 3.7. Therefore, python 3.7 is the lowest version of python Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-37165644438284934262020-08-23T10:00:00.000+07:002020-08-23T10:00:02.764+07:00Configuring Custom ipython Terminal Color Scheme In some cases ipython default terminal color scheme is not the most readable one, especially when using Powershell in Windows. One of the way to fix the problem is to use custom/non-default color scheme. The steps to accomplish that as follows (tested in ipython v7.17 and python 3.7.9): Run `pygmentize -L styles` in your terminal to check available ipython color styles/schemes. Experiment Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-58640644413308039752020-08-19T06:23:00.000+07:002020-08-19T06:23:32.936+07:00Fixing Visual Studio 2017 "can't find windows.h, stddef.h, string.h" Error The error in the title (in most cases) is caused by differing version between the target of the VS2017 project build settings and the version of Windows SDK installed in the computer used to compile your code. Each version of Windows SDK creates its own directory structure in your computer which made VS2017 IDE points to the wrong path (or in my case non-existent path). My solution to fix Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-35939597237146649372017-12-29T13:32:00.002+07:002017-12-29T13:47:26.023+07:00Storing Python Object in Redis - The "Brute Force" ApproachSometimes we have the need to store Python object (class instance) to "object storage" server for some reason and then to retrieve it later. This post explains how to that by using Redis as the "object storage" server.
DISCLAIMER: This post assumes that the machine where the code is executed and the Redis server is in the same machine or located within a secure premises.
You can clone theDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-61141992450158225952017-10-02T11:53:00.002+07:002017-10-02T11:53:30.495+07:00Subclassing HTMLParser Class in Python 2Using HTMLParser class (https://docs.python.org/2/library/htmlparser.html) in Python 2 is rather easy if you don't need to pass parameter to your subclass for custom processing of the HTML tags. But, what if you do? This is rather trivial to do in Python 3, as seen here. The problem with Python 2, if you follow the "normal" way of invoking the parent HTMLParser class as explained at https://Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-73362440485377174032017-05-15T12:03:00.000+07:002017-05-17T10:08:59.143+07:00Checking whether you have MS17-010 Windows Update Installed (a.k.a Guarding Against WannaCry)Kaspersky Lab GReaT team explains about protecting yourself from WannaCrypt/WannaCry infection over at: https://blog.kaspersky.com/wannacry-ransomware/16518/. The article specifically mentioned:
"Install software updates. This case earnestly calls for installing the system security update MS17-010 for all Windows users, especially when Microsoft even released it for systems that are not Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-1915033729079151032017-05-02T15:12:00.001+07:002017-05-02T15:12:36.540+07:00"Signal" Handling in Windows Console ApplicationSignal handling in Windows console application is quite different from what POSIX defines. Well, you could do it the POSIX way if you're using Visual Studio (see: signal). But, the behavior is not quite like POSIX in all circumstances. The Windows native "signal" handling is the way to go if you're using third party compiler suite or cross-compiling via MinGW-W64. The native "signal" handling is Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-60373072959936109702017-03-21T09:57:00.002+07:002017-03-21T13:51:39.426+07:00Path with Backslash in C++11 RegexString with backslash in C/C++ is sometimes problematic due to backslash being an escape character in C/C++ character string. It even got more complicated as we use the string in regular expression (regex) because backslash is also an escape character in regex. Therefore, the number of backslashes that you need grows exponentially if you intend to feed literal backslash character into the Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-20173870867263987122017-03-14T10:41:00.001+07:002017-03-14T10:41:36.160+07:00Free "Remote Desktop" Setup for Windows Home EditionsAs you might already know, all Windows Home Edition variants don't support Microsoft Remote Desktop Protocol (RDP) https://en.wikipedia.org/wiki/Remote_Desktop_Protocol. Therefore, you need different software stack as a solution to the problem.
Enter VNC (https://en.wikipedia.org/wiki/Virtual_Network_Computing). VNC is another protocol to remotely control Windows desktop. VNC can be used asDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-91345479153025540012017-02-27T13:02:00.000+07:002017-02-27T23:13:37.811+07:00Parallel Build in Linux/UnixAs a software developer, lengthy build time is always an enemy. You want to do almost anything to shorten the build time. One of the way to do that is to make the build process runs in parallel. If you are using GNU Make, it's as easy as adding "-j" flag to your build script. This is a sample bash script to do that:
#!/bin/bash
_architectures="x86_64-w64-mingw32 i686-w64-mingw32"
CPU_CORES="$(Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-7298335470195753292017-02-13T12:22:00.002+07:002017-02-13T17:19:30.109+07:00Fix for systemd v232 build failure when using GNU gperf 3.1You might encounter the build failure in this post title if you're the kind that roll your own Linux Systemd. I encountered it while building Systemd package for my Arch Linux SELinux variant.
The culprit is mismatch in lookup functions declaration--hash functions--generated by GNU gperf version 3.1 and the function declaration in Systemd version 232. I managed to complete the build afterDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-17128029208386296082017-01-18T10:30:00.003+07:002017-01-18T10:31:10.760+07:0064-bit Software Development on IBM AIXIn this post I'll talk about software development on IBM AIX by means of open source software tools in concert with native AIX development tools.
Using GCC as the compiler to compile your application in AIX is just fine. However, GCC's ld (ld-gcc) linker is not suitable to be used as the linker. This is because linking in AIX is rather tricky and apparently only AIX linker (ld-xlc) work Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-75665975727047814782017-01-18T09:46:00.002+07:002017-01-18T09:46:30.670+07:00Listening to Multicast Netlink SocketNetlink is the recommended way to communicate with Linux kernel from user-space application. In many cases, the communication is unicast, i.e. only one user-space application uses the netlink socket to communicate with a kernel subsystem that provides the netlink interface. But, what if the kernel subsystem provides a multicast netlink socket and you want to listen to the multicast kernel "Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-5018579298564778402017-01-09T23:31:00.001+07:002017-01-09T23:31:24.571+07:00The Importance of C/C++ Program Exit Status in Unix/LinuxThe return value from main() in C/C++ programs a.k.a exit status is often overlooked by less advanced Unix/Linux programmers. Nevertheless, it's important to keep in mind the exit status of your C/C++ code because it will help in the long run. There are at least 2 scenarios where exit status is important:
When you're using shell script to automate processing by using several programs to Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-67132866619818541512016-12-07T21:46:00.000+07:002016-12-08T13:28:59.043+07:00How to "interface" Runtime Error Handling between C++11 (Modern C++) and C Code This post explore the idea to interface runtime error handling between C++11 and C. This is important because most OS API are exposed via C libraries. Moreover, there are countless C libraries out there that uses C-styled runtime error handling as well.
Anyway, before moving further I want to emphasize that assertion has a different goal compared to runtime error handling. Assertion is meant to Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-86637148328120476572016-11-25T23:13:00.000+07:002016-12-07T09:23:17.879+07:00Dealing with Opaque C Pointer in C++11This post explains how to deal with opaque C pointer in C++11--read: how to interface with C in C++11. This is important to know for those working on real world C++11 code because there are many C libraries out there that uses opaque pointer as their "interface" to other code, which in this particular case: C++11 application. It's also important to know for C++11 programmers because the wayDarmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-87187964070762920552016-10-31T10:16:00.002+07:002016-10-31T10:16:30.498+07:00Cross Compiling Unicode Windows Application with Mingw-w64Cross compiling Unicode Windows application in Linux is quite straight forward if you are using mingw-w64 cross compiler. All you have to do is turn on the -municode compiler switch. Other than that, you need to change your program entry point from main() to wmain() if your program is a command line program. I provided a complete sample code over at https://bitbucket.org/pinczakko/Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0tag:blogger.com,1999:blog-5964008201936624679.post-5413075598100305862016-10-27T12:49:00.001+07:002016-10-27T12:49:32.648+07:00What operator int() means in C++?Short answer to the title of this post: It's a user-defined conversion to int.
Long answer: read on ;-). The code below is a sample of the user-defined conversion.
class MyClass {
public:
//..
operator HANDLE() const { return(m_hCJ); }
//..
private:
HANDLE m_hCJ; // handle to volume
//..
};
The code above would return MyClass object's m_hCJ member value Darmawan Salihunhttp://www.blogger.com/profile/16192437872942077146noreply@blogger.com0