Skip to content

Instantly share code, notes, and snippets.

View heruoxin's full-sized avatar
🏠
Working from home

little_cup heruoxin

🏠
Working from home
View GitHub Profile
@heruoxin
heruoxin / gist:804b112c28a34f43d7e0c1fbb8414544
Created January 29, 2018 05:05
读取 Device Owner 模式下的 ApplicationInfo
// 读列表
pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES)
// 读到之后需要过滤掉双开/访客账户的 app
boolean installed = (applicationInfo.flags | ApplicationInfo.FLAG_INSTALLED == applicationInfo.flags);
@heruoxin
heruoxin / AdvancedLinearLayoutManager.java
Last active March 29, 2022 14:30
LinearLayoutManager with fixed computeVerticalScrollOffset()
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import java.util.HashMap;
import java.util.Map;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@heruoxin
heruoxin / AdvancedLinearLayoutManager.java
Last active January 10, 2020 07:50
修复当 RecyclerView 被其他透明或半透明 View 遮挡时,LinearLayoutManager#findFirstVisibleItemPosition 等方法会失效的问题。
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import java.util.HashMap;
import java.util.Map;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
@heruoxin
heruoxin / arp_os_x.sh
Created July 2, 2014 15:05
Simple arp hack script on OS X. Install arpspoof and wireshark before using it.
#!/bin/bash
#subset=`ifconfig en0 | grep 'inet ' | cut -d" " -f2 | cut -d"." -f1-3`
#echo "nmap -sP $subset.1/24"
#nmap -sP $subset.1/24
#echo
while true; do
read -p "dst IP: " dstip
if ! [ -z $dstip ]; then
@heruoxin
heruoxin / MainActivity.java
Created March 30, 2017 10:16
使用 dataBinding 来优化 fitsSystemWindows 系统边距分发
public class MainActivity extends BaseActivity {
private ActivityMainBinding mBinding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
mBinding.setInsets(new WindowInsetsBindingAdapter.WindowInset());
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.v7.graphics.Palette;
/**
* Created by heruoxin on 16/4/15.
*/
public class ColorUtil {
Intent i = new Intent("com.catchingnow.icebox.FREEZE_APP")
.putExtra("broadcast_action", 0) // 0 冻结,1 解冻,2 解冻并运行
.putExtra("broadcast_package_name_set", {}); // String Array, action 为运行时,size 必须为 1,其余无限制
context.sendBroadcast(i);
@heruoxin
heruoxin / CDUT Xietong Router Hack.sh
Last active November 15, 2016 03:40
成都理工协同路由脚本……
#!/bin/bash
echo
echo "成都理工协同拨号路由破解脚本"
echo "算法来源:http://fyscu.com/forum.php?mod=viewthread&tid=1104"
echo "本脚本仅适用于ddwrt、openwrt、tomato的路由"
echo "使用前请确认已经在路由设置页面上调整之为PPPoE拨号模式,并最好备过份。"
echo "截至2014年2月,对CD028XXXXX@96301类型的帐号有效,对使用本脚本后的任何意外本人无力负责。"
echo
@heruoxin
heruoxin / CDUT teacher rating script.py
Last active January 3, 2016 05:19
成都理工自动评教脚本……
#!/usr/bin/python
# -*-encoding:utf-8 -*-
#CDUT teacher rating script
from urllib import urlencode
import urllib2, cookielib, re
data = {
@heruoxin
heruoxin / material_design_color.xml
Created November 16, 2015 03:56
Google Material Design Color XML for Android. var: http://www.v2ex.com/t/231395
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_500_main">#f44336</color>
<color name="red_50">#ffebee</color>
<color name="red_100">#ffcdd2</color>
<color name="red_200">#ef9a9a</color>
<color name="red_300">#e57373</color>
<color name="red_400">#ef5350</color>
<color name="red_500">#f44336</color>
<color name="red_600">#e53935</color>