Skip to content

Instantly share code, notes, and snippets.

View finleyChen's full-sized avatar

Fanglin Chen finleyChen

View GitHub Profile
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 April 2, 2013 00:05
save user input in sharedPreference
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 April 1, 2013 23:57
load the user data from shared preferences. If there is no data make sure that we set it to something reasonable.
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
@finleyChen
finleyChen / gist:5068106
Created March 1, 2013 21:48
write file
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 November 24, 2012 21:53
python implementation to rename in batch
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')