Diary

AWS EC2 Amazon Linux 2 AMI 2.0 Instance Initial Setup with Japanese Language Support

1 Mins read

Update Libraries

sudo yum update

Set timezone to Asia/Tokyo
sudo timedatectl
sudo timedatectl set-timezone Asia/Tokyo

Japanese language settings #localectl ja_JP.utf8
localectl
sudo localectl set-locale LANG=ja_JP.utf8
localectl
cat /etc/locale.conf
sudo localectl set-keymap jp106
cat /etc/vconsole.conf

Development tools

Install libraries needed for compilation
sudo yum -y groupinstall base "Development tools"

Install nkf command needed for Japanese text processing
wget "https://ja.osdn.net/dl/nkf/nkf-2.1.4.tar.gz" -O nkf-2.1.4.tar.gz
tar zxvf nkf-2.1.4.tar.gz
cd nkf-2.1.4/
sudo make && sudo make install
cd ..
rm -rf nkf-2.1.4
rm -f nkf-2.1.4.tar.gz
sudo ln -s /usr/local/bin/nkf /usr/bin/nkf

Automatic Time Sync and Update Settings

sudo yum -y install chrony

sudo vi /etc/chrony.conf

#------------------------------------
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# In comments
# pool 2.amazon.pool.ntp.org iburst

# Add these
server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst
#------------------------------------

sudo systemctl restart chronyd
sudo systemctl enable chronyd

#Check
sudo chronyc sources

mailx

Email environment often needed. Not pre-installed on AMI, so set it up for administrative use.
※sendmail[postfix] comes pre-installed

# Work as root
sudo su -

# mail command not available without module, so install it
yum install mailx

# Delete old root mail just in case
sed -i '/^root:/d' /etc/aliases

# Root mail forwarding
echo "root: hoge@hogetaro.com" >> /etc/aliases

# Apply changes
newaliases

# Test
echo testtaro | mail root

# Return to user
Exit

※AWS strictly manages email sending on port 25. High volume outbound email may get blocked. If that happens, go through the approval process.
Approval is required to set up a proper SMTP server.
https://forums.aws.amazon.com/thread.jspa?threadID=153660

telnet

Convenient utility. Install if desired.

sudo yum -y install telnet
Read more
Diary

SyntaxHighlighter in WordPress Posts Causes HTML Escape Character Display Issues

1 Mins read

WordPress 5.2.1
SyntaxHighlighter plugin 3.5.0

When pasting source code wrapped in SyntaxHighlighter tags, HTML escape characters (greater than/less than signs, etc.) are not displayed correctly.

It appears the WordPress post editor is encoding strings when focus leaves the text box, and this process is causing the problem.

For now, clicking the undo icon in the upper left once reverts to the pre-encoded state, then publishing after that displays correctly.

※The encoding process also runs when the publish button is clicked, so reverting is safe.
Don’t put focus back on the post text box!

 

Update 20190829

Classic Editor

solves the problem!

 

Read more
Diary

Calling a ViewController from Storyboard Programmatically in iOS Xcode Swift 4.2

1 Mins read

Mac 10.14.5
Xcode 10.2.1
Swift 4.2

How to call a ViewController from Storyboard programmatically
This sample targets Main.storyboard. Make sure to clear the settings beforehand:
“General” > “Deployment Info” > “Main Interface”

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
 
    var window: UIWindow?   //Main Window
 
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
 
        window = UIWindow(frame: UIScreen.main.bounds)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateInitialViewController()
        window?.rootViewController = viewController
        window?.makeKeyAndVisible()
 
        return true
    }
}
Read more