Skip to content

Instantly share code, notes, and snippets.

View kaimingguo's full-sized avatar

Kaiming Guo kaimingguo

View GitHub Profile
@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};
@kaimingguo
kaimingguo / FindSDL2.cmake
Last active April 15, 2020 19:37
CMake find SDL2 library modules
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindSDL2
# --------
#
# Locate SDL2 library
#
# This module defines
@kaimingguo
kaimingguo / maid.sh
Created December 10, 2019 07:26
Shell Script I Use To Automatically Clean Up My Mac. FROM: https://github.com/jgamblin/MacOS-Maid
#!/bin/bash
SECONDS=0
#Check if running as root and if not elevate
amiroot=$(sudo -n uptime 2>&1| grep -c "load")
if [ "$amiroot" -eq 0 ]
then
printf "Maid Service Require Root Access. Please Enter Your Password.\n"
sudo -v
printf "\n"
@kaimingguo
kaimingguo / Vagrantfile
Created December 6, 2019 08:33
Vagrant & VirtualBox enable serial port sample
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# ...
config.vm.provider "virtualbox" do |vb|
# ...
vb.customize ["modifyvm", :id, "--uart2", "0x2F8", 3]
# add aliases to use git-fzf method
alias git-fzf 'set arg1 = `echo \!:1* | awk '"'"'{ print $1 }'"'"'`; \\
bash -c "source ~/.config/bash/plugins/git-fzf.bash && __git_fzf_bash::$arg1" ; \\
'

Update portnsap and port distfiles server name:

cp /etc/portsnap.conf /etc/portsnap.conf.orig
sed -i "" 's|portsnap.FreeBSD.org|portsnap3.hshh.org|' /etc/portsnap.conf

Add next line into /etc/make.conf file: