Skip to content

Instantly share code, notes, and snippets.

@imhet
imhet / Mac OS 上关闭 SIP.md
Created November 4, 2019 15:59
Mac OS 上关闭 SIP

SIP 是 System Integrity Protection 的简写,译为系统完整性保护。 SIP 是 OS X El Capitan 时开始采用的一项安全技术,目的是为了限制 root 账户对系统的完全控制权,也叫 Rootless 保护机制。

Mac 系统中 SIP 状态默认是开启的。近期更新了系统版本导致该状态重新被打开,在终端运行一些命令时提示 "Operation not permitted" 。

查看 SIP 状态

终端输入 csrutil status 即可看到 SIP 的状态是 disable 还是 enable 。

关闭或开启 SIP

@imhet
imhet / RestartAppUtil.java
Created April 28, 2019 08:43
Android 重启应用的5种方式
/**
* 多种方式重启应用自身
*/
public class RestartAppUtil
{
/**
* 使用 AlarmManager 来帮助重启
@imhet
imhet / Foreground.java
Created November 24, 2015 05:48 — forked from steveliles/Foreground.java
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
@imhet
imhet / dlmusic
Created November 16, 2015 13:10 — forked from vetch/dlmusic
download 320kbps music from xiami.com
#!/usr/bin/env python
#-*-coding:utf8-*-
"""
vesion2.0
这个脚本的作用是通过输入某首歌页面的url,来实现这首歌的下载,保存到当前工作目录下。
目前可以实现高音质音乐的下载,无须账号登陆。
比如,When I'm Sixty-Four的页面的url是 http://www.xiami.com/song/1003908
download_hq_music('http://www.xiami.com/song/1003908'),将会实现When I'm Sixty-Four的320k版本下载
@imhet
imhet / gist:760a8b98551a179867d0
Created February 5, 2015 09:58
query list of keyword
ArrayList<String> channels = new ArrayList<String>();
channels.add(audienceGender);
channels.add(audienceEducation);
channels.add(audienceCity);
pushQuery.whereContainsAll("channels", channels);