Skip to content

Instantly share code, notes, and snippets.

#!bin/bash
WORK_PATH="$PWD"
function list() {
SAVEIFS=$IFS
IFS=$'\n'
for file in $1/*
do
echo $file
@was0107
was0107 / gist:1d87012db3873310053d66519efd41b5
Created December 28, 2016 06:27
pull当前目录下的所有GIT项目
#!bin/bash
WORK_PATH="$PWD"
function list() {
SAVEIFS=$IFS
IFS=$'\n'
for file in $1/*
do
echo $file
@was0107
was0107 / getMemoryUsage
Created August 12, 2016 05:45
getMemoryUsage
#pragma mark - Memory methods
double getMemoryUsage(void) {
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
double memoryUsageInMB = kerr == KERN_SUCCESS ? (info.resident_size / 1024.0 / 1024.0) : 0.0;
return memoryUsageInMB;
@was0107
was0107 / TouchLight TouchDark
Created January 22, 2014 08:03
点击图片变暗或者变亮 ----一张图片实现
public static final OnTouchListener TouchLight = new OnTouchListener() {
public final float[] BT_SELECTED = new float[] { 1, 0, 0, 0, 50, 0, 1, 0, 0, 50, 0, 0, 1, 0, 50, 0, 0, 0, 1, 0 };
public final float[] BT_NOT_SELECTED = new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 };
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.getBackground().setColorFilter(new ColorMatrixColorFilter(BT_SELECTED));
v.setBackgroundDrawable(v.getBackground());
@was0107
was0107 / Rotate3dAnimation
Last active January 3, 2016 23:49
点赞
/**
* An animation that rotates the view on the Y axis between two specified
* angles. This animation also adds a translation on the Z axis (depth) to
* improve the effect.
*/
public class Rotate3dAnimation extends Animation
{
private final float mFromDegrees;
private final float mToDegrees;
private final float mCenterX;
@was0107
was0107 / RotateAnimation
Last active January 8, 2018 08:25
android 界面翻转动画
public class RotateAnimation extends Animation
{
/** 值为true时可明确查看动画的旋转方向。 */
public static final boolean DEBUG = false;
/** 沿Y轴正方向看,数值减1时动画逆时针旋转。 */
public static final boolean ROTATE_DECREASE = true;
/** 沿Y轴正方向看,数值减1时动画顺时针旋转。 */
public static final boolean ROTATE_INCREASE = false;
/** Z轴上最大深度。 */
public static final float DEPTH_Z = 310.0f;
@was0107
was0107 / ReceiveBroadcastView
Last active December 31, 2015 12:19 — forked from cyrilmottier/gist:2367432
接收ReceiveBroadcast的视图
package com.cyrilmottier.android.androidtips;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
@was0107
was0107 / TimeUtility
Last active December 31, 2015 05:39
时间转化在距离当前多久的工具类
public class TimeUtility {
private static int MILL_MIN = 1000 * 60;
private static int MILL_HOUR = MILL_MIN * 60;
private static int MILL_DAY = MILL_HOUR * 24;
private static String JUST_NOW = GlobalContext.getInstance().getString(R.string.justnow);
private static String MIN = GlobalContext.getInstance().getString(R.string.min);
private static String HOUR = GlobalContext.getInstance().getString(R.string.hour);
private static String DAY = GlobalContext.getInstance().getString(R.string.day);
@was0107
was0107 / gist:7866518
Created December 9, 2013 02:19
通过反射来设置对话框是否要关闭
/**
* 通过反射来设置对话框是否要关闭,在表单校验时很管用, 因为在用户填写出错时点确定时默认Dialog会消失, 所以达不到校验的效果
* 而mShowing字段就是用来控制是否要消失的,而它在Dialog中是私有变量, 所有只有通过反射去解决此问题
*
* @param pDialog
* @param pIsClose
*/
public void setAlertDialogIsClose(DialogInterface pDialog, Boolean pIsClose) {
try {
Field field = pDialog.getClass().getSuperclass()