Skip to content

Instantly share code, notes, and snippets.

@tctony
tctony / build-libopus-m1.sh
Created August 1, 2022 11:21 — forked from mmsarquis/build-libopus-m1.sh
Build Opus library on Mac M1 for multiple platforms
apple#!/bin/bash
VERSION="1.3.1"
SDKVERSION_IPHONE="14.5"
ARCHS_DEVICES_IPHONE="arm64e armv7"
ARCHS_SIMULATOR_IPHONE="x86_64 arm64"
SDKVERSION_WATCH="7.4"
ARCHS_DEVICES_WATCH="arm64_32 armv7k"
// shift mapping for KeyboardEvent.key
const lowerToUpper: Record<string, string> = {};
for (let a = 'a'.charCodeAt(0); a <= 'z'.charCodeAt(0); a += 1) {
lowerToUpper[a] = String.fromCharCode(a).toUpperCase();
}
const ShiftMapping: Record<string, string> = {
'`': '~',
'1': '!',
'2': '@',
@tctony
tctony / get_unicode_char
Created December 13, 2019 13:54
convert unsigned int to unicode char
void GetUnicodeChar(unsigned int code, char chars[5]) {
if (code <= 0x7F) {
chars[0] = (code & 0x7F); chars[1] = '\0';
} else if (code <= 0x7FF) {
// one continuation byte
chars[1] = 0x80 | (code & 0x3F); code = (code >> 6);
chars[0] = 0xC0 | (code & 0x1F); chars[2] = '\0';
} else if (code <= 0xFFFF) {
// two continuation bytes
chars[2] = 0x80 | (code & 0x3F); code = (code >> 6);
@tctony
tctony / Makefile
Created September 25, 2019 09:06 — forked from mawenbao/Makefile
googletest simple example
# Makefile for gtest examples
GOOGLE_TEST_LIB = gtest
GOOGLE_TEST_INCLUDE = /usr/local/include
G++ = g++
G++_FLAGS = -c -Wall -I $(GOOGLE_TEST_INCLUDE)
LD_FLAGS = -L /usr/local/lib -l $(GOOGLE_TEST_LIB) -l pthread
OBJECTS = main.o string-compare.o
@tctony
tctony / Makefile
Created September 25, 2019 09:06 — forked from mawenbao/Makefile
googletest simple example
# Makefile for gtest examples
GOOGLE_TEST_LIB = gtest
GOOGLE_TEST_INCLUDE = /usr/local/include
G++ = g++
G++_FLAGS = -c -Wall -I $(GOOGLE_TEST_INCLUDE)
LD_FLAGS = -L /usr/local/lib -l $(GOOGLE_TEST_LIB) -l pthread
OBJECTS = main.o string-compare.o
@tctony
tctony / pre-commit-clang-format
Created April 8, 2019 10:26 — forked from wangkuiyi/pre-commit-clang-format
Git pre-commit hook that invokes clang-format to reformat C/C++/Objective-C source code.
#!/bin/bash
# git pre-commit hook that runs an clang-format stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
# modifications for clang-format by rene.milk@wwu.de
# This file is part of a set of unofficial pre-commit hooks available
# at github.
@tctony
tctony / workflow
Created February 24, 2018 09:15
xcode_open_file_in_emacs
tell application "Xcode"
set last_word_in_main_window to (word -1 of (get name of window 1))
if (last_word_in_main_window is "Edited") then
display dialog "Please save the current document and try again"
-- eventually we could automatically save the document when this becomes annoying
else
set current_document to document 1 whose name ends with last_word_in_main_window
set current_document_path to path of current_document
@tctony
tctony / emacs-pidfile.el
Created July 25, 2017 15:21 — forked from avdi/emacs-pidfile.el
Write pidfile on emacs-server startup
(setq pidfile "emacs-server.pid")
(add-hook 'emacs-startup-hook
(lambda ()
(with-temp-file pidfile
(insert (number-to-string (emacs-pid))))))
(add-hook 'kill-emacs-hook
(lambda ()
(when (file-exists-p pidfile)
(delete-file pidfile))))
@tctony
tctony / redis.service
Last active July 25, 2017 07:10 — forked from ordoghl/redis.service
redis systemd unit file
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=100000
@tctony
tctony / .gitconfig
Last active July 22, 2017 09:07
gitconfig
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true
[push]
default = simple
[alias]
co = checkout
br = branch
cm = commit