start new:
tmux
start new with session name:
tmux new -s myname
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(); |
on linux 4.19, I get
error creating new backup file '/var/lib/dpkg/status-old': Invalid cross-device link
when trying to install stuff on a ubuntu docker container. this seems to be an issue with metacopy https://www.spinics.net/lists/linux-unionfs/msg06109.html
issue can be worked around by running
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) |
/** | |
* 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 |
#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 |
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; |