Skip to content

Instantly share code, notes, and snippets.

View shawnfeng0's full-sized avatar
💭
Keep thinking

Shawn Feng shawnfeng0

💭
Keep thinking
View GitHub Profile
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();
/**
* 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)) {
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.");
* }
@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 窗口名]

恢复会话:

@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