Skip to content

Instantly share code, notes, and snippets.

public static <T extends Object> List<T> asList(T... args) {
List<T> list = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
list.add(args[i]);
}
return list;
}
@plateaukao
plateaukao / lollipop.java
Created September 27, 2015 04:08
How to detect foreground process name in Android with Lollipop
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static String getForegroundProcess(Context context) {
String topPackageName = null;
UsageStatsManager usage = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
long time = System.currentTimeMillis();
List<UsageStats> stats = usage.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000*1000, time);
if (stats != null) {
SortedMap<Long, UsageStats> runningTask = new TreeMap<Long,UsageStats>();
for (UsageStats usageStats : stats) {
runningTask.put(usageStats.getLastTimeUsed(), usageStats);
@plateaukao
plateaukao / ssh_config
Last active December 18, 2015 14:09
remove comments
Host heroku.com
User freemember007
Hostname 107.21.95.3
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
port 22
import com.maddyhome.idea.vim.key.KeyParser
import com.maddyhome.idea.vim.key.Shortcut
import com.maddyhome.idea.vim.command.Command
import javax.swing.KeyStroke
import java.awt.event.KeyEvent
// gc, gf, gs, ga でそれぞれのGotoコマンド実行
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoClass", Command.Type.OTHER_READONLY, new Shortcut("gc"))
parser.registerAction(KeyParser.MAPPING_NORMAL, "GotoFile", Command.Type.OTHER_READONLY, new Shortcut("gf"))