Skip to content

Instantly share code, notes, and snippets.

@hungtatai
hungtatai / tmux-cheatsheet.markdown
Created October 25, 2017 06:01 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
@hungtatai
hungtatai / make_function.cpp
Created August 9, 2017 06:38 — forked from duckie/make_function.cpp
C++11 - make_function : template resolution of a callable (function, lambda or functor) to the corresponding std::function
#include <functional>
namespace functional {
template <typename Function> struct function_traits;
template <typename ClassType, typename ReturnType, typename... Args>
struct function_traits<ReturnType(ClassType::*)(Args...) const> {
using function = const std::function<ReturnType(Args...)>;
};
@hungtatai
hungtatai / install.sh
Last active December 26, 2016 12:23 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

How to update all packages on ubuntu?

sudo apt-get update        # Fetches the list of available updates
sudo apt-get upgrade       # Strictly upgrades the current packages
sudo apt-get dist-upgrade  # Installs updates (new ones)

or

SCRIPT_PATH=$(dirname $(readlink -f $0))
echo $SCRIPT_PATH
// Get Environment Variable from $FILE and Set to Current Environment
function ExtractEnv () {
FILE_PATH=$1
ITEM_NAME=$2
VALUE=`cat $FILE_PATH | awk 'BEGIN{FS="="}{ if ($1 ~ /\s*'$ITEM_NAME'\s*/) print $0}' | sed 's/^\s*'$ITEM_NAME'\s*=\s*//'`
eval "$ITEM_NAME='$VALUE'"
}
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.df diff
git config --global alias.cur "rev-parse --abbrev-ref HEAD" # get current branch
#include <stdio.h>
/*
如果要在 main 用 d ,那跟在 A 用 *a 或在 B 用 b 意思是一樣的
但如果要在 main 用 &d ,那跟在 B 用 &b 意思是不一樣的,切記要用 A 的 a 當做做法
*/
void A (int **a) {
printf("A: *a: %p\n", *a);
printf("A: a: %p\n", a);
}
<?php
// https://blog.ladsai.com/php-utf8-%E7%B0%A1%E7%B9%81%E8%BD%89%E6%8F%9B.html#more-141
function gb2312_to_big5($str)
{
global $utf8_gb2312, $utf8_big5;
$str_t = '';
$len = strlen($str);
$a = 0;