Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Rustacean

Folyd Folyd

🦀
Rustacean
View GitHub Profile
@Folyd
Folyd / git-author_rewrit.sh
Created Sep 6, 2015
Rewrite author information.
View git-author_rewrit.sh
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="lyshuhow@gmail.com"
CORRECT_NAME="zhushuang"
CORRECT_EMAIL="zhushuang@xiaoyezi.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
@Folyd
Folyd / signe_apk.sh
Created Sep 6, 2015
Singed apk file use local key store
View signe_apk.sh
#!/usr/bin/env bash
if [ $# -lt 2 ] ;then
echo "Please specify a key store"
exit 0
fi
if [ $# -lt 3 ] ;then
echo "Please specify a source unsigned apk file"
exit 0
fi
@Folyd
Folyd / batch_replace_text.sh
Created Sep 6, 2015
Batch replace text in mac os
View batch_replace_text.sh
#!/usr/bin/env bash
old="onFailure(MetaCode"
new="onFailure(int"
# sed -i "s/$old/$new/g" `grep $old -rl $1`
# sed -i -e "s/$old/$new/g" `ls`
#The sed command is a bit different in Mac OS X, the ‘-i’ option
# required a parameter to tell what extension to add for the backup file.
@Folyd
Folyd / DownloadManagerResolver.java
Last active Dec 21, 2017
A helper class to detect whether DownloadManager is disabled in Android device,if true show AlertDialog to tell user to enable it.
View DownloadManagerResolver.java
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatTextView;
@Folyd
Folyd / NativeCalled.java
Last active Sep 9, 2015
A annotation which to indicate the method is called by native code.
View NativeCalled.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* A annotation which to indicate the method is called by native code.
*
*/
@Folyd
Folyd / FileUtils.java
Created Sep 9, 2015
A common utility class for file I/O
View FileUtils.java
import android.content.Context;
import android.os.Environment;
import android.text.TextUtils;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@Folyd
Folyd / StatusApplication.java
Last active Feb 19, 2018
Custom Application which can detect application state of whether it enter background or enter foreground.
View StatusApplication.java
/**
* Custom Application which can detect application state of whether it enter
* background or enter foreground.
*
* @author shuang
* @reference http://www.vardhan-justlikethat.blogspot.sg/2014/02/android-solution-to-detect-when-android.html
*/
public abstract class StatusApplication extends Application implements ActivityLifecycleCallbacks {
public static final int STATE_UNKNOWN = 0x00;
@Folyd
Folyd / OnLastItemVisibleListener.java
Created Sep 9, 2015
A OnLastItemVisibleListener for ListView
View OnLastItemVisibleListener.java
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
public abstract class OnLastItemVisibleListener implements AbsListView.OnScrollListener {
private boolean mLastItemVisible = false;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
/**
* Check that the scrolling has stopped, and that the last item is
View SimpleBitmapAsyncTask.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class SimpleBitmapAsyncTask extends AsyncTask<String, Void, Bitmap> {
@Folyd
Folyd / Keyboard.java
Created Sep 9, 2015
A Piano Keyboarad View in Android
View Keyboard.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import com.theonepiano.smartpiano.R;
You can’t perform that action at this time.