Skip to content

Instantly share code, notes, and snippets.

Fanglin Chen finleyChen

Block or report user

Report or block finleyChen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cropImage.java
private void cropImage() {
// Use existing crop activity.
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(mImageCaptureUri, IMAGE_UNSPECIFIED);
// Specify image size
intent.putExtra("outputX", 100);
intent.putExtra("outputY", 100);
// Specify aspect ratio, 1:1
@finleyChen
finleyChen / saveUserData.java
Created Apr 2, 2013
save user input in sharedPreference
View saveUserData.java
private void saveUserData() {
Log.d(TAG, "saveUserData()");
// Getting the shared preferences editor
String mKey = getString(R.string.preference_name);
SharedPreferences mPrefs = getSharedPreferences(mKey, MODE_PRIVATE);
@finleyChen
finleyChen / loadUserData.java
Created Apr 1, 2013
load the user data from shared preferences. If there is no data make sure that we set it to something reasonable.
View loadUserData.java
private void loadUserData() {
// We can also use log.d to print to the LogCat
Log.d(TAG, "loadUserData()");
// Load and update all profile views
// Get the shared preferences - create or retrieve the activity
View gist:5068106
osw=new OutputStreamWriter(fOut);
BufferedWriter fbw = new BufferedWriter(osw);
try {
fbw.write(String.valueOf(smoothedInference));
fbw.write(" "+String.valueOf(System.currentTimeMillis()));
fbw.newLine();
fbw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@finleyChen
finleyChen / rename.py
Created Nov 24, 2012
python implementation to rename in batch
View rename.py
import glob, os
def rename(dir, pattern):
i=318
for pathAndFilename in glob.iglob(os.path.join(dir, pattern)):
title, ext = os.path.splitext(os.path.basename(pathAndFilename))
i+=1
os.rename(pathAndFilename, os.path.join(dir, str(i) + '.png'))
rename(r'/svm/andrew/open', r'*.png')
You can’t perform that action at this time.