Skip to content

Instantly share code, notes, and snippets.

View Richie97's full-sized avatar

Eric Richardson Richie97

View GitHub Profile
@Richie97
Richie97 / Tabletcheck2
Created April 13, 2012 19:55
More Tablet checking code
public boolean isTablet(Context context) {
boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
return (xlarge || large);
}
@Richie97
Richie97 / androidTabletChecker
Created April 12, 2012 21:49
Tablet Checker
/**
* Checks if the device is a tablet or a phone
*
* @param activityContext
* The Activity Context.
* @return Returns true if the device is a Tablet
*/
public static boolean isTabletDevice(Context activityContext) {
// Verifies if the Generalized Size of the device is XLARGE to be
// considered a Tablet
@Richie97
Richie97 / gist:2008332
Created March 9, 2012 19:54
Resizing Bitmaps
public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
@Richie97
Richie97 / gist:2004295
Created March 9, 2012 00:19
immutable Bitmap into mutable bitmap.
public static Bitmap convertToMutable(Bitmap imgIn) {
try {
//this is the file going to use temporally to save the bytes.
// This file will not be a image, it will store the raw image data.
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.tmp");
//Open an RandomAccessFile
//Make sure you have added uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
//into AndroidManifest.xml file
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
class CheckIn(db.Model):
__tablename__ = 'checkins'
id = db.Column(db.Integer, primary_key=True)
location_id = db.Column(db.Integer)
user_id = db.Column(db.Integer)
date = db.Column(db.DateTime)
def to_dict(self):
return{
@app.route('/locations/add', methods=['POST'])
def add_loc():
db.execute('insert into locations(name, blurb, phone_number, address, url) values(?,?,?,?,?)', [request.form['name'], request.form['blurb'], request.form['phone'], request.form['address'], request.form['url']])
db.commit()
return