Skip to content

Instantly share code, notes, and snippets.

os_log

六大好處

  1. Log Viewer
    • Built in Apple GUI App “Console”
  2. Log store
    • 存放在Apple 指定的位置不用擔心。
    • 存成特定的 binary file,非常有效率。
  • 自動依照 log 等級,決定不同寫入時機點。
@ot32em
ot32em / play_feature_match.py
Last active December 12, 2022 04:31
Play opencv SIFT, SURF, BRISK, or ORB
# Step 1: https://www.python.org/downloads/ => Install Python 3
# Step 2: `python -m pip install --upgrade pip` => Update the pip
# Step 3: `pip install opencv-python` => Install opencv
# Step 4: `pip install opencv-contrib-python` => Install opencv contrib for non-free modules `xfeatures2d`
import numpy as np
import cv2
@ot32em
ot32em / lsJPG.ps
Created May 23, 2018 16:08
列出當前目錄中所有 JPG 檔案的名字
dir | where {!$_.PsIsContainer -and # 選不是 dir
$_.Extension -eq ".jpg"} # 選.jpg
| select-object name # 只取名字
| ft -HideTableHeaders # 把上面的 Name ===== 說明標題 hide 起來
> 1.txt # 存在旁邊的 1.txt
# Const a b 與 Identity a 是兩個極端
Const a b = F b:
- 實體 b 是誰,完全不重要。
- 不管怎樣,我都只要 (容器/F/Const a) 的 a。
Identity b = F b
- Context/Side Effect 完全不重要。
- 不管怎樣 (容器/F/Identity) 怎樣算,我都只要內容物的 b。

ConnectionPoint 標準介面群:

IConnectionPointContainer / similiar to connection factory

外部尋問 Interface/Callback 有無的入口

  • FindConnectionPoint() 讓外部尋問,此 COM 有無支援某 Interface 的 callback。如果有,就回傳對應該 interface 的 IConnectionPoint
  • EnumConnectionPoints() 到下一層

IConnectionPoint / similiar to connection class

@ot32em
ot32em / WindowsMBStrConv.cpp
Created March 7, 2018 06:22
In Windows, 4 ways to convert from Multibytes of current code page and 3 ways to convert from UTF8.
#include <windows.h>
#include <cstdio>
#include <iostream>
#include <atlbase.h>
#include <atlstr.h>
#include <atlconv.h>
#include <string>
#include <codecvt>
#include <xlocbuf>
@ot32em
ot32em / sort_imp.cpp
Last active April 27, 2017 11:05
sorting imp
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <string>
// bubble sort
@ot32em
ot32em / VM 增大術.md
Last active April 3, 2019 11:23
將你的 Virtual Box 上的 vdi,在 Linux/LVM 的架構下,擴充本來 8GB 不夠用的大小。
@ot32em
ot32em / understand_do_notation.purs
Last active April 5, 2017 14:29
Understainding do notation
expr = do -- A chain of >>=, flatMap, chain the a -> T b
a <- [1, 2] -- The init T a, T a :: Array Int, make T is Array
b <- [Just 4] -- f, f :: Int(a) -> Array Maybe Int,
pure unit -- g, g :: Maybe Int(b) -> Array Unit
c <- ["a","b"] -- h, h :: Unit -> Array String
empty -- i, i :: String(c) -> Array Unit
d <- [5, 6] -- j, j :: Unit -> Array Int
[7, 8] -- k, k :: Int(d) -> Array Int
pure $ d -- l, l :: Int(ignored) -> Array Int
{-