Skip to content

Instantly share code, notes, and snippets.

@Hackforid
Hackforid / ProcessName.java
Created November 15, 2017 15:59
[Android] Get Process Name
// High performance
public static String getProcessName() {
try {
File file = new File("/proc/" + android.os.Process.myPid() + "/" + "cmdline");
BufferedReader mBufferedReader = new BufferedReader(new FileReader(file));
String processName = mBufferedReader.readLine().trim();
mBufferedReader.close();
return processName;
} catch (Exception e) {
e.printStackTrace();
@Hackforid
Hackforid / get_deps.gradle
Created January 5, 2023 13:08
获取模块的依赖
task runGetDeps() {
doLast {
project.getConfigurations().each { configuration ->
// println("conf $configuration.name")
if (configuration.name == "debugCompileClasspath" && configuration.canBeResolved) {
println("conf $configuration.name")
configuration.incoming.resolutionResult.getAllDependencies().each { dep ->
println("dep => $dep")
}
}
@Hackforid
Hackforid / Kotlin
Created August 19, 2019 07:25
ButterKnife-Reflection
import org.gradle.api.Plugin
import org.gradle.api.Project
class ButterKnifePlugin: Plugin<Project> {
private val KAPT_NAME = "kapt"
private val APT_NAME = "annotationProcessor"
private val KOTLIN_KAPT_PLUGIN_ID = "org.jetbrains.kotlin.kapt"
private val BUTTER_KNIFE_PLUGIN_ID = "com.jakewharton.butterknife"
@Hackforid
Hackforid / FrescoHttpDNSInterceptor.kt
Created August 10, 2018 06:44
Fresco HTTP DNS Interceptor
import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException
/**
* Fresco无法直接设置request的header来传递Hostname
* 通过提供Interceptor来添加和video相同的httpdns支持
* 同时图片下载的成功与否也会用来对host进行评分
@Hackforid
Hackforid / base.py
Created May 13, 2015 08:25
Sqlalchemy use scoped_session in Tornado
# -*- coding: utf-8 -*-
import store
from tools.tor import ThreadRequestContext
class BaseHandler(RequestHandler):
def prepare(self):
store.db()
@Hackforid
Hackforid / java
Created November 23, 2017 11:32
ua
builder.header("X-AppEngine-Country", DeviceUtils.getCountryISO())
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("User-Agent", SMAuthUtilsProxy.getUserAgent() + ConnectionManager.getConnectType())
.header("app-language", DeviceUtils.getLanguageCodeWithCountry())
.header("locale", DeviceUtils.getLanguageCodeWithCountry())
.header("country", DeviceUtils.getCountryISO())
.header("cpu-abi", SystemUtils.getMostPreferredABI())
.header("unique-key", getUniqueKey());
@Hackforid
Hackforid / deeplink.html
Created September 22, 2017 02:47
Deeplink兼容实现
Analysic Version 6.1.3
Total: 67931 Fail: 10008(14.73%) Multi Fail: 439(0.65%)
createRecord failed: 687 (6.86%, 1.01%)
Good 0 0.00%
Normal 0 0.00%
Poor 0 0.00%
None 0 0.00%
compose Error: 1508 (15.07%, 2.22%)
Good 0 0.00%
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="gentoo"
# Example aliases
@Hackforid
Hackforid / CompatCollapsingToolbarLayout.java
Created March 30, 2017 13:04
CompatCollapsingToolbarLayout
public class CompatCollapsingToolbarLayout extends CollapsingToolbarLayout {
private boolean mLayoutReady;
public CompatCollapsingToolbarLayout(Context context) {
this(context, null);
}
public CompatCollapsingToolbarLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}