Programming Tips From Software Engineer

Technical News, Documents and Tips From Software Engineer

  • January 9, 2021

2 types of Life cycle of SwiftUI

SwiftUI has 2 types of lifecycle. UIKit App Delegate SwiftUI App This post says about these life cycles. Select the life cycle of app You can select the life cycle of app when you create the project. Xcode 12 added the life cycle option into the project options dialog. However, if you choose the template for the Multiplatform, this option will not appeared. Multiplatform template always use the SwiftUI App life cycle. UIKit App Delegate UIKit App Delegate use the UIKit to implement. The framework is different by OS. UIKit App Delegate – iOS/iPadOS/tvOS AppKit App Delegate – macOS WatchKit […]

  • January 3, 2021

Setup Homebrew on Windows

Homebrew is a package manager. It supports a Linux since version 2.0 and it also supports the WSL. This article explains how to setup Homebrew in WSL. About Homebrew Homebrew can Install dependencies at once. Updates and uninstall packages easily Homebrew following steps with 1 command. Download a package. Download dependencies. Install them with valid order. Generate and execute needed scripts. Benefits on WSL Linux distributions on WSL has a package manage. Are there any befits Homebrew has? Yes. Homebrew independent from the Linux distribution. Homebrew install packages into the user’s home directory. Linux distributions on WSL has apt-get. It […]

  • January 3, 2021
  • January 3, 2021

Docker: Check the Privacy Configuration if you use Docker on macOS Catalina 10.15

The Docker can mount the folder in host OS to share with container. This article says check points if this function doesn’t work fine. The running environment of this article is macOS Catalina 10.15. When the host OS is macOS, the privacy settings also needed to be checked. Situation I have been using the web server which is running on the docker container to develop. The content files are in the folder which is shared with the container, because I want to edit them quickly. The configuration file of the Docker Composer is following: version: "3" services: nginx: build: . […]

  • January 3, 2021
  • January 3, 2021

Python: Output the log with logging module

It is general to export the log from the batch script which is executed periodically. The log is also useful to analyze the problem. You may insert the special log for debug to explore the reason of bug. The log is base facility to explore the reason of problem and recover from it. You can output the log from Python script with logging module. Simple Logging Most simple logging code is following. import logging logging.basicConfig(level=logging.INFO)"Most Simple Log. The Value is %d.", 10) Execute this script, the following log will be output. $ python3 INFO:root:Most Simple Log. The Value is […]

  • January 2, 2021
  • December 26, 2020

Python: Get the Command Line Argument with ArgumentParser

It is easy to get the command line argument of python shell script with ArgumentParser class. The ArgumentParser class has following functions: Get the positional required argument Get the optional argument Output the help If the script executed without required arguments, the ArgumentParser class abort the script. It is hard work to write above functions by yourself in your own script. Basic usage The basic code to use `ArgumentParser` class is following: import argparse # Allocate the parser parser = argparse.ArgumentParser() # Register arguments to the parser # Parse command line arguments # The result will be returned into the args variable. args […]

  • January 1, 2021
  • December 26, 2020

Creating the disk image file has HFS+ file system

The default file system of the macOS is changed to APFS since macOS High Sierra 10.13. The file system of the disk image file which is created by the Disk Utility had been changed to APFS also. They are not able to mount on earlier OS than macOS 10.13 which not supports APFS. This article how to create the disk image file with specify the file system. Creating the disk image file To create the disk image file, you can following way: Use the Disk Utility Use the hdiutil To specify the file system, use hdiutil to create the disk […]

  • December 31, 2020
  • December 26, 2020

Creating the zip file in format as same as Finder

Finder has a function create the zip file from the file or the folder. This zip file is different from the zip file Windows creates. This article says this zip file as Finder style zip file. You can create this zip file from the terminal and the shell script. You can create it in the automated script. This article explains that how to create the Finder style zip file and how to expand it. Creating the Finder style zip file You can create the Finder style zip file with ditto. $ ditto -c -k --sequesterRsrc --keepParent Test Above line […]

  • December 30, 2020
  • December 26, 2020

Localizing the site title and catch phrase with THE THOR WP Theme and the Bogo plugin

2020/11/29 : Our site no longer use Bogo. We use Language Switcher Plug-in, and install new instance of the WordPress for each languages. The Language Switcher Plug-in insert the href tag and links to other language pages. This blog have been using the wordpress theme “THE THOR”. The other language version is also created and to localize with plugin “Bogo”. The Bogo has a function to replace text but the site title and the catch phrase couldn’t replace, so they had been exported in Japanese because the main language of this blog is Japanese. I want to replace them too […]

  • December 29, 2020
  • December 26, 2020

Supporting notarization services in the installer

If the application is packaged into the installer package and it is deployed, the installer package also need to support the Notarization Services. This article explains that how to support Notarization Services for the installer. Overview of How to make the installer The installer of macOS is created with following 2 steps. Create the component package with pkgbuild. Create the deployment installer with productbuild. If the deployment file is disk image format, the step to create the dmg file with hdiutils will be followed. And you will upload it to the Apple Notarization Services. Prerequirements of the Notarization In prerequirements […]

  • December 28, 2020
  • December 26, 2020

Introduction to Combine | Connecting to the Web Server with the Combine

This article explains that how to connect to the web server with the Combine. Create the Publisher of the DataTask Create the publisher of the data task to connect to the web server. Two methods are available to create it: func dataTaskPublisher(for: URL) -> URLSession.DataTaskPublisher func dataTaskPublisher(for: URLRequest) -> URLSession.DataTaskPublisher The first method has an argument “URL”. If you want to simply connect to the URL and GET the contents, you can use this method. The second method has an argument “URLRequest”. With “URLRequest”, you can set the method of the HTTP, the body data, the header value and so […]


>Programming Tips From Software Engineer

Programming Tips From Software Engineer

Technical News, Documents and Tips.