Skip to content

Instantly share code, notes, and snippets.

View yijiem's full-sized avatar
🏠
Working from home

Yijie Ma yijiem

🏠
Working from home
  • 04:03 (UTC -07:00)
View GitHub Profile
@yijiem
yijiem / .bash_aliases
Created August 27, 2020 16:14 — forked from vratiu/.bash_aliases
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@yijiem
yijiem / sync_gdrive.py
Created August 27, 2020 01:55 — forked from markuscraig/sync_gdrive.py
Rclone + Google Drive sync script
#!/usr/bin/env python
import os
import shutil
import subprocess
# global variables
SYNC_DIRS = [
{
'src': "/Volumes/PhotoArchive/Lightroom",
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yijiem
yijiem / 01-mac-profiling.md
Created July 6, 2020 23:15 — forked from loderunner/01-mac-profiling.md
Profiling an application in Mac OS X

Profiling an application in Mac OS X

Finding which process to profile

If your system is running slowly, perhaps a process is using too much CPU time and won't let other processes run smoothly. To find out which processes are taking up a lot of CPU time, you can use Apple's Activity Monitor.

The CPU pane shows how processes are affecting CPU (processor) activity:

#!/usr/bin/env bash
# https://code.google.com/p/chromium/issues/detail?id=226801
url='https://chromium.googlesource.com/chromium/src/net/+/master/http/transport_security_state_static.json?format=TEXT';
curl -#s "${url}" | \
base64 --decode | \
sed '/^ *\/\// d' | \
sed '/^\s*$/d' > hsts.json;
yijiem-macpro:~ yijiem$ gpg-connect-agent --dirmngr 'keyserver --hosttable'
S # hosttable (idx, ipv6, ipv4, dead, name, time):
S # 0 hkps.pool.sks-keyservers.net
S # . hkps.pool.sks-keyservers.net
S # . --> 6 5 4 7 3 2 1*
S # 1 6 [2a00:1b98:1:4::254:0]
S # 2 6 [2001:67c:26b4:ff00::141] (pgpkeys.co.uk)
S # 3 6 [2001:67c:26b4:ff00::140] (pgpkeys.uk)
S # 4 4 209.244.105.201
S # 5 4 192.146.137.141 (pgpkeys.co.uk)
@yijiem
yijiem / pass.md
Created May 30, 2020 23:15 — forked from abtrout/pass.md
Using password-store with git repository synching

Password-store keeps your passwords (or any other sensitive information) saved in GnuPG encrypted files organized in ~/.password-store. For more information about GPG, consult the GNU Privacy Handbook.

Getting started

To get started, install pass and generate a keypair.

$ brew install pass
$ gpg --gen-key
$ gpg --list-keys
@yijiem
yijiem / cpu_affinity.h
Created January 7, 2020 10:36
context switch benchmark
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stdio.h>
#include <pthread.h>
#include <mach/thread_policy.h>
#include <mach/thread_act.h>
#define SYSCTL_CORE_COUNT "machdep.cpu.core_count"
typedef struct cpu_set {
@yijiem
yijiem / §(Toggle Wi-Fi).app
Created December 17, 2019 15:49 — forked from viktorklang/§(Toggle Wi-Fi).app
AppleScript to toggle Wi-Fi in OSX
(*
Installation instructions
=========================
Run as an Application:
1) Open AppleScript Editor and create a new script
2) Paste this file into it
3) Save name it '§(Toggle Wi-Fi)'
- Or substitute '§' for a symbol that you can press with a single key
4) Put it in Applications/Utilities
@yijiem
yijiem / main.cc
Last active November 6, 2019 03:32
StringStore
#include "string_store.h"
#include <iostream>
#include <stdlib.h>
#include <assert.h>
int main() {
StringStore ss;
if (!ss.Initialize("./")) {
std::cerr << "Initialize failed" << std::endl;