Skip to content

Instantly share code, notes, and snippets.

View maoruibin's full-sized avatar
😕
todo everything

咕咚 maoruibin

😕
todo everything
View GitHub Profile
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on Git.
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
@maoruibin
maoruibin / FileUtil.java
Last active January 13, 2016 15:50
method of copy file
/**
* copy file
* @param source
* @param dest
* @throws IOException
*/
public static void copyFileUsingFileChannels(File source, File dest)
throws IOException {
FileChannel inputChannel = null;
FileChannel outputChannel = null;
@maoruibin
maoruibin / RxUtils.txt
Last active January 21, 2016 04:15
RxUtils
/**
* make a operate change to observable
* @param func
* @param <T>
* @return
*/
public static <T> Observable<T> makeObservable(final Callable<T> func) {
return Observable.create(new Observable.OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> subscriber) {
@maoruibin
maoruibin / gist:3044a47284312a234ae6
Created March 6, 2016 05:30
Create a ImageView effect when press
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Drawable drawable = getDrawable();
if (drawable != null) {
drawable.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int x = (int) event.getX();
int y = (int) event.getY();
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
//记录触摸到坐标
lastX = x;
lastY = y;
break;
@maoruibin
maoruibin / DrawableBuilder.java
Last active July 11, 2019 11:52
提供语义化 API 用来创建 Shape Drawable
**
* author : ruibin1 (ruibin1@staff.weibo.com)
* docs : https://github.com/maoruibin/maoruibin.github.com/issues/88
* build : 2019/3/21 - 3:55 PM.
*/
public class DrawableBuilder {
//默认线条粗细 1dp
private static final int defaultLineWidth = 1;
private static final int defaultLineColor = Color.parseColor("#e9e9e9");
@maoruibin
maoruibin / ListenClipboardService.java
Created February 25, 2016 13:45
生成一个处于前台状态的通知
private void showNormalNotification(Context context) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle("Title");
builder.setContentText("Description");
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setPriority(NotificationCompat.PRIORITY_MIN);
builder.setOngoing(true);
long[] vibrate = {0, 50, 0, 0};
builder.setVibrate(vibrate);
```java
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.Point;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.text.TextUtils;
@maoruibin
maoruibin / EditTextCountWatch.java
Last active March 30, 2023 09:51
EditText View 限制输入字符数,并倒计还能输入多少字符,兼容中英文字符
/**
* EditText View 限制输入字符数,并倒计还能输入多少字符,兼容中英文字符
* author : ruibin1 (ruibin1@staff.weibo.com)
* create : 2019/3/28 - 2:12 PM.
* thanks : https://github.com/FJ917/FJEditTextCount
*/
public class EditTextCountWatch {
private EditText mEtContent;
private TextView mTvNum;
//最大字符