Skip to content

Instantly share code, notes, and snippets.

View kaimingguo's full-sized avatar

Kaiming Guo kaimingguo

View GitHub Profile
@kaimingguo
kaimingguo / Vagrantfile
Created March 10, 2025 08:20
Vagrant Box and k3s, Cilium
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@kaimingguo
kaimingguo / README.md
Created March 2, 2025 14:20
Search Project TODOs with fzf
rg --color=always --line-number "TODO|FIXME|XXX|HACK|BUG|NOTE" | \
fzf --ansi \
    --delimiter : \
    --preview 'bat --style=numbers --color=always --highlight-line {2} {1}' \
    --preview-window '+{2}-/2'
@kaimingguo
kaimingguo / Cargo.toml
Created March 2, 2025 08:43
Taiwan Powerball numbers generator
[package]
name = "tw-powerball-rs"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.9"
@kaimingguo
kaimingguo / main.go
Created February 6, 2025 01:53
Self-signed certificate in Go
package main
import (
"crypto"
"crypto/ecdsa"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/base64"
@kaimingguo
kaimingguo / gist:2381ecd16c0c219236e2af8e5ce3345e
Last active February 5, 2025 09:16
Search for TODO-style comments in project
rg --color=always --line-number "TODO|FIXME|XXX|HACK|BUG|NOTE" | \
    fzf --ansi \
        --delimiter : \
        --preview 'bat --style=numbers --color=always --highlight-line {2} {1}' \
        --preview-window '+{2}-/2'
  1. rg (ripgrep): searches for common comment patterns:
  • Uses --color=always to preserve colors for fzf
@kaimingguo
kaimingguo / README.md
Created February 15, 2024 01:25
Start chrome using a specified user profile

Start chrome browser with Profile 1 in a new tab.

$ open -a "Google Chrome" --args --profile-directory="Profile 1"

Start Brave browser with Default in a new tab.

$ /Applications/Brave\ Browser/Contents/MacOS/Brave\ Browser --profile-directory="Default"
@kaimingguo
kaimingguo / main.go
Created January 30, 2024 03:05
Example of adding a password to a specific presentation in Go
package main
import (
"math/rand"
"path/filepath"
"time"
"github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
"github.com/scjalliance/comshim"
@kaimingguo
kaimingguo / main.cc
Created December 6, 2023 11:04
Automation OLE Display PowerPoint Version
#include <assert.h>
#include <ole2.h>
#include <iostream>
#include <memory>
#include <sstream>
#include <vector>
template <class T>
void SafeRelease(T **ppT) {
@kaimingguo
kaimingguo / iso8601-duration-parser.go
Created March 28, 2023 08:09
ISO8601 duration format parser
package main
import (
"fmt"
"regexp"
"strconv"
"time"
)
func main() {
@kaimingguo
kaimingguo / demo.cc
Created April 15, 2020 19:51
Win32 API multi-monitor display information
#include <windows.h>
#include <iostream>
#include <vector>
struct ScreenArray {
std::vector<RECT> Monitors;
static BOOL CALLBACK MonitorEnumProc(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) {
MONITORINFOEX mi = {0};