前两天收到邮件,Oracle Cloud要把使用率低的机器停掉,以七天为一个周期。(而且我也没有办法再绑定国内的信用卡到Oracle账号)。我是达不到那个使用率了。被迫学习OCI,实时监控机器状态,关了自动重开
电脑
Quick switch between mirror and extend mode with external Display
A simple search on google would suggest the shortcut is ‘Cmd+F1’.
Yes, it works, but it is not precise. The real key combination is ‘Cmd + display_brightness_decment’. This does not make any difference for the internal keyboard, as F1 acts as display_brightness_decrement by default. However, I am using HHKB, the equivalent for the key is ‘Fn+o’.
Now I can happily switch between these 2 modes using ‘Cmd+Fn+o’. Hurrah!
Thanks to Karabiner-EventViewer during the debugging.
php-fpm out of memory
今天发现云计算平台上的Linux操作系统默认都没有开启swap。由于我使用的机器都只有512MB或1GB内存,这导致了php-fpm频繁因为超出内存而崩溃。
修复方法:开启swap
sudo fallocate -l 1G /swapfile
chmod 600 /swapfile
chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfileAdd following to /etc/fstab
/swapfile none swap sw 0 0
双宽带分流
家庭网络一直使用联通宽带,在这个联通宽带市场占有率很低的城市,它提供了最好的服务。公司的服务器在电信机房,而电信网络又对来自联通的连接随机丢包。安装两条宽带就成了解决问题的唯一办法。在过去这几年我一直都没有真正掌握iptables和Linux高级路由知识,直到今天。
在朋友的帮助下,我搞清楚了家庭网络的拓扑,写出了正确的路由和iptables设置。为了这两行设置,我总计可能花费了超过30小时。
ip route add xx.xx.xx.xx scope global nexthop via 192.168.11.1 dev eth1 iptables -t nat -A POSTROUTING -d xx.xx.xx.xx -o eth1 -j SNAT --to-source 192.168.11.3
DON’T set aggressive timeout value
I have a 12 TB USB drive connected to the Raspberry Pi 4 running Raspbian. The drive is formatted as btrfs.
The original line for this drive on fstab is
UUID=”8afd87a4-f10e-11ea-9666-bfec6b15c3e4″ /mnt/btrfsdrive btrfs defaults 0 0
The major issue is when USB drive is offline, RPi4 would not boot. A simple google search directs me to the well-known ArchLinux wikipage. This page implies that nofail,x-systemd.device-timeout=1ms works like a charm. I tried it and find it s**ks. When the USB drive is connected, only some directories are seen after booting, and this partition is NOT even shown in /proc/mounts
The root cause is obvious after comparing the booting log in /var/log/messages. timeout=1ms is not acceptable at all. In fact, the default timeout value is 90 seconds.
Not sure whether this issue happens only on RPi 4, or Raspbian, or Linux. Anyway, suggesting user to set such a small timeout value is misleading.
I am not able to correct the mistake on that wiki because the captcha during registration is What is the output of “pacman -V|base32|head -1” and I won’t install ArchLinux to get the answer…
Log of fstab options=default
Sep 7 20:51:33 myhost kernel: [ 23.019520] Btrfs loaded, crc32c=crc32c-generic
Sep 7 20:51:33 myhost kernel: [ 23.021470] BTRFS: device label myelements devid 1 transid 74693 /dev/sda
Sep 7 20:51:33 myhost kernel: [ 23.298985] BTRFS info (device sda): disk space caching is enabled
Sep 7 20:51:33 myhost kernel: [ 23.299003] BTRFS info (device sda): has skinny extents
Sep 7 20:51:33 myhost kernel: [ 27.445768] random: crng init done
Sep 7 20:51:33 myhost kernel: [ 27.445793] random: 7 urandom warning(s) missed due to ratelimiting
Sep 7 20:51:33 myhost rsyslogd: [origin software=”rsyslogd” swVersion=”8.1901.0″ x-pid=”385″ x-info=”https://www.rsyslog.com”] start
Sep 7 20:51:33 myhost kernel: [ 39.738751] uart-pl011 fe201000.serial: no DMA platform data
Sep 7 20:51:33 myhost kernel: [ 39.763978] 8021q: 802.1Q VLAN Support v1.8
Sep 7 20:51:33 myhost udisksd[401]: udisks daemon version 2.8.1 starting
Log of fstab options=nofail,x-systemd.device-timeout=1ms
Sep 7 20:44:44 myhost kernel: [ 22.972058] Btrfs loaded, crc32c=crc32c-generic
Sep 7 20:44:44 myhost kernel: [ 22.974082] BTRFS: device label myelements devid 1 transid 74693 /dev/sda
Sep 7 20:44:45 myhost kernel: [ 23.440453] broken atomic modeset userspace detected, disabling atomic
Sep 7 20:44:45 myhost kernel: [ 24.015551] broken atomic modeset userspace detected, disabling atomic
Sep 7 20:44:46 myhost lightdm[1325]: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
Sep 7 20:44:46 myhost kernel: [ 24.976452] broken atomic modeset userspace detected, disabling atomic
Sep 7 20:44:47 myhost kernel: [ 25.577489] broken atomic modeset userspace detected, disabling atomic
Sep 7 20:44:47 myhost lightdm[1335]: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
Sep 7 20:44:48 myhost kernel: [ 26.430257] broken atomic modeset userspace detected, disabling atomic
Sep 7 20:44:48 myhost kernel: [ 27.014250] broken atomic modeset userspace detected, disabling atomic
Sep 7 20:50:53 myhost udisksd[358]: udisks daemon version 2.8.1 exiting
Tips of tmux, rpath, cgdb
- To make the indicating arrow shown as straight line, not dashed line: manually set TERM to xterm-256color
- tmux will set TERM to screen-256color, which may fix the size of nested tmux. Solution: manually set TERM to xterm before launching a new tmux in a new machine.
- Use rpath to include common lib path in ELF, to make it run under CentOS5/6/7…
Set pane title in tmux 2.3
Tmux 2.3 adds a useful option called ‘pane-border-status‘. However I could not find out how to set pane title. My walk around is as below
cat ~/mylocal/bin/setpane
#!/usr/bin/env csh
printf ‘\033]2;%s\033\\’ $1
tmux set-option -g pane-border-format ‘#{pane_index} “#{pane_title}”‘
This script cannot be called within Tcl. Hope tmux will add a ‘rename-pane’ command in the future.
Remap right Option key as Ctrl on MacBook
Right Option key is almost useless for me and the built-in keyboard lacks a right Ctrl key. I find Karabiner. It works perfectly!
[2014.9.25 update] I find Karabiner could alter behavior of USB mouse. As we know, ‘Scroll direction: natual’ is really nature for MacBook’s trackpad, but not that nature for mouse wheel. Karabiner could retain normal wheel behavior while keeping trackpad ‘natural’
My setting is attached
Firefox多个用户配置文件(Profile)的设置
工作后,在同一个浏览器里同时浏览工作内容和私人内容多有不便。Firefox提供了启动时选择Profile的选项。以OS X为例
$ /Applications/Firefox.app/Contents/MacOS/firefox-bin -P personal -no-remote
这样在启动时可以直接选择personal这个profile。不同profile的插件、浏览记录等完全互相独立。
还可以把这行脚本简单包装成一个OS X的App。细节如下。Info.plist拷贝自/Applications/Firefox.app/Contents/Info.plist并作简单修改(粗体标出)。如果没有它,BetterTouchTool无法对启动的Firefox窗口提供Snapping功能。另外可以自行制作.icns图标放到”/Applications/Firefox(p).app/Contents/Resources”。
$ mkdir “/Applications/Firefox(p).app”
$ mkdir “/Applications/Firefox(p).app/Contents”
$ mkdir “/Applications/Firefox(p).app/Contents/MacOS”
$ mkdir “/Applications/Firefox(p).app/Contents/Resources”
$ cat “/Applications/Firefox(p).app/Contents/MacOS/Firefox(p)”
#!/bin/bash
/Applications/Firefox.app/Contents/MacOS/firefox-bin -P jinyao_personal -no-remote
$ cat “/Applications/Firefox(p).app/Contents/Info.plist”
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>html</string>
<string>htm</string>
<string>shtml</string>
<string>xht</string>
<string>xhtml</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeName</key>
<string>HTML Document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>HTML</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>svg</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>image/svg+xml</string>
</array>
<key>CFBundleTypeName</key>
<string>SVG document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>NSDocumentClass</key>
<string>BrowserDocument</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>text</string>
<string>txt</string>
<string>js</string>
<string>log</string>
<string>css</string>
<string>xul</string>
<string>rdf</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeName</key>
<string>Text Document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
<string>utxt</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>jpeg</string>
<string>jpg</string>
<string>png</string>
<string>gif</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>fileBookmark.icns</string>
<key>CFBundleTypeName</key>
<string>document.icns</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>GIFf</string>
<string>JPEG</string>
<string>PNGf</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>oga</string>
<string>ogg</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>audio/ogg</string>
</array>
<key>CFBundleTypeName</key>
<string>HTML5 Audio (Ogg)</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>ogv</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>video/ogg</string>
</array>
<key>CFBundleTypeName</key>
<string>HTML5 Video (Ogg)</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>webm</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>video/webm</string>
</array>
<key>CFBundleTypeName</key>
<string>HTML5 Video (WebM)</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>firefox(p)</string>
<key>CFBundleGetInfoString</key>
<string>Firefox 32.0</string>
<key>CFBundleIconFile</key>
<string>firefox(p)</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.firefox</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Firefox(p)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>32.0</string>
<key>CFBundleSignature</key>
<string>MOZB</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLIconFile</key>
<string>document.icns</string>
<key>CFBundleURLName</key>
<string>http URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>http</string>
</array>
</dict>
<dict>
<key>CFBundleURLIconFile</key>
<string>document.icns</string>
<key>CFBundleURLName</key>
<string>https URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>ftp URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ftp</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>file URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>file</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>3214.8.25</string>
<key>NSAppleScriptEnabled</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>i386</key>
<string>10.6.0</string>
<key>x86_64</key>
<string>10.6.0</string>
</dict>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSPrincipalClass</key>
<string>GeckoNSApplication</string>
<key>NSDisablePersistence</key>
<true/>
</dict>
</plist>
iPad难觅理想浏览器
对于iPad浏览器的要求:
- 支持Firefox书签同步
- 支持外接蓝牙键盘快捷键
- 有“阅读器”功能
- 可以将网页保存到Evernote
对键盘快捷键的支持只存在于Safari;Dolphin浏览器不支持1、2、3;Foxbrowser只支持2;Mercury Browser支持阅读器功能但速度非常慢,另外用键盘打字时显示有明显滞后。