Skip to content

Instantly share code, notes, and snippets.

@shawnfeng0
shawnfeng0 / tmux-cheatsheet.markdown
Created October 11, 2018 04:23 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@shawnfeng0
shawnfeng0 / tmux-cheatsheet.markdown
Created October 11, 2018 05:33 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

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

恢复会话:

import android.support.annotation.NonNull;
/**
* Measuring code runtime.
* For example:
* long timeSpent = TimeMeasure.doTimeMeasureUs(() -> {
* if (!nativeSendFrame(receiverName, videoBufferByte)) {
* if (++mErrorCount >= ERROR_MAX_COUNT) {
* throw new Exception("Send frame error.");
* }
/**
* Is the Android service running?
* @param context The current context.
* @param serviceClass The service to get running state.
* @return true: if service is running.
*/
static boolean isServiceRunning(Context context, Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
if (manager == null) return false;
for (ActivityManager.RunningServiceInfo serviceInfo : manager.getRunningServices(Integer.MAX_VALUE)) {
public static List<String> getIpAddressString() {
List<String> result = new ArrayList<>();
try {
for (Enumeration<NetworkInterface> enNetI = NetworkInterface
.getNetworkInterfaces(); enNetI.hasMoreElements(); ) {
NetworkInterface netI = enNetI.nextElement();
if (netI.getDisplayName().matches("wlan(.*)") || netI.getDisplayName().matches("eth(.*)")) {
for (Enumeration<InetAddress> enumIpAddr = netI
.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
InetAddress inetAddress = enumIpAddr.nextElement();
@shawnfeng0
shawnfeng0 / docker-cross-device-link.md
Created November 28, 2018 12:53 — forked from Francesco149/docker-cross-device-link.md
docker error creating new backup file '/var/lib/dpkg/status-old': Invalid cross-device link
@shawnfeng0
shawnfeng0 / CMakeLists.txt
Created November 30, 2018 16:47 — forked from khancyr/CMakeLists.txt
Ardupilot clion
cmake_minimum_required(VERSION 2.8.4)
project(Ardupilot)
# Function: EXCLUDE_FILES_FROM_DIR_IN_LIST
# Description: Exclude all files from a list under a specific directory.
# Param _InFileList: Input and returned List
# Param _excludeDirName: Name of the directory, which shall be ignored.
# Param _verbose: Print the names of the files handled
FUNCTION (EXCLUDE_FILES_FROM_DIR_IN_LIST _InFileList _excludeDirName _verbose)
@shawnfeng0
shawnfeng0 / bits.h
Last active November 25, 2021 20:07
Read/Write some bits within a number
/**
* Modify some bits within a number
*
* @note The lowest index is 0, increasing sequentially
*
* @param origin Original data
* @param offset Offset that needs to be modified
* @param len Bit length
* @param value The value to which the specified bit needs to be replaced
* @return Modified value
@shawnfeng0
shawnfeng0 / battery_level.cpp
Last active November 14, 2019 06:12
Battery voltage level back measurement
#include <stdint.h>
#include <stdlib.h>
enum BatteryLevel {
BATTERY_LEVEL_VERY_LOW = 0,
BATTERY_LEVEL_LOW = 1,
BATTERY_LEVEL_MEDIUM = 2,
BATTERY_LEVEL_HIGH = 3,
BATTERY_LEVEL_VERY_HIGH = 4,
BATTERY_LEVEL_END = 5
@shawnfeng0
shawnfeng0 / Hex2Str.c
Created November 14, 2019 05:44
Convert hexadecimal to a string
char *Hex2Str(uint8_t *addr, size_t len, char *out_str, size_t out_str_len,
bool from_end) {
if (addr == NULL || len == 0 || out_str == NULL || out_str_len < 3)
return out_str;
len = len < (out_str_len-1) / 2 ? len : (out_str_len-1) / 2;
char hex[] = "0123456789ABCDEF";
char *str = out_str;