Skip to content

Instantly share code, notes, and snippets.

View khoa-io's full-sized avatar

Hoàng Văn Khoa khoa-io

View GitHub Profile
@khoa-io
khoa-io / c++
Last active September 27, 2022 04:11
Compile hello_multithreading_world.cc
$ c++ -Wall -Wextra -Werror hello_multithreading_world.cc -o hello_multithreading_world
$ ./hello_multithreading_world
Hello Multithreading World
@khoa-io
khoa-io / hello_multithreading_world.cc
Last active September 26, 2022 08:42
Hello Multithreading World (C++ Thread)
#include <iostream>
#include <string>
#include <system_error>
#include <thread>
class BackgroundTask {
public:
void operator()() const {
std::cout << "Hello Multithreading World" << std::endl;
}
@khoa-io
khoa-io / cc
Last active September 26, 2022 06:53
Compiling hello_multithreading_world.c
$ cc -Wall -Wextra -Werror hello_multithreading_world.c -o hello_multithreading_world
$ ./hello_multithreading_world
Hello Multithreading World
@khoa-io
khoa-io / hello_multithreading_world.c
Last active September 25, 2022 17:55
Hello Multithreading World (Pthreads)
#include <pthread.h>
#include <stdio.h>
void *helloWorld(void *arg) {
(void)(arg);
printf("Hello Multithreading World\n");
return (void *)0;
}
int main() {
@khoa-io
khoa-io / pthread_create.h
Last active September 27, 2022 06:41
The declaration of `pthread_create()`
#include <pthread.h>
int pthread_create(pthread_t *id,
const pthread_attr_t *attr,
void *(*start_routine)(void *),
void *arg);
@khoa-io
khoa-io / norm-apple.zsh-theme
Last active May 18, 2022 01:49
Zsh theme based on Norm
# Based on: norm.zsh-theme
NEWLINE=$'\n'
PROMPT='%{$fg[yellow]%} %n@%m %D{%R.%S %a %b %d %Y} %{$fg[green]%}%c $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}%{$fg[yellow]%}${NEWLINE}⌘ '
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[blue]%}git %{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} %{$reset_color%}"
ZSH_THEME_HG_PROMPT_PREFIX="%{$fg[blue]%}hg %{$fg[red]%}"
ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[yellow]%} %{$reset_color%}"
@khoa-io
khoa-io / repo
Created September 14, 2021 03:35
Yet another repo launcher that call the latest launcher
#!/usr/bin/env /bin/sh
# Yet another repo launcher that call the latest launcher
if test -f "`pwd`/.repo/repo/repo"; then
`pwd`/.repo/repo/repo $*
else
if [ ! -f "${HOME}/.local/bin" ]; then
mkdir -p "${HOME}/.local/bin"
fi
if [ ! -f "${HOME}/.local/bin/google-repo" ]; then
@khoa-io
khoa-io / aosp.zsh
Created May 5, 2021 16:22
Set up AOSP build environment for zsh
#compdef aosp
# Basic completion
complete -W "cd customize-sbox build env log reload tree unset xcode" aosp
# # Advanced completion from _aosp
# compdef _aosp aosp
# autoload -U compinit
# compinit
@khoa-io
khoa-io / open-atom.py
Created August 11, 2017 16:17
Open Folder in Atom
# -*- coding: UTF-8 -*-
# This example is contributed by Hoàng Văn Khoa
# Example modified for Atom
# Based on https://github.com/gnunn1/tilix/blob/master/data/nautilus/open-tilix.py
# Installation:
# mkdir -p ~/.local/share/nautilus-python/extensions
# cp open-atom.py ~/.local/share/nautilus-python/extensions
from gettext import gettext, textdomain
from subprocess import PIPE, call
@khoa-io
khoa-io / .clang-format
Created August 11, 2017 15:50
"Visual Studio" clang-format style
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true