做一个安静的小丑

挺好的。

三十岁了,过生日好像是很久以前的事情了。隐约感觉人生的快乐已经走起了下坡路,与十几二十的幸福时光渐行渐远了。

这一切也许是必然的,年轻的时候对未来无限的憧憬和想象也逐渐被现实打败。我觉得我还是幸运的,人生走了很多弯路,流过很多眼泪,挺过去了,天便晴了一半。 我对命运没有怨言,毕竟老天对我眷顾不少。

去年有了宝宝,看着他一天天长大,发育强壮,从吃喝拉撒睡的无聊循环,到抬头翻身爬着走,咿咿呀呀叫爸爸,是我每天都能感受到的阳光。

我自认为做事比身边的人更尽力,但是还是不知道怎么了,像是被若隐若现的愧疚感笼罩。我仿佛是一个罪人,对不起所有人。 或者说我有原罪,要用一生去偿还,还不一定能还完。

有的时候不知道一张张笑脸背后是发自内心的,还是出于客气与尊重。也不知道一双双眼睛在哪里盯着我,是单纯想看看我,还是拿出小本本记下我哪里没做到没做好,将来遇到不满意的时候套进 “他竟然说了/做了【XX】, 连【XXX】都【XXX】” 的句式里。

我希望我还是曾经的我,勇往直前,大胆放手,不在乎他人眼光和感受的我。 若是畏首畏尾终究会死在别人的眼光里,一辈子也就这样了,一眼望到头。

伤口会愈合,伤疤一直在。凑合活着也许是大多数人的归宿。

 

也许男人真的都是奴才命?为了一点点甜头要苦苦撑着? 被耍的团团转?一次次低三下四,死皮赖脸,结果却也只能这样。写下这篇blog,想给自己提个醒,少在这个看不到头死循环里面浪费时间和感情了。我觉得我自己不应该被这样对待,竭尽全力对别人,举手之劳的事,别人对我确百般遮拦。我个人确信这块试金石,装都懒得装的试金石。

我的20岁是残缺的,但是恐怕接下来的人生只能凑合下去了,曾经那么多的憧憬,灰飞烟灭了。

 

一月二月连续过了业余无线电Tech和General。 圆了十年前的梦。希望我能在电波中交到朋友,陪我聊聊天。

 

 

Unlock Bell’s Carrier Lock on iPhone

For “SIM Not Supported Error” when using a SIM card other than Bell/Virgin Mobile

 

Send you device purchase agreement to

[email protected]

Their process time is usually 10-60 minutes.

 

Customer service can’t really handle this.

Yes, there’s no lock after 2018, but the store usually lock their expensive iPhone models and unlock the carrier for you after the purchase. They do forget about the unlocking step quite often.

Disable mouse zooming in Firefox

Why?

The scroll wheel on my MX master 3 doesn’t really work well with MacOS. Zooming is triggered by mistake quite often.

Windows:

  • about:config
  • mousewheel.with_control.action
  • change the value to 1

Reference: https://support.mozilla.org/bm/questions/1253302

OSX

  • about:config
  • mousewheel.with_meta.action
  • change the value to 1

In MacOS, meta key is the Command key. (Source)

The value 0 means “Do nothing”, 1 means “Scroll contents”, 2 means “Go back or forward in the history”, 3 means “Zoom in or out the contents”

More Info about the config

 

Enable MySQL/MariaDB SSL for PDO/Laravel

Server side setup

Refer to this manual from MariaDB
https://mariadb.com/kb/en/securing-connections-for-client-and-server/

require_secure_transport = ON could be added to the my.cnf file to enforece SSL for all connections (including those from localhost & unix socket)

One way SSL

Without CA verification

PDO

$pdo = new PDO('mysql:host=db.example.com;dbname=image', 'laravel', 'laravel',array(
    PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false));

Laravel (config/database.php)

// under mysql => options
'options' => extension_loaded('pdo_mysql') ? [
        PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
 ] : []

PLEASE NOTE: array_filter in this original config file is REMOVED. Because entries with empty() value will be filtered, so that MYSQL_ATTR_SSL_VERIFY_SERVER_CERT will be removed.

MYSQL_ATTR_SSL_CA is set just to enable SSL (like mysql -h …. -u … -p –ssl)

With CA verification

PLEASE BE AWARE, the cert in this mode is domain validated. The MySQL server should use a cert with matched common name, ‘db.example.com’ for example. the use of domain name for the host is preferred.

Same to without verification, but set MYSQL_ATTR_SSL_VERIFY_SERVER_CERT to true. (Or just remove the attribute, since it’s true by default)

Two way (mutual) SSL

PDO::MYSQL_ATTR_SSL_CA => "/path/to/ca-cert.pem",
PDO::MYSQL_ATTR_SSL_CERT => "/path/to/client-cert.pem",
PDO::MYSQL_ATTR_SSL_KEY => "/path/to/client-key.pem",
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false

MYSQL_ATTR_SSL_VERIFY_SERVER_CERT could be true or false, it depends.

Common Errors

PHP ‘illegal hardware instruction’ on MacOS

I’m using MacOS 10.15 using PHP 7.4.11 from homebrew.
This error basically happens when PDO SSL setup/verification failed.
For example:

PDO::__construct(): SSL operation failed with code 1. OpenSSL Error messages

Or maybe

PDO::__construct(): Peer certificate CN=Common name' did not match expected CN= domain’

I believe it’s a platform specific issue.

PDO attribute not received by Laravel

Mentioned already.
array_filter will filter out all attributes with value of null/false/0/”” …
Remove it when you have to use those values.

Fixing a “Damaged App” from App Store

Background:

  • OSX (From Apple, or Hackintosh)
  • The App was purchased from the App Store with the current iCloud ID

The problem:

  • Unable to open a previously purchased App

The error:

“Magnet” is damaged and can’t be opened. Delete “Magnet” and download it again from the App Store.

It could be any paid app, in my case, ‘Magnet’.

There exist a similar but common error caused by unsigned/modified third party apps (blocked by Gatekeeper)

App Is Damaged and Can’t Be Opened. You Should Move It To The Trash

This is NOT what my guide is talking about.

The Cause

The error basically means Apple is unable to verify the App purchased on this machine.

The MAC address of your en0 is part of the verification. Because all Macs come with a built-in Wifi/Ethernet Adapter.

Run this in your terminal to list all network interfaces.

networksetup -listallhardwareports

What exactly happened to my is, my hackintosh motherboard comes with two built-in Ethernet adapters. I disabled one (en0) from the BIOS few days after the OSX is installed.

How to fix

If you encountered the same error message, try the following:

(Software issue, basically sync your current en0 MAC address with iCloud)

  • Follow this guide from 1Password (also work for other apps from the App Store)
  • If that doesn’t help, move on:

(Hardware issue. in most cases, en0 not found)

  • list all network interfaces, find en0
  • If en0 is not found, enable it from BIOS (if you disabled it before)
  • If you didn’t remove/disable any network hardware, rename your primary interface to en0, here are some useful resources
  • After that, follow the guide from 1Password again when necessary (when it’s still not working)

If none of those work:

Go to network settings > tiny gear icon > Set service order
Open a terminal and run:

cd /Library/Preferences/SystemConfiguration/
sudo rm NetworkInterfaces.plist
sudo rm preferences.plist
Restart machine

Credit for this: Jeremy Wininger

1089. Duplicate Zeros

Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.

Note that elements beyond the length of the original array are not written.

Do the above modifications to the input array in place, do not return anything from your function.

Example 1:

Input: [1,0,2,3,0,4,5,0]
Output: null
Explanation: After calling your function, the input array is modified to: [1,0,0,2,3,0,0,4]

Example 2:

Input: [1,2,3]
Output: null
Explanation: After calling your function, the input array is modified to: [1,2,3]

Note:

1 <= arr.length <= 10000
0 <= arr[i] <= 9

Solution:

class Solution {
    public void duplicateZeros(int[] arr) {
        int count  = 0;
        for (int i = 0; i < arr.length; i ++){
            if (arr[i] == 0){
                count ++;
            }
        }
        
        int offset = count;
        for (int i = arr.length - 1; i >= 0; i --){
            if (i + offset < arr.length){
                arr[i+offset] = arr[i];
            }
            if (arr[i] == 0){
                offset --;
                if (i + offset < arr.length){
                    arr[i+offset] = arr[i];
                }
            }
        }
    }
}

 

88. Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

Note:

The number of elements initialized in nums1 and nums2 are m and n respectively.
You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.

Example:

Input:
nums1 = [1,2,3,0,0,0], m = 3
nums2 = [2,5,6], n = 3

Output: [1,2,2,3,5,6]

Constraints:

-10^9 <= nums1[i], nums2[i] <= 10^9 nums1.length == m + n nums2.length == n Solution.

class Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        // index for m
        int im = m -1;
        // index for n
        int in = n -1;
        // index for result
        int ir = m + n -1;
        
        for (;ir >= 0; ir --){
            
            if (im < 0){
                // If one of the array is all cleared, use the other
                nums1[ir] = nums2[in--];
            } else if (in < 0){
                nums1[ir] = nums1[im--];
            } else if (nums1[im] > nums2[in]){
                // Otherwise, pick the greater one.
                nums1[ir] = nums1[im--];
            } else {
                nums1[ir] = nums2[in--];
            }
        }
        
    }
}